remove unused code

This commit is contained in:
Prome
2022-10-14 16:19:17 +08:00
parent d395d4c49c
commit c35c021bab
3 changed files with 5 additions and 44 deletions

View File

@@ -29,8 +29,7 @@ std::string GetDataURI(const std::string& data, const std::string& mime_type) {
} // namespace
WebviewHandler::WebviewHandler(bool use_views)
: use_views_(use_views), is_closing_(false) {
WebviewHandler::WebviewHandler() {
DCHECK(!g_instance);
g_instance = this;
}
@@ -46,21 +45,7 @@ WebviewHandler* WebviewHandler::GetInstance() {
void WebviewHandler::OnTitleChange(CefRefPtr<CefBrowser> browser,
const CefString& title) {
CEF_REQUIRE_UI_THREAD();
if (use_views_) {
// Set the title of the window using the Views framework.
CefRefPtr<CefBrowserView> browser_view =
CefBrowserView::GetForBrowser(browser);
if (browser_view) {
CefRefPtr<CefWindow> window = browser_view->GetWindow();
if (window)
window->SetTitle(title);
}
} else if (!IsChromeRuntimeEnabled()) {
// Set the title of the window using platform APIs.
PlatformTitleChange(browser, title);
}
//todo: title change
}
void WebviewHandler::OnAfterCreated(CefRefPtr<CefBrowser> browser) {
@@ -71,16 +56,7 @@ void WebviewHandler::OnAfterCreated(CefRefPtr<CefBrowser> browser) {
}
bool WebviewHandler::DoClose(CefRefPtr<CefBrowser> browser) {
CEF_REQUIRE_UI_THREAD();
// Closing the main window requires special handling. See the DoClose()
// documentation in the CEF header for a detailed destription of this
// process.
if (browser_list_.size() == 1) {
// Set a flag to indicate that the window close should be allowed.
is_closing_ = true;
}
CEF_REQUIRE_UI_THREAD();
// Allow the close. For windowed browsers this will result in the OS close
// event being sent.
return false;
@@ -311,7 +287,3 @@ void WebviewHandler::OnPaint(CefRefPtr<CefBrowser> browser, CefRenderHandler::Pa
const CefRenderHandler::RectList &dirtyRects, const void *buffer, int w, int h) {
onPaintCallback(buffer, w, h);
}
void WebviewHandler::PlatformTitleChange(CefRefPtr<CefBrowser> browser,
const CefString& title) {
}

View File

@@ -18,7 +18,7 @@ public CefRenderHandler{
public:
std::function<void(const void*, int32_t width, int32_t height)> onPaintCallback;
explicit WebviewHandler(bool use_views);
explicit WebviewHandler();
~WebviewHandler();
// Provide access to the single global instance of this object.
@@ -75,8 +75,6 @@ public:
// Request that all existing browser windows close.
void CloseAllBrowsers(bool force_close);
bool IsClosing() const { return is_closing_; }
// Returns true if the Chrome runtime is enabled.
static bool IsChromeRuntimeEnabled();
@@ -96,19 +94,10 @@ private:
float dpi = 1.0;
bool is_dragging = false;
// Platform-specific implementation.
void PlatformTitleChange(CefRefPtr<CefBrowser> browser,
const CefString& title);
// True if the application is using the Views framework.
const bool use_views_;
// List of existing browser windows. Only accessed on the CEF UI thread.
typedef std::list<CefRefPtr<CefBrowser>> BrowserList;
BrowserList browser_list_;
bool is_closing_;
// Include the default reference counting implementation.
IMPLEMENT_REFCOUNTING(WebviewHandler);
};

View File

@@ -14,7 +14,7 @@
#include <thread>
CefRefPtr<WebviewHandler> handler(new WebviewHandler(true));
CefRefPtr<WebviewHandler> handler(new WebviewHandler());
CefRefPtr<WebviewApp> app(new WebviewApp(handler));
CefMainArgs mainArgs;