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"
|
2012-04-03 03:34:16 +02:00
|
|
|
#include "content/public/renderer/content_renderer_client.h"
|
|
|
|
|
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;
|
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
|
|
|
struct CefViewHostMsg_GetPluginInfo_Output;
|
|
|
|
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,
|
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.
|
|
|
|
base::SequencedTaskRunner* render_task_runner() const {
|
|
|
|
return render_task_runner_.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
int uncaught_exception_stack_size() const {
|
|
|
|
return uncaught_exception_stack_size_;
|
|
|
|
}
|
2012-04-03 03:34:16 +02:00
|
|
|
|
2012-12-31 11:41:15 +01:00
|
|
|
void WebKitInitialized();
|
2013-01-03 18:24:24 +01:00
|
|
|
void OnRenderProcessShutdown();
|
2012-12-31 11:41:15 +01:00
|
|
|
|
2012-11-02 19:16:28 +01:00
|
|
|
void DevToolsAgentAttached();
|
|
|
|
void DevToolsAgentDetached();
|
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.
|
2013-01-03 18:24:24 +01:00
|
|
|
scoped_refptr<base::SequencedTaskRunner> GetCurrentTaskRunner();
|
|
|
|
|
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;
|
|
|
|
void RenderFrameCreated(content::RenderFrame* render_frame) override;
|
|
|
|
void RenderViewCreated(content::RenderView* render_view) override;
|
|
|
|
bool OverrideCreatePlugin(
|
2014-07-01 00:30:29 +02:00
|
|
|
content::RenderFrame* render_frame,
|
|
|
|
blink::WebLocalFrame* frame,
|
|
|
|
const blink::WebPluginParams& params,
|
2014-11-12 20:25:15 +01:00
|
|
|
blink::WebPlugin** plugin) override;
|
|
|
|
bool HandleNavigation(content::RenderFrame* render_frame,
|
2015-11-10 21:18:16 +01:00
|
|
|
bool is_content_initiated,
|
2017-01-23 18:36:54 +01:00
|
|
|
bool render_view_was_created_by_renderer,
|
2014-11-12 20:25:15 +01:00
|
|
|
blink::WebFrame* frame,
|
|
|
|
const blink::WebURLRequest& request,
|
|
|
|
blink::WebNavigationType type,
|
|
|
|
blink::WebNavigationPolicy default_policy,
|
|
|
|
bool is_redirect) 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-01-23 18:36:54 +01:00
|
|
|
bool WillSendRequest(blink::WebLocalFrame* frame,
|
2015-10-12 20:13:13 +02:00
|
|
|
ui::PageTransition transition_type,
|
2016-11-23 21:54:29 +01:00
|
|
|
const blink::WebURL& url,
|
2015-10-12 20:13:13 +02:00
|
|
|
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;
|
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
|
|
|
|
2015-09-09 16:05:39 +02:00
|
|
|
static blink::WebPlugin* CreatePlugin(
|
|
|
|
content::RenderFrame* render_frame,
|
|
|
|
blink::WebLocalFrame* frame,
|
|
|
|
const blink::WebPluginParams& params,
|
|
|
|
const CefViewHostMsg_GetPluginInfo_Output& output);
|
|
|
|
|
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();
|
|
|
|
|
2013-01-03 18:24:24 +01:00
|
|
|
scoped_refptr<base::SequencedTaskRunner> 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_;
|
2012-04-03 03:34:16 +02:00
|
|
|
|
|
|
|
// Map of RenderView pointers to CefBrowserImpl references.
|
|
|
|
typedef std::map<content::RenderView*, CefRefPtr<CefBrowserImpl> > BrowserMap;
|
|
|
|
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.
|
2016-10-21 21:52:29 +02:00
|
|
|
typedef std::map<content::RenderView*, std::unique_ptr<CefGuestView> >
|
|
|
|
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_
|