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"
|
2013-07-24 22:15:18 +02:00
|
|
|
#include "base/message_loop/message_loop.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"
|
|
|
|
#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
|
|
|
|
2013-02-02 01:21:59 +01:00
|
|
|
class CefContentRendererClient : public content::ContentRendererClient,
|
2017-12-07 22:44:24 +01:00
|
|
|
public service_manager::LocalInterfaceProvider,
|
2013-04-16 00:16:01 +02:00
|
|
|
public base::MessageLoop::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);
|
|
|
|
|
2015-11-17 19:20:13 +01:00
|
|
|
// Returns true if a guest view associated with the specified RenderView.
|
|
|
|
bool HasGuestViewForView(content::RenderView* view);
|
|
|
|
|
|
|
|
// 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
|
|
|
|
2017-12-07 22:44:24 +01:00
|
|
|
// Used by CefRenderURLRequest to create WebURLLoaders.
|
|
|
|
blink::WebURLLoaderFactory* url_loader_factory() const {
|
|
|
|
return url_loader_factory_.get();
|
|
|
|
}
|
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;
|
2017-05-17 11:29:28 +02:00
|
|
|
bool OverrideCreatePlugin(content::RenderFrame* render_frame,
|
|
|
|
const blink::WebPluginParams& params,
|
|
|
|
blink::WebPlugin** plugin) override;
|
2015-10-14 20:23:08 +02:00
|
|
|
bool ShouldFork(blink::WebLocalFrame* frame,
|
|
|
|
const GURL& url,
|
|
|
|
const std::string& http_method,
|
|
|
|
bool is_initial_navigation,
|
|
|
|
bool is_server_redirect,
|
|
|
|
bool* send_referrer) override;
|
2017-07-27 01:19:27 +02:00
|
|
|
bool WillSendRequest(
|
|
|
|
blink::WebLocalFrame* frame,
|
|
|
|
ui::PageTransition transition_type,
|
|
|
|
const blink::WebURL& url,
|
|
|
|
std::vector<std::unique_ptr<content::URLLoaderThrottle>>* throttles,
|
|
|
|
GURL* new_url) override;
|
2016-01-12 01:19:51 +01:00
|
|
|
unsigned long long VisitedLinkHash(const char* canonical_url,
|
|
|
|
size_t length) override;
|
|
|
|
bool IsLinkVisited(unsigned long long link_hash) override;
|
2015-07-16 23:40:01 +02:00
|
|
|
content::BrowserPluginDelegate* CreateBrowserPluginDelegate(
|
|
|
|
content::RenderFrame* render_frame,
|
|
|
|
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;
|
2017-12-07 22:44:24 +01:00
|
|
|
void DevToolsAgentAttached(content::RenderFrame* render_frame,
|
|
|
|
int session_id) override;
|
|
|
|
void DevToolsAgentDetached(content::RenderFrame* render_frame,
|
|
|
|
int session_id) override;
|
|
|
|
|
|
|
|
// service_manager::LocalInterfaceProvider implementation.
|
|
|
|
void GetInterface(const std::string& name,
|
|
|
|
mojo::ScopedMessagePipeHandle request_handle) override;
|
2012-04-03 03:34:16 +02:00
|
|
|
|
2013-02-02 01:21:59 +01:00
|
|
|
// MessageLoop::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:
|
2014-01-02 23:41:11 +01:00
|
|
|
void BrowserCreated(content::RenderView* render_view,
|
|
|
|
content::RenderFrame* render_frame);
|
|
|
|
|
2013-02-02 01:21:59 +01:00
|
|
|
// Perform cleanup work for single-process mode.
|
|
|
|
void RunSingleProcessCleanupOnUIThread();
|
|
|
|
|
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_;
|
2017-12-07 22:44:24 +01:00
|
|
|
std::unique_ptr<blink::WebURLLoaderFactory> 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
|
|
|
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(CefContentRendererClient);
|
2012-04-03 03:34:16 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // CEF_LIBCEF_RENDERER_CONTENT_RENDERER_CLIENT_H_
|