better naming

This commit is contained in:
Prome
2022-10-14 16:09:46 +08:00
parent a24e160863
commit d395d4c49c
7 changed files with 50 additions and 50 deletions

2
.gitignore vendored
View File

@@ -41,7 +41,7 @@ migrate_working_dir/
# The .vscode folder contains launch configuration and tasks you configure in
# VS Code which you may wish to be included in version control, so this line
# is commented out by default.
#.vscode/
.vscode/
# Flutter/Dart/Pub related
**/doc/api/

View File

@@ -2,7 +2,7 @@
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
#include "simple_app.h"
#include "webview_app.h"
#include <string>
@@ -76,11 +76,11 @@ private:
} // namespace
SimpleApp::SimpleApp(CefRefPtr<SimpleHandler> handler) {
WebviewApp::WebviewApp(CefRefPtr<WebviewHandler> handler) {
m_handler = handler;
}
void SimpleApp::OnContextInitialized() {
void WebviewApp::OnContextInitialized() {
CEF_REQUIRE_UI_THREAD();
// Specify CEF browser settings here.
@@ -97,7 +97,7 @@ void SimpleApp::OnContextInitialized() {
nullptr, nullptr);
}
CefRefPtr<CefClient> SimpleApp::GetDefaultClient() {
CefRefPtr<CefClient> WebviewApp::GetDefaultClient() {
// Called when a new browser window is created via the Chrome runtime UI.
return SimpleHandler::GetInstance();
return WebviewHandler::GetInstance();
}

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2013 The Chromium Embedded Framework Authors. All rights
// Copyright (c) 2013 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
@@ -7,12 +7,12 @@
#include "include/cef_app.h"
#include <functional>
#include "simple_handler.h"
#include "webview_handler.h"
// Implement application-level callbacks for the browser process.
class SimpleApp : public CefApp, public CefBrowserProcessHandler {
class WebviewApp : public CefApp, public CefBrowserProcessHandler {
public:
SimpleApp(CefRefPtr<SimpleHandler> handler);
WebviewApp(CefRefPtr<WebviewHandler> handler);
// CefApp methods:
CefRefPtr<CefBrowserProcessHandler> GetBrowserProcessHandler() override {
@@ -34,9 +34,9 @@ public:
CefRefPtr<CefClient> GetDefaultClient() override;
private:
CefRefPtr<SimpleHandler> m_handler;
CefRefPtr<WebviewHandler> m_handler;
// Include the default reference counting implementation.
IMPLEMENT_REFCOUNTING(SimpleApp);
IMPLEMENT_REFCOUNTING(WebviewApp);
};
#endif // CEF_TESTS_CEFSIMPLE_SIMPLE_APP_H_

View File

@@ -2,7 +2,7 @@
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
#include "simple_handler.h"
#include "webview_handler.h"
#include <sstream>
#include <string>
@@ -18,7 +18,7 @@
namespace {
SimpleHandler* g_instance = nullptr;
WebviewHandler* g_instance = nullptr;
// Returns a data: URI with the specified contents.
std::string GetDataURI(const std::string& data, const std::string& mime_type) {
@@ -29,22 +29,22 @@ std::string GetDataURI(const std::string& data, const std::string& mime_type) {
} // namespace
SimpleHandler::SimpleHandler(bool use_views)
WebviewHandler::WebviewHandler(bool use_views)
: use_views_(use_views), is_closing_(false) {
DCHECK(!g_instance);
g_instance = this;
}
SimpleHandler::~SimpleHandler() {
WebviewHandler::~WebviewHandler() {
g_instance = nullptr;
}
// static
SimpleHandler* SimpleHandler::GetInstance() {
WebviewHandler* WebviewHandler::GetInstance() {
return g_instance;
}
void SimpleHandler::OnTitleChange(CefRefPtr<CefBrowser> browser,
void WebviewHandler::OnTitleChange(CefRefPtr<CefBrowser> browser,
const CefString& title) {
CEF_REQUIRE_UI_THREAD();
@@ -63,14 +63,14 @@ void SimpleHandler::OnTitleChange(CefRefPtr<CefBrowser> browser,
}
}
void SimpleHandler::OnAfterCreated(CefRefPtr<CefBrowser> browser) {
void WebviewHandler::OnAfterCreated(CefRefPtr<CefBrowser> browser) {
CEF_REQUIRE_UI_THREAD();
// Add to the list of existing browsers.
browser_list_.push_back(browser);
}
bool SimpleHandler::DoClose(CefRefPtr<CefBrowser> browser) {
bool WebviewHandler::DoClose(CefRefPtr<CefBrowser> browser) {
CEF_REQUIRE_UI_THREAD();
// Closing the main window requires special handling. See the DoClose()
@@ -86,7 +86,7 @@ bool SimpleHandler::DoClose(CefRefPtr<CefBrowser> browser) {
return false;
}
void SimpleHandler::OnBeforeClose(CefRefPtr<CefBrowser> browser) {
void WebviewHandler::OnBeforeClose(CefRefPtr<CefBrowser> browser) {
CEF_REQUIRE_UI_THREAD();
// Remove from the list of existing browsers.
@@ -104,7 +104,7 @@ void SimpleHandler::OnBeforeClose(CefRefPtr<CefBrowser> browser) {
}
}
bool SimpleHandler::OnBeforePopup(CefRefPtr<CefBrowser> browser,
bool WebviewHandler::OnBeforePopup(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
const CefString& target_url,
const CefString& target_frame_name,
@@ -120,7 +120,7 @@ bool SimpleHandler::OnBeforePopup(CefRefPtr<CefBrowser> browser,
return true;
}
void SimpleHandler::OnLoadError(CefRefPtr<CefBrowser> browser,
void WebviewHandler::OnLoadError(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
ErrorCode errorCode,
const CefString& errorText,
@@ -145,7 +145,7 @@ void SimpleHandler::OnLoadError(CefRefPtr<CefBrowser> browser,
frame->LoadURL(GetDataURI(ss.str(), "text/html"));
}
void SimpleHandler::CloseAllBrowsers(bool force_close) {
void WebviewHandler::CloseAllBrowsers(bool force_close) {
if (!CefCurrentlyOn(TID_UI)) {
// Execute on the UI thread.
// CefPostTask(TID_UI, base::BindOnce(&SimpleHandler::CloseAllBrowsers, this,
@@ -162,7 +162,7 @@ void SimpleHandler::CloseAllBrowsers(bool force_close) {
}
// static
bool SimpleHandler::IsChromeRuntimeEnabled() {
bool WebviewHandler::IsChromeRuntimeEnabled() {
static int value = -1;
if (value == -1) {
CefRefPtr<CefCommandLine> command_line =
@@ -172,7 +172,7 @@ bool SimpleHandler::IsChromeRuntimeEnabled() {
return value == 1;
}
void SimpleHandler::sendScrollEvent(int x, int y, int deltaX, int deltaY) {
void WebviewHandler::sendScrollEvent(int x, int y, int deltaX, int deltaY) {
BrowserList::const_iterator it = browser_list_.begin();
if (it != browser_list_.end()) {
CefMouseEvent ev;
@@ -182,7 +182,7 @@ void SimpleHandler::sendScrollEvent(int x, int y, int deltaX, int deltaY) {
}
}
void SimpleHandler::changeSize(float a_dpi, int w, int h)
void WebviewHandler::changeSize(float a_dpi, int w, int h)
{
this->dpi = a_dpi;
this->width = w;
@@ -193,7 +193,7 @@ void SimpleHandler::changeSize(float a_dpi, int w, int h)
}
}
void SimpleHandler::cursorClick(int x, int y, bool up)
void WebviewHandler::cursorClick(int x, int y, bool up)
{
BrowserList::const_iterator it = browser_list_.begin();
if (it != browser_list_.end()) {
@@ -211,7 +211,7 @@ void SimpleHandler::cursorClick(int x, int y, bool up)
}
}
void SimpleHandler::cursorMove(int x , int y, bool dragging)
void WebviewHandler::cursorMove(int x , int y, bool dragging)
{
BrowserList::const_iterator it = browser_list_.begin();
if (it != browser_list_.end()) {
@@ -229,7 +229,7 @@ void SimpleHandler::cursorMove(int x , int y, bool dragging)
}
}
bool SimpleHandler::StartDragging(CefRefPtr<CefBrowser> browser,
bool WebviewHandler::StartDragging(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefDragData> drag_data,
DragOperationsMask allowed_ops,
int x,
@@ -246,7 +246,7 @@ bool SimpleHandler::StartDragging(CefRefPtr<CefBrowser> browser,
return true;
}
void SimpleHandler::sendKeyEvent(CefKeyEvent ev)
void WebviewHandler::sendKeyEvent(CefKeyEvent ev)
{
BrowserList::const_iterator it = browser_list_.begin();
if (it != browser_list_.end()) {
@@ -254,7 +254,7 @@ void SimpleHandler::sendKeyEvent(CefKeyEvent ev)
}
}
void SimpleHandler::loadUrl(std::string url)
void WebviewHandler::loadUrl(std::string url)
{
BrowserList::const_iterator it = browser_list_.begin();
if (it != browser_list_.end()) {
@@ -262,28 +262,28 @@ void SimpleHandler::loadUrl(std::string url)
}
}
void SimpleHandler::goForward() {
void WebviewHandler::goForward() {
BrowserList::const_iterator it = browser_list_.begin();
if (it != browser_list_.end()) {
(*it)->GetMainFrame()->GetBrowser()->GoForward();
}
}
void SimpleHandler::goBack() {
void WebviewHandler::goBack() {
BrowserList::const_iterator it = browser_list_.begin();
if (it != browser_list_.end()) {
(*it)->GetMainFrame()->GetBrowser()->GoBack();
}
}
void SimpleHandler::reload() {
void WebviewHandler::reload() {
BrowserList::const_iterator it = browser_list_.begin();
if (it != browser_list_.end()) {
(*it)->GetMainFrame()->GetBrowser()->Reload();
}
}
void SimpleHandler::GetViewRect(CefRefPtr<CefBrowser> browser, CefRect &rect) {
void WebviewHandler::GetViewRect(CefRefPtr<CefBrowser> browser, CefRect &rect) {
CEF_REQUIRE_UI_THREAD();
rect.x = rect.y = 0;
@@ -301,17 +301,17 @@ void SimpleHandler::GetViewRect(CefRefPtr<CefBrowser> browser, CefRect &rect) {
}
}
bool SimpleHandler::GetScreenInfo(CefRefPtr<CefBrowser> browser, CefScreenInfo& screen_info) {
bool WebviewHandler::GetScreenInfo(CefRefPtr<CefBrowser> browser, CefScreenInfo& screen_info) {
//todo: hi dpi support
screen_info.device_scale_factor = this->dpi;
return false;
}
void SimpleHandler::OnPaint(CefRefPtr<CefBrowser> browser, CefRenderHandler::PaintElementType type,
void WebviewHandler::OnPaint(CefRefPtr<CefBrowser> browser, CefRenderHandler::PaintElementType type,
const CefRenderHandler::RectList &dirtyRects, const void *buffer, int w, int h) {
onPaintCallback(buffer, w, h);
}
void SimpleHandler::PlatformTitleChange(CefRefPtr<CefBrowser> browser,
void WebviewHandler::PlatformTitleChange(CefRefPtr<CefBrowser> browser,
const CefString& title) {
}

View File

@@ -10,7 +10,7 @@
#include <functional>
#include <list>
class SimpleHandler : public CefClient,
class WebviewHandler : public CefClient,
public CefDisplayHandler,
public CefLifeSpanHandler,
public CefLoadHandler,
@@ -18,11 +18,11 @@ public CefRenderHandler{
public:
std::function<void(const void*, int32_t width, int32_t height)> onPaintCallback;
explicit SimpleHandler(bool use_views);
~SimpleHandler();
explicit WebviewHandler(bool use_views);
~WebviewHandler();
// Provide access to the single global instance of this object.
static SimpleHandler* GetInstance();
static WebviewHandler* GetInstance();
// CefClient methods:
virtual CefRefPtr<CefDisplayHandler> GetDisplayHandler() override {
@@ -110,7 +110,7 @@ private:
bool is_closing_;
// Include the default reference counting implementation.
IMPLEMENT_REFCOUNTING(SimpleHandler);
IMPLEMENT_REFCOUNTING(WebviewHandler);
};
#endif // CEF_TESTS_CEFSIMPLE_SIMPLE_HANDLER_H_

View File

@@ -9,13 +9,13 @@
#import <Foundation/Foundation.h>
#import "include/wrapper/cef_library_loader.h"
#import "include/cef_app.h"
#import "../../common/simple_app.h"
#import "../../common/simple_handler.h"
#import "../../common/webview_app.h"
#import "../../common/webview_handler.h"
#include <thread>
CefRefPtr<SimpleHandler> handler(new SimpleHandler(true));
CefRefPtr<SimpleApp> app(new SimpleApp(handler));
CefRefPtr<WebviewHandler> handler(new WebviewHandler(true));
CefRefPtr<WebviewApp> app(new WebviewApp(handler));
CefMainArgs mainArgs;
NSObject<FlutterTextureRegistry>* tr;

View File

@@ -2,7 +2,7 @@
#ifndef CefBridge_h
#define CefBridge_h
#include "../../common/simple_app.cc"
#include "../../common/simple_handler.cc"
#include "../../common/webview_app.cc"
#include "../../common/webview_handler.cc"
#endif