cef/libcef/renderer/alloy/alloy_content_renderer_clie...

158 lines
6.1 KiB
C
Raw Normal View History

// Copyright (c) 2013 The Chromium Embedded Framework Authors.
// Portions 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_RENDERER_ALLOY_ALLOY_CONTENT_RENDERER_CLIENT_H_
#define CEF_LIBCEF_RENDERER_ALLOY_ALLOY_CONTENT_RENDERER_CLIENT_H_
#pragma once
#include <list>
#include <map>
#include <memory>
#include <string>
#include <vector>
#include "libcef/renderer/browser_impl.h"
#include "base/compiler_specific.h"
Add chrome runtime support for more callbacks and ceftests (see issue #2969) 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.*
2020-09-25 03:40:47 +02:00
#include "base/single_thread_task_runner.h"
#include "base/task/current_thread.h"
#include "chrome/common/plugin.mojom.h"
#include "chrome/renderer/media/chrome_key_systems_provider.h"
#include "content/public/renderer/content_renderer_client.h"
#include "content/public/renderer/render_thread.h"
#include "mojo/public/cpp/bindings/generic_pending_receiver.h"
#include "services/service_manager/public/cpp/local_interface_provider.h"
namespace extensions {
class CefExtensionsRendererClient;
class Dispatcher;
class DispatcherDelegate;
class ExtensionsClient;
class ExtensionsGuestViewContainerDispatcher;
class ExtensionsRendererClient;
class ResourceRequestPolicy;
} // namespace extensions
namespace visitedlink {
class VisitedLinkReader;
}
namespace web_cache {
class WebCacheImpl;
}
class AlloyRenderThreadObserver;
class CefRenderManager;
class ChromePDFPrintClient;
Add spell checking support (issue #137). This includes: - Red underline of misspelled words in html text areas. - Right-click context menu options to correct the misspelled word. - New CefBrowser::ReplaceMisspelling method for accepting a word replacement. - Methods added to CefContextMenuParams for retrieving spelling-related information. - Uses the unified text checker when auto-correct is not enabled to match Google Chrome behavior. - On Windows and Linux a hunspell dictionary file will be downloaded to the "<cache_path>/Dictionaries" directory as needed, or used from the <cache_path> directory if the file already exists there. The dictionary file will be downloaded from http://cache.pack.google.com/edgedl/chrome/dict/<LANG>-3-0.bdic where <LANG> is the language abbreviation. - On OS X the spell checking implementation will use the system NSSpellChecker implementation. The following command-line flags have been added: --disable-spell-checking => Disable spell-checking support (no red underline, no dictionary file download, etc). --enable-spelling-auto-correct => Automatically correct common misspellings while typing (like 'omre' to 'more' on Windows/Linux or 'ehlo' to 'helo' on OS X). --enable-spelling-service => Enable use of the remote Google spelling service (this requires Google API keys). --override-spell-check-lang=<LANG> => Use the specified dictionary language <LANG> instead of the language specified in the locales.pak file. To see the default/supported dictionary languages: https://code.google.com/p/chromium/codesearch#search/&q=IDS_SPELLCHECK_DICTIONARY%20xtb&sq=package:chromium git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@1859 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
2014-10-07 22:44:33 +02:00
class SpellCheck;
class AlloyContentRendererClient
: public content::ContentRendererClient,
public service_manager::LocalInterfaceProvider,
public base::CurrentThread::DestructionObserver {
public:
AlloyContentRendererClient();
~AlloyContentRendererClient() override;
// Returns the singleton AlloyContentRendererClient instance.
// This method is deprecated and should not be used in new callsites.
static AlloyContentRendererClient* Get();
// Render thread task runner.
2017-09-21 13:57:40 +02:00
base::SingleThreadTaskRunner* render_task_runner() const {
return render_task_runner_.get();
}
// Returns the task runner for the current thread. Returns NULL if the current
// thread is not the main render process thread.
2017-09-21 13:57:40 +02:00
scoped_refptr<base::SingleThreadTaskRunner> GetCurrentTaskRunner();
// Perform cleanup work that needs to occur before shutdown when running in
// single-process mode. Blocks until cleanup is complete.
void RunSingleProcessCleanup();
// ContentRendererClient implementation.
void PostIOThreadCreated(
base::SingleThreadTaskRunner* io_thread_task_runner) override;
void RenderThreadStarted() override;
void ExposeInterfacesToBrowser(mojo::BinderMap* binders) override;
void RenderThreadConnected() override;
void RenderFrameCreated(content::RenderFrame* render_frame) override;
void WebViewCreated(blink::WebView* web_view) override;
bool IsPluginHandledExternally(content::RenderFrame* render_frame,
const blink::WebElement& plugin_element,
const GURL& original_url,
const std::string& mime_type) override;
bool OverrideCreatePlugin(content::RenderFrame* render_frame,
const blink::WebPluginParams& params,
blink::WebPlugin** plugin) override;
void WillSendRequest(blink::WebLocalFrame* frame,
ui::PageTransition transition_type,
const blink::WebURL& url,
const net::SiteForCookies& site_for_cookies,
const url::Origin* initiator_origin,
GURL* new_url) override;
uint64_t VisitedLinkHash(const char* canonical_url, size_t length) override;
bool IsLinkVisited(uint64_t link_hash) override;
bool IsOriginIsolatedPepperPlugin(const base::FilePath& plugin_path) override;
void AddSupportedKeySystems(
std::vector<std::unique_ptr<::media::KeySystemProperties>>* key_systems)
override;
bool IsKeySystemsUpdateNeeded() override;
void RunScriptsAtDocumentStart(content::RenderFrame* render_frame) override;
void RunScriptsAtDocumentEnd(content::RenderFrame* render_frame) override;
void RunScriptsAtDocumentIdle(content::RenderFrame* render_frame) override;
void DevToolsAgentAttached() override;
void DevToolsAgentDetached() override;
std::unique_ptr<blink::URLLoaderThrottleProvider>
CreateURLLoaderThrottleProvider(
blink::URLLoaderThrottleProviderType provider_type) override;
// service_manager::LocalInterfaceProvider implementation.
void GetInterface(const std::string& name,
mojo::ScopedMessagePipeHandle request_handle) override;
// MessageLoopCurrent::DestructionObserver implementation.
void WillDestroyCurrentMessageLoop() override;
private:
Add chrome runtime support for more callbacks and ceftests (see issue #2969) 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.*
2020-09-25 03:40:47 +02:00
void OnBrowserCreated(content::RenderView* render_view,
absl::optional<bool> is_windowless);
// Perform cleanup work for single-process mode.
void RunSingleProcessCleanupOnUIThread();
// Time at which this object was created. This is very close to the time at
// which the RendererMain function was entered.
base::TimeTicks main_entry_time_;
std::unique_ptr<CefRenderManager> render_manager_;
Add chrome runtime support for more callbacks and ceftests (see issue #2969) 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.*
2020-09-25 03:40:47 +02:00
2017-09-21 13:57:40 +02:00
scoped_refptr<base::SingleThreadTaskRunner> render_task_runner_;
std::unique_ptr<AlloyRenderThreadObserver> observer_;
std::unique_ptr<web_cache::WebCacheImpl> web_cache_impl_;
std::unique_ptr<SpellCheck> spellcheck_;
std::unique_ptr<visitedlink::VisitedLinkReader> visited_link_slave_;
std::unique_ptr<ChromePDFPrintClient> pdf_print_client_;
std::unique_ptr<extensions::ExtensionsClient> extensions_client_;
std::unique_ptr<extensions::CefExtensionsRendererClient>
extensions_renderer_client_;
// Used to refresh the list of supported key systems after Widevine is
// installed as a component update.
ChromeKeySystemsProvider key_systems_provider_;
// Used in single-process mode to test when cleanup is complete.
// Access must be protected by |single_process_cleanup_lock_|.
Add chrome runtime support for more callbacks and ceftests (see issue #2969) 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.*
2020-09-25 03:40:47 +02:00
bool single_process_cleanup_complete_ = false;
base::Lock single_process_cleanup_lock_;
DISALLOW_COPY_AND_ASSIGN(AlloyContentRendererClient);
};
#endif // CEF_LIBCEF_RENDERER_ALLOY_ALLOY_CONTENT_RENDERER_CLIENT_H_