2013-01-03 18:24:24 +01:00
|
|
|
// Copyright (c) 2013 The Chromium Embedded Framework Authors.
|
|
|
|
// Portions copyright (c) 2011 The Chromium Authors. All rights reserved.
|
2012-04-03 03:34:16 +02:00
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
|
|
|
#ifndef CEF_LIBCEF_RENDERER_CONTENT_RENDERER_CLIENT_H_
|
|
|
|
#define CEF_LIBCEF_RENDERER_CONTENT_RENDERER_CLIENT_H_
|
|
|
|
#pragma once
|
|
|
|
|
2012-04-24 20:01:48 +02:00
|
|
|
#include <list>
|
2012-04-03 03:34:16 +02:00
|
|
|
#include <map>
|
2016-10-21 21:52:29 +02:00
|
|
|
#include <memory>
|
2012-04-03 03:34:16 +02:00
|
|
|
#include <string>
|
2012-12-31 11:41:15 +01:00
|
|
|
#include <vector>
|
2012-04-03 03:34:16 +02:00
|
|
|
|
|
|
|
#include "libcef/renderer/browser_impl.h"
|
|
|
|
|
|
|
|
#include "base/compiler_specific.h"
|
2019-10-01 15:55:16 +02:00
|
|
|
#include "base/message_loop/message_loop_current.h"
|
2019-10-15 13:52:26 +02:00
|
|
|
#include "base/optional.h"
|
2013-01-03 18:24:24 +01:00
|
|
|
#include "base/sequenced_task_runner.h"
|
2017-12-07 22:44:24 +01:00
|
|
|
#include "chrome/common/plugin.mojom.h"
|
2012-04-03 03:34:16 +02:00
|
|
|
#include "content/public/renderer/content_renderer_client.h"
|
2017-12-07 22:44:24 +01:00
|
|
|
#include "content/public/renderer/render_thread.h"
|
2019-10-01 15:55:16 +02:00
|
|
|
#include "mojo/public/cpp/bindings/generic_pending_receiver.h"
|
2018-03-20 21:15:08 +01:00
|
|
|
#include "services/service_manager/public/cpp/binder_registry.h"
|
2017-12-07 22:44:24 +01:00
|
|
|
#include "services/service_manager/public/cpp/local_interface_provider.h"
|
|
|
|
|
|
|
|
namespace blink {
|
|
|
|
class WebURLLoaderFactory;
|
|
|
|
}
|
2012-04-03 03:34:16 +02:00
|
|
|
|
2015-07-16 23:40:01 +02:00
|
|
|
namespace extensions {
|
2015-11-10 21:18:16 +01:00
|
|
|
class CefExtensionsRendererClient;
|
2015-07-16 23:40:01 +02:00
|
|
|
class Dispatcher;
|
|
|
|
class DispatcherDelegate;
|
|
|
|
class ExtensionsClient;
|
|
|
|
class ExtensionsGuestViewContainerDispatcher;
|
|
|
|
class ExtensionsRendererClient;
|
2015-10-12 20:13:13 +02:00
|
|
|
class ResourceRequestPolicy;
|
2017-07-27 01:19:27 +02:00
|
|
|
} // namespace extensions
|
2015-07-16 23:40:01 +02:00
|
|
|
|
2014-09-27 01:48:19 +02:00
|
|
|
namespace web_cache {
|
2016-05-25 01:35:43 +02:00
|
|
|
class WebCacheImpl;
|
2014-09-27 01:48:19 +02:00
|
|
|
}
|
|
|
|
|
2015-11-17 19:20:13 +01:00
|
|
|
class CefGuestView;
|
2016-05-25 01:35:43 +02:00
|
|
|
class CefRenderThreadObserver;
|
2012-12-31 11:41:15 +01:00
|
|
|
struct Cef_CrossOriginWhiteListEntry_Params;
|
2015-07-16 23:40:01 +02:00
|
|
|
class ChromePDFPrintClient;
|
2014-10-07 22:44:33 +02:00
|
|
|
class SpellCheck;
|
2012-04-03 03:34:16 +02:00
|
|
|
|
2018-11-30 23:21:07 +01:00
|
|
|
class CefContentRendererClient
|
|
|
|
: public content::ContentRendererClient,
|
|
|
|
public service_manager::LocalInterfaceProvider,
|
|
|
|
public base::MessageLoopCurrent::DestructionObserver {
|
2012-04-03 03:34:16 +02:00
|
|
|
public:
|
|
|
|
CefContentRendererClient();
|
2014-11-12 20:25:15 +01:00
|
|
|
~CefContentRendererClient() override;
|
2012-04-03 03:34:16 +02:00
|
|
|
|
|
|
|
// Returns the singleton CefContentRendererClient instance.
|
|
|
|
static CefContentRendererClient* Get();
|
|
|
|
|
|
|
|
// Returns the browser associated with the specified RenderView.
|
|
|
|
CefRefPtr<CefBrowserImpl> GetBrowserForView(content::RenderView* view);
|
|
|
|
|
|
|
|
// Returns the browser associated with the specified main WebFrame.
|
2013-11-08 22:28:56 +01:00
|
|
|
CefRefPtr<CefBrowserImpl> GetBrowserForMainFrame(blink::WebFrame* frame);
|
2012-04-03 03:34:16 +02:00
|
|
|
|
|
|
|
// Called from CefBrowserImpl::OnDestruct().
|
|
|
|
void OnBrowserDestroyed(CefBrowserImpl* browser);
|
|
|
|
|
2019-10-15 13:52:26 +02:00
|
|
|
// Returns the guest view associated with the specified RenderView if any.
|
|
|
|
CefGuestView* GetGuestViewForView(content::RenderView* view);
|
2015-11-17 19:20:13 +01:00
|
|
|
|
|
|
|
// Called from CefGuestView::OnDestruct().
|
|
|
|
void OnGuestViewDestroyed(CefGuestView* guest_view);
|
|
|
|
|
2013-01-03 18:24:24 +01:00
|
|
|
// Render thread task runner.
|
2017-09-21 13:57:40 +02:00
|
|
|
base::SingleThreadTaskRunner* render_task_runner() const {
|
2013-01-03 18:24:24 +01:00
|
|
|
return render_task_runner_.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
int uncaught_exception_stack_size() const {
|
|
|
|
return uncaught_exception_stack_size_;
|
|
|
|
}
|
2012-04-03 03:34:16 +02:00
|
|
|
|
2019-05-11 00:14:48 +02:00
|
|
|
// Returns a factory that only supports unintercepted http(s) and blob
|
|
|
|
// requests. Used by CefRenderURLRequest.
|
|
|
|
blink::WebURLLoaderFactory* GetDefaultURLLoaderFactory();
|
2012-12-31 11:41:15 +01:00
|
|
|
|
2017-12-07 22:44:24 +01:00
|
|
|
void WebKitInitialized();
|
2013-01-03 18:24:24 +01:00
|
|
|
|
2015-10-09 17:23:12 +02:00
|
|
|
// 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();
|
2013-01-03 18:24:24 +01:00
|
|
|
|
2013-02-02 01:21:59 +01:00
|
|
|
// Perform cleanup work that needs to occur before shutdown when running in
|
|
|
|
// single-process mode. Blocks until cleanup is complete.
|
|
|
|
void RunSingleProcessCleanup();
|
|
|
|
|
2012-04-03 03:34:16 +02:00
|
|
|
// ContentRendererClient implementation.
|
2014-11-12 20:25:15 +01:00
|
|
|
void RenderThreadStarted() override;
|
2017-05-31 17:33:30 +02:00
|
|
|
void RenderThreadConnected() override;
|
2014-11-12 20:25:15 +01:00
|
|
|
void RenderFrameCreated(content::RenderFrame* render_frame) override;
|
|
|
|
void RenderViewCreated(content::RenderView* render_view) override;
|
2019-07-24 23:12:00 +02:00
|
|
|
bool IsPluginHandledExternally(content::RenderFrame* render_frame,
|
|
|
|
const blink::WebElement& plugin_element,
|
|
|
|
const GURL& original_url,
|
|
|
|
const std::string& mime_type) override;
|
2017-05-17 11:29:28 +02:00
|
|
|
bool OverrideCreatePlugin(content::RenderFrame* render_frame,
|
|
|
|
const blink::WebPluginParams& params,
|
|
|
|
blink::WebPlugin** plugin) override;
|
2018-04-19 17:44:42 +02:00
|
|
|
void WillSendRequest(blink::WebLocalFrame* frame,
|
2018-02-15 01:12:09 +01:00
|
|
|
ui::PageTransition transition_type,
|
|
|
|
const blink::WebURL& url,
|
2018-04-19 17:44:42 +02:00
|
|
|
const url::Origin* initiator_origin,
|
|
|
|
GURL* new_url,
|
|
|
|
bool* attach_same_site_cookies) override;
|
2019-04-16 16:38:48 +02:00
|
|
|
uint64_t VisitedLinkHash(const char* canonical_url, size_t length) override;
|
|
|
|
bool IsLinkVisited(uint64_t link_hash) override;
|
2018-04-19 17:44:42 +02:00
|
|
|
bool IsOriginIsolatedPepperPlugin(const base::FilePath& plugin_path) override;
|
2015-07-16 23:40:01 +02:00
|
|
|
content::BrowserPluginDelegate* CreateBrowserPluginDelegate(
|
|
|
|
content::RenderFrame* render_frame,
|
2018-04-19 17:44:42 +02:00
|
|
|
const content::WebPluginInfo& info,
|
2015-07-16 23:40:01 +02:00
|
|
|
const std::string& mime_type,
|
|
|
|
const GURL& original_url) override;
|
2016-05-25 01:35:43 +02:00
|
|
|
void AddSupportedKeySystems(
|
|
|
|
std::vector<std::unique_ptr<::media::KeySystemProperties>>* key_systems)
|
|
|
|
override;
|
2016-04-27 22:38:52 +02:00
|
|
|
void RunScriptsAtDocumentStart(content::RenderFrame* render_frame) override;
|
|
|
|
void RunScriptsAtDocumentEnd(content::RenderFrame* render_frame) override;
|
2017-04-20 21:28:17 +02:00
|
|
|
void RunScriptsAtDocumentIdle(content::RenderFrame* render_frame) override;
|
2018-02-15 01:12:09 +01:00
|
|
|
void DevToolsAgentAttached() override;
|
|
|
|
void DevToolsAgentDetached() override;
|
2019-07-24 23:12:00 +02:00
|
|
|
std::unique_ptr<content::URLLoaderThrottleProvider>
|
|
|
|
CreateURLLoaderThrottleProvider(
|
|
|
|
content::URLLoaderThrottleProviderType provider_type) override;
|
2019-10-01 15:55:16 +02:00
|
|
|
void BindReceiverOnMainThread(mojo::GenericPendingReceiver receiver) override;
|
2017-12-07 22:44:24 +01:00
|
|
|
|
|
|
|
// service_manager::LocalInterfaceProvider implementation.
|
|
|
|
void GetInterface(const std::string& name,
|
|
|
|
mojo::ScopedMessagePipeHandle request_handle) override;
|
2012-04-03 03:34:16 +02:00
|
|
|
|
2018-11-30 23:21:07 +01:00
|
|
|
// MessageLoopCurrent::DestructionObserver implementation.
|
2014-11-12 20:25:15 +01:00
|
|
|
void WillDestroyCurrentMessageLoop() override;
|
2013-02-02 01:21:59 +01:00
|
|
|
|
2014-04-04 18:50:38 +02:00
|
|
|
private:
|
2019-05-24 22:23:43 +02:00
|
|
|
// Maybe create a new browser object, return the existing one, or return
|
|
|
|
// nullptr for guest views.
|
|
|
|
CefRefPtr<CefBrowserImpl> MaybeCreateBrowser(
|
|
|
|
content::RenderView* render_view,
|
2019-10-15 13:52:26 +02:00
|
|
|
content::RenderFrame* render_frame,
|
|
|
|
base::Optional<bool>* is_windowless);
|
2014-01-02 23:41:11 +01:00
|
|
|
|
2013-02-02 01:21:59 +01:00
|
|
|
// Perform cleanup work for single-process mode.
|
|
|
|
void RunSingleProcessCleanupOnUIThread();
|
|
|
|
|
2018-03-20 21:15:08 +01:00
|
|
|
// 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_;
|
|
|
|
|
2017-09-21 13:57:40 +02:00
|
|
|
scoped_refptr<base::SingleThreadTaskRunner> render_task_runner_;
|
2016-05-25 01:35:43 +02:00
|
|
|
std::unique_ptr<CefRenderThreadObserver> observer_;
|
|
|
|
std::unique_ptr<web_cache::WebCacheImpl> web_cache_impl_;
|
2016-04-27 22:38:52 +02:00
|
|
|
std::unique_ptr<SpellCheck> spellcheck_;
|
2019-05-11 00:14:48 +02:00
|
|
|
|
|
|
|
std::unique_ptr<blink::WebURLLoaderFactory> default_url_loader_factory_;
|
2012-04-03 03:34:16 +02:00
|
|
|
|
|
|
|
// Map of RenderView pointers to CefBrowserImpl references.
|
2017-05-17 11:29:28 +02:00
|
|
|
typedef std::map<content::RenderView*, CefRefPtr<CefBrowserImpl>> BrowserMap;
|
2012-04-03 03:34:16 +02:00
|
|
|
BrowserMap browsers_;
|
2012-04-24 20:01:48 +02:00
|
|
|
|
2015-11-17 19:20:13 +01:00
|
|
|
// Map of RenderView poiners to CefGuestView implementations.
|
2017-05-17 11:29:28 +02:00
|
|
|
typedef std::map<content::RenderView*, std::unique_ptr<CefGuestView>>
|
2016-10-21 21:52:29 +02:00
|
|
|
GuestViewMap;
|
2015-11-17 19:20:13 +01:00
|
|
|
GuestViewMap guest_views_;
|
|
|
|
|
2012-12-31 11:41:15 +01:00
|
|
|
// Cross-origin white list entries that need to be registered with WebKit.
|
|
|
|
typedef std::vector<Cef_CrossOriginWhiteListEntry_Params> CrossOriginList;
|
|
|
|
CrossOriginList cross_origin_whitelist_entries_;
|
|
|
|
|
2016-04-27 22:38:52 +02:00
|
|
|
std::unique_ptr<ChromePDFPrintClient> pdf_print_client_;
|
2015-07-16 23:40:01 +02:00
|
|
|
|
2016-04-27 22:38:52 +02:00
|
|
|
std::unique_ptr<extensions::ExtensionsClient> extensions_client_;
|
|
|
|
std::unique_ptr<extensions::CefExtensionsRendererClient>
|
2015-11-10 21:18:16 +01:00
|
|
|
extensions_renderer_client_;
|
2015-07-16 23:40:01 +02:00
|
|
|
|
2012-11-02 19:16:28 +01:00
|
|
|
int devtools_agent_count_;
|
|
|
|
int uncaught_exception_stack_size_;
|
2013-01-03 18:24:24 +01:00
|
|
|
|
2013-02-02 01:21:59 +01:00
|
|
|
// Used in single-process mode to test when cleanup is complete.
|
|
|
|
// Access must be protected by |single_process_cleanup_lock_|.
|
|
|
|
bool single_process_cleanup_complete_;
|
|
|
|
base::Lock single_process_cleanup_lock_;
|
2016-11-23 21:54:29 +01:00
|
|
|
|
2018-03-20 21:15:08 +01:00
|
|
|
service_manager::BinderRegistry registry_;
|
|
|
|
|
2016-11-23 21:54:29 +01:00
|
|
|
DISALLOW_COPY_AND_ASSIGN(CefContentRendererClient);
|
2012-04-03 03:34:16 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // CEF_LIBCEF_RENDERER_CONTENT_RENDERER_CLIENT_H_
|