mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-03-10 00:50:12 +01:00
This change adds support for: - Protocol and request handling. - Loading and navigation events. - Display and focus events. - Mouse/keyboard events. - Popup browsers. - Callbacks in the renderer process. - Misc. functionality required for ceftests. This change also adds a new CefBrowserProcessHandler::GetCookieableSchemes callback for configuring global state that will be applied to all CefCookieManagers by default. This global callback is currently required by the chrome runtime because the primary ProfileImpl is created via ChromeBrowserMainParts::PreMainMessageLoopRun (CreatePrimaryProfile) before OnContextCreated can be called. ProfileImpl will use the "C:\Users\[user]\AppData\Local\CEF\User Data\Default" directory by default (on Windows). Cookies may persist in this directory when running ceftests and may need to be manually deleted if those tests fail. Remaining work includes: - Support for client-created request contexts. - Embedding the browser in a Views hierarchy (cefclient support). - TryCloseBrowser and DoClose support. - Most of the CefSettings configuration. - DevTools protocol and window control (ShowDevTools, ExecuteDevToolsMethod). - CEF-specific WebUI pages (about, license, webui-hosts). - Context menu customization (CefContextMenuHandler). - Auto resize (SetAutoResizeEnabled). - Zoom settings (SetZoomLevel). - File dialog runner (RunFileDialog). - File and JS dialog handlers (CefDialogHandler, CefJSDialogHandler). - Extension loading (LoadExtension, etc). - Plugin loading (OnBeforePluginLoad). - Widevine loading (CefRegisterWidevineCdm). - PDF and print preview does not display. - Crash reporting is untested. - Mac: Web content loads but does not display. The following ceftests are now passing when run with the "--enable-chrome-runtime" command-line flag: CorsTest.* DisplayTest.*:-DisplayTest.AutoResize DOMTest.* DraggableRegionsTest.* ImageTest.* MessageRouterTest.* NavigationTest.* ParserTest.* RequestContextTest.*Global* RequestTest.* ResourceManagerTest.* ResourceRequestHandlerTest.* ResponseTest.* SchemeHandlerTest.* ServerTest.* StreamResourceHandlerTest.* StreamTest.* StringTest.* TaskTest.* TestServerTest.* ThreadTest.* URLRequestTest.*Global* V8Test.*:-V8Test.OnUncaughtExceptionDevTools ValuesTest.* WaitableEventTest.* XmlReaderTest.* ZipReaderTest.*
113 lines
4.1 KiB
C++
113 lines
4.1 KiB
C++
// Copyright 2016 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.
|
|
|
|
#ifndef CEF_LIBCEF_BROWSER_VIEWS_BROWSER_VIEW_IMPL_H_
|
|
#define CEF_LIBCEF_BROWSER_VIEWS_BROWSER_VIEW_IMPL_H_
|
|
#pragma once
|
|
|
|
#include "include/cef_client.h"
|
|
#include "include/views/cef_browser_view.h"
|
|
#include "include/views/cef_browser_view_delegate.h"
|
|
#include "libcef/browser/browser_host_base.h"
|
|
#include "libcef/browser/views/browser_view_view.h"
|
|
#include "libcef/browser/views/view_impl.h"
|
|
|
|
#include "base/callback_forward.h"
|
|
#include "ui/views/controls/webview/unhandled_keyboard_event_handler.h"
|
|
|
|
class CefBrowserHostBase;
|
|
|
|
class CefBrowserViewImpl : public CefViewImpl<CefBrowserViewView,
|
|
CefBrowserView,
|
|
CefBrowserViewDelegate>,
|
|
public CefBrowserViewView::Delegate {
|
|
public:
|
|
typedef CefViewImpl<CefBrowserViewView,
|
|
CefBrowserView,
|
|
CefBrowserViewDelegate>
|
|
ParentClass;
|
|
|
|
// Create a new CefBrowserView instance. |delegate| may be nullptr.
|
|
static CefRefPtr<CefBrowserViewImpl> Create(
|
|
CefRefPtr<CefClient> client,
|
|
const CefString& url,
|
|
const CefBrowserSettings& settings,
|
|
CefRefPtr<CefDictionaryValue> extra_info,
|
|
CefRefPtr<CefRequestContext> request_context,
|
|
CefRefPtr<CefBrowserViewDelegate> delegate);
|
|
|
|
// Create a new CefBrowserView instance for a popup. |delegate| may be
|
|
// nullptr.
|
|
static CefRefPtr<CefBrowserViewImpl> CreateForPopup(
|
|
const CefBrowserSettings& settings,
|
|
CefRefPtr<CefBrowserViewDelegate> delegate);
|
|
|
|
// Called from CefBrowserPlatformDelegateViews.
|
|
void WebContentsCreated(content::WebContents* web_contents);
|
|
void BrowserCreated(CefBrowserHostBase* browser,
|
|
base::RepeatingClosure on_bounds_changed);
|
|
void BrowserDestroyed(CefBrowserHostBase* browser);
|
|
|
|
// Called to handle accelerators when the event is unhandled by the web
|
|
// content and the browser client.
|
|
bool HandleKeyboardEvent(const content::NativeWebKeyboardEvent& event);
|
|
|
|
// CefBrowserView methods:
|
|
CefRefPtr<CefBrowser> GetBrowser() override;
|
|
void SetPreferAccelerators(bool prefer_accelerators) override;
|
|
|
|
// CefView methods:
|
|
CefRefPtr<CefBrowserView> AsBrowserView() override { return this; }
|
|
void SetBackgroundColor(cef_color_t color) override;
|
|
|
|
// CefViewAdapter methods:
|
|
void Detach() override;
|
|
std::string GetDebugType() override { return "BrowserView"; }
|
|
void GetDebugInfo(base::DictionaryValue* info,
|
|
bool include_children) override;
|
|
|
|
// CefBrowserViewView::Delegate methods:
|
|
void OnBrowserViewAdded() override;
|
|
void OnBoundsChanged() override;
|
|
|
|
private:
|
|
// Create a new implementation object.
|
|
// Always call Initialize() after creation.
|
|
// |delegate| may be nullptr.
|
|
explicit CefBrowserViewImpl(CefRefPtr<CefBrowserViewDelegate> delegate);
|
|
|
|
void SetPendingBrowserCreateParams(
|
|
CefRefPtr<CefClient> client,
|
|
const CefString& url,
|
|
const CefBrowserSettings& settings,
|
|
CefRefPtr<CefDictionaryValue> extra_info,
|
|
CefRefPtr<CefRequestContext> request_context);
|
|
|
|
void SetDefaults(const CefBrowserSettings& settings);
|
|
|
|
// CefViewImpl methods:
|
|
CefBrowserViewView* CreateRootView() override;
|
|
void InitializeRootView() override;
|
|
|
|
// Logic extracted from UnhandledKeyboardEventHandler::HandleKeyboardEvent for
|
|
// the handling of accelerators. Returns true if the event was handled by the
|
|
// accelerator.
|
|
bool HandleAccelerator(const content::NativeWebKeyboardEvent& event,
|
|
views::FocusManager* focus_manager);
|
|
|
|
std::unique_ptr<CefBrowserCreateParams> pending_browser_create_params_;
|
|
|
|
CefRefPtr<CefBrowserHostBase> browser_;
|
|
|
|
views::UnhandledKeyboardEventHandler unhandled_keyboard_event_handler_;
|
|
bool ignore_next_char_event_ = false;
|
|
|
|
base::RepeatingClosure on_bounds_changed_;
|
|
|
|
IMPLEMENT_REFCOUNTING_DELETE_ON_UIT(CefBrowserViewImpl);
|
|
DISALLOW_COPY_AND_ASSIGN(CefBrowserViewImpl);
|
|
};
|
|
|
|
#endif // CEF_LIBCEF_BROWSER_VIEWS_BROWSER_VIEW_IMPL_H_
|