mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2024-12-13 10:06:28 +01:00
4fbd247231
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.*
151 lines
6.1 KiB
C++
151 lines
6.1 KiB
C++
// Copyright (c) 2011 The Chromium 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_ALLOY_ALLOY_BROWSER_CONTEXT_H_
|
|
#define CEF_LIBCEF_BROWSER_ALLOY_ALLOY_BROWSER_CONTEXT_H_
|
|
#pragma once
|
|
|
|
#include "include/cef_request_context_handler.h"
|
|
#include "libcef/browser/alloy/chrome_profile_alloy.h"
|
|
#include "libcef/browser/browser_context.h"
|
|
#include "libcef/browser/request_context_handler_map.h"
|
|
|
|
#include "chrome/browser/download/download_prefs.h"
|
|
#include "components/proxy_config/pref_proxy_config_tracker.h"
|
|
#include "components/visitedlink/browser/visitedlink_delegate.h"
|
|
|
|
class CefDownloadManagerDelegate;
|
|
class CefSSLHostStateDelegate;
|
|
class CefVisitedLinkListener;
|
|
class MediaDeviceIDSalt;
|
|
class PrefService;
|
|
|
|
namespace extensions {
|
|
class CefExtensionSystem;
|
|
}
|
|
|
|
namespace visitedlink {
|
|
class VisitedLinkWriter;
|
|
}
|
|
|
|
// See CefBrowserContext documentation for usage. Only accessed on the UI thread
|
|
// unless otherwise indicated. ChromeProfileAlloy must be the first listed base
|
|
// class to avoid issues when casting between void* and content::BrowserContext*
|
|
// in Chromium code.
|
|
class AlloyBrowserContext : public ChromeProfileAlloy,
|
|
public CefBrowserContext,
|
|
public visitedlink::VisitedLinkDelegate {
|
|
public:
|
|
explicit AlloyBrowserContext(const CefRequestContextSettings& settings);
|
|
|
|
// CefBrowserContext overrides.
|
|
content::BrowserContext* AsBrowserContext() override { return this; }
|
|
Profile* AsProfile() override { return this; }
|
|
void Initialize() override;
|
|
void Shutdown() override;
|
|
void RemoveCefRequestContext(CefRequestContextImpl* context) override;
|
|
void LoadExtension(const CefString& root_directory,
|
|
CefRefPtr<CefDictionaryValue> manifest,
|
|
CefRefPtr<CefExtensionHandler> handler,
|
|
CefRefPtr<CefRequestContext> loader_context) override;
|
|
bool GetExtensions(std::vector<CefString>& extension_ids) override;
|
|
CefRefPtr<CefExtension> GetExtension(const CefString& extension_id) override;
|
|
bool UnloadExtension(const CefString& extension_id) override;
|
|
bool IsPrintPreviewSupported() const override;
|
|
|
|
// content::BrowserContext overrides.
|
|
content::ResourceContext* GetResourceContext() override;
|
|
content::ClientHintsControllerDelegate* GetClientHintsControllerDelegate()
|
|
override;
|
|
void SetCorsOriginAccessListForOrigin(
|
|
const url::Origin& source_origin,
|
|
std::vector<network::mojom::CorsOriginPatternPtr> allow_patterns,
|
|
std::vector<network::mojom::CorsOriginPatternPtr> block_patterns,
|
|
base::OnceClosure closure) override;
|
|
base::FilePath GetPath() override;
|
|
base::FilePath GetPath() const override;
|
|
std::unique_ptr<content::ZoomLevelDelegate> CreateZoomLevelDelegate(
|
|
const base::FilePath& partition_path) override;
|
|
bool IsOffTheRecord() const override;
|
|
content::DownloadManagerDelegate* GetDownloadManagerDelegate() override;
|
|
content::BrowserPluginGuestManager* GetGuestManager() override;
|
|
storage::SpecialStoragePolicy* GetSpecialStoragePolicy() override;
|
|
content::PushMessagingService* GetPushMessagingService() override;
|
|
content::StorageNotificationService* GetStorageNotificationService() override;
|
|
content::SSLHostStateDelegate* GetSSLHostStateDelegate() override;
|
|
content::PermissionControllerDelegate* GetPermissionControllerDelegate()
|
|
override;
|
|
content::BackgroundFetchDelegate* GetBackgroundFetchDelegate() override;
|
|
content::BackgroundSyncController* GetBackgroundSyncController() override;
|
|
content::BrowsingDataRemoverDelegate* GetBrowsingDataRemoverDelegate()
|
|
override;
|
|
std::string GetMediaDeviceIDSalt() override;
|
|
|
|
// Profile overrides.
|
|
ChromeZoomLevelPrefs* GetZoomLevelPrefs() override;
|
|
scoped_refptr<network::SharedURLLoaderFactory> GetURLLoaderFactory() override;
|
|
PrefService* GetPrefs() override;
|
|
bool AllowsBrowserWindows() const override { return false; }
|
|
const PrefService* GetPrefs() const override;
|
|
ProfileKey* GetProfileKey() const override;
|
|
policy::SchemaRegistryService* GetPolicySchemaRegistryService() override;
|
|
policy::UserCloudPolicyManager* GetUserCloudPolicyManager() override;
|
|
policy::ProfilePolicyConnector* GetProfilePolicyConnector() override;
|
|
const policy::ProfilePolicyConnector* GetProfilePolicyConnector()
|
|
const override;
|
|
|
|
// Values checked in ProfileNetworkContextService::CreateNetworkContextParams
|
|
// when creating the NetworkContext.
|
|
bool ShouldRestoreOldSessionCookies() const override {
|
|
return ShouldPersistSessionCookies();
|
|
}
|
|
bool ShouldPersistSessionCookies() const override {
|
|
return !!settings_.persist_session_cookies;
|
|
}
|
|
|
|
// visitedlink::VisitedLinkDelegate methods.
|
|
void RebuildTable(const scoped_refptr<URLEnumerator>& enumerator) override;
|
|
|
|
// Manages extensions.
|
|
extensions::CefExtensionSystem* extension_system() const {
|
|
return extension_system_;
|
|
}
|
|
|
|
// Called from AlloyBrowserHostImpl::DidFinishNavigation to update the table
|
|
// of visited links.
|
|
void AddVisitedURLs(const std::vector<GURL>& urls);
|
|
|
|
// Called from DownloadPrefs::FromBrowserContext.
|
|
DownloadPrefs* GetDownloadPrefs();
|
|
|
|
private:
|
|
~AlloyBrowserContext() override;
|
|
|
|
std::unique_ptr<PrefService> pref_service_;
|
|
std::unique_ptr<PrefProxyConfigTracker> pref_proxy_config_tracker_;
|
|
|
|
std::unique_ptr<CefDownloadManagerDelegate> download_manager_delegate_;
|
|
std::unique_ptr<CefSSLHostStateDelegate> ssl_host_state_delegate_;
|
|
std::unique_ptr<visitedlink::VisitedLinkWriter> visitedlink_master_;
|
|
// |visitedlink_listener_| is owned by visitedlink_master_.
|
|
CefVisitedLinkListener* visitedlink_listener_ = nullptr;
|
|
|
|
// Owned by the KeyedService system.
|
|
extensions::CefExtensionSystem* extension_system_ = nullptr;
|
|
|
|
// The key to index KeyedService instances created by
|
|
// SimpleKeyedServiceFactory.
|
|
std::unique_ptr<ProfileKey> key_;
|
|
|
|
std::unique_ptr<DownloadPrefs> download_prefs_;
|
|
|
|
std::unique_ptr<content::ResourceContext> resource_context_;
|
|
|
|
scoped_refptr<MediaDeviceIDSalt> media_device_id_salt_;
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(AlloyBrowserContext);
|
|
};
|
|
|
|
#endif // CEF_LIBCEF_BROWSER_ALLOY_ALLOY_BROWSER_CONTEXT_H_
|