2012-04-03 03:34:16 +02:00
|
|
|
// 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_CONTENT_BROWSER_CLIENT_H_
|
|
|
|
#define CEF_LIBCEF_BROWSER_CONTENT_BROWSER_CLIENT_H_
|
|
|
|
#pragma once
|
|
|
|
|
2012-12-30 12:17:49 +01:00
|
|
|
#include <list>
|
2012-11-20 21:08:36 +01:00
|
|
|
#include <map>
|
2013-06-04 19:41:37 +02:00
|
|
|
#include <set>
|
2012-04-03 03:34:16 +02:00
|
|
|
#include <string>
|
|
|
|
#include <utility>
|
|
|
|
|
2013-09-03 18:43:31 +02:00
|
|
|
#include "include/cef_request_context_handler.h"
|
|
|
|
|
2012-04-03 03:34:16 +02:00
|
|
|
#include "base/compiler_specific.h"
|
2012-12-30 12:17:49 +01:00
|
|
|
#include "base/memory/ref_counted.h"
|
2012-04-03 03:34:16 +02:00
|
|
|
#include "base/memory/scoped_ptr.h"
|
2012-11-20 21:08:36 +01:00
|
|
|
#include "base/synchronization/lock.h"
|
2012-04-03 03:34:16 +02:00
|
|
|
#include "content/public/browser/content_browser_client.h"
|
2013-09-03 18:43:31 +02:00
|
|
|
#include "net/proxy/proxy_config_service.h"
|
|
|
|
#include "net/url_request/url_request_context_getter.h"
|
2013-07-24 22:15:18 +02:00
|
|
|
#include "url/gurl.h"
|
2012-04-03 03:34:16 +02:00
|
|
|
|
2013-02-23 01:43:28 +01:00
|
|
|
class CefBrowserContext;
|
2012-12-30 12:17:49 +01:00
|
|
|
class CefBrowserInfo;
|
2012-04-03 03:34:16 +02:00
|
|
|
class CefBrowserMainParts;
|
2013-09-03 18:43:31 +02:00
|
|
|
class CefDevToolsDelegate;
|
2012-06-25 23:21:27 +02:00
|
|
|
class CefResourceDispatcherHostDelegate;
|
2013-09-03 18:43:31 +02:00
|
|
|
class PrefService;
|
2012-04-03 03:34:16 +02:00
|
|
|
|
|
|
|
namespace content {
|
2012-09-28 22:14:02 +02:00
|
|
|
class PluginServiceFilter;
|
2012-04-03 03:34:16 +02:00
|
|
|
class SiteInstance;
|
|
|
|
}
|
|
|
|
|
|
|
|
class CefContentBrowserClient : public content::ContentBrowserClient {
|
|
|
|
public:
|
|
|
|
CefContentBrowserClient();
|
|
|
|
virtual ~CefContentBrowserClient();
|
|
|
|
|
2012-11-20 21:08:36 +01:00
|
|
|
// Returns the singleton CefContentBrowserClient instance.
|
|
|
|
static CefContentBrowserClient* Get();
|
|
|
|
|
2012-12-30 12:17:49 +01:00
|
|
|
// Methods for managing CefBrowserInfo life span. Do not add new callers of
|
|
|
|
// these methods.
|
2012-11-20 21:08:36 +01:00
|
|
|
// During popup window creation there is a race between the call to
|
|
|
|
// CefBrowserMessageFilter::OnGetNewBrowserInfo on the IO thread and the call
|
2013-02-09 23:38:24 +01:00
|
|
|
// to CefBrowserHostImpl::ShouldCreateWebContents on the UI thread. To resolve
|
|
|
|
// this race CefBrowserInfo may be created when requested for the first time
|
|
|
|
// and before the associated CefBrowserHostImpl is created.
|
2013-11-08 17:06:06 +01:00
|
|
|
scoped_refptr<CefBrowserInfo> CreateBrowserInfo(bool is_popup);
|
2014-01-02 23:41:11 +01:00
|
|
|
scoped_refptr<CefBrowserInfo> GetOrCreateBrowserInfo(
|
|
|
|
int render_view_process_id,
|
|
|
|
int render_view_routing_id,
|
|
|
|
int render_frame_process_id,
|
|
|
|
int render_frame_routing_id);
|
2012-12-30 12:17:49 +01:00
|
|
|
void RemoveBrowserInfo(scoped_refptr<CefBrowserInfo> browser_info);
|
|
|
|
void DestroyAllBrowsers();
|
|
|
|
|
|
|
|
// Retrieves the CefBrowserInfo matching the specified IDs or an empty
|
|
|
|
// pointer if no match is found. It is allowed to add new callers of this
|
2014-01-02 23:41:11 +01:00
|
|
|
// method but consider using CefBrowserHostImpl::GetBrowserFor[View|Frame]()
|
2013-09-03 18:43:31 +02:00
|
|
|
// instead.
|
2014-01-02 23:41:11 +01:00
|
|
|
scoped_refptr<CefBrowserInfo> GetBrowserInfoForView(int render_process_id,
|
|
|
|
int render_routing_id);
|
|
|
|
scoped_refptr<CefBrowserInfo> GetBrowserInfoForFrame(int render_process_id,
|
|
|
|
int render_routing_id);
|
2012-11-20 21:08:36 +01:00
|
|
|
|
2013-09-03 18:43:31 +02:00
|
|
|
// Create and return a new CefBrowserContextProxy object.
|
|
|
|
CefBrowserContext* CreateBrowserContextProxy(
|
|
|
|
CefRefPtr<CefRequestContextHandler> handler);
|
|
|
|
|
|
|
|
// BrowserContexts are nominally owned by RenderViewHosts and
|
|
|
|
// CefRequestContextImpls. Keep track of how many objects reference a given
|
|
|
|
// context and delete the context when the reference count reaches zero.
|
|
|
|
void AddBrowserContextReference(CefBrowserContext* context);
|
|
|
|
void RemoveBrowserContextReference(CefBrowserContext* context);
|
|
|
|
|
|
|
|
// ContentBrowserClient implementation.
|
2012-04-03 03:34:16 +02:00
|
|
|
virtual content::BrowserMainParts* CreateBrowserMainParts(
|
|
|
|
const content::MainFunctionParams& parameters) OVERRIDE;
|
2013-02-27 18:56:03 +01:00
|
|
|
virtual content::WebContentsViewPort* OverrideCreateWebContentsView(
|
2012-11-21 01:40:15 +01:00
|
|
|
content::WebContents* web_contents,
|
|
|
|
content::RenderViewHostDelegateView** rvhdv) OVERRIDE;
|
2014-01-02 23:41:11 +01:00
|
|
|
virtual void RenderProcessWillLaunch(
|
2013-02-23 01:43:28 +01:00
|
|
|
content::RenderProcessHost* host) OVERRIDE;
|
|
|
|
virtual net::URLRequestContextGetter* CreateRequestContext(
|
|
|
|
content::BrowserContext* browser_context,
|
2014-04-04 18:50:38 +02:00
|
|
|
content::ProtocolHandlerMap* protocol_handlers,
|
|
|
|
content::ProtocolHandlerScopedVector protocol_interceptors) OVERRIDE;
|
2013-02-23 01:43:28 +01:00
|
|
|
virtual net::URLRequestContextGetter* CreateRequestContextForStoragePartition(
|
|
|
|
content::BrowserContext* browser_context,
|
|
|
|
const base::FilePath& partition_path,
|
|
|
|
bool in_memory,
|
2014-04-04 18:50:38 +02:00
|
|
|
content::ProtocolHandlerMap* protocol_handlers,
|
|
|
|
content::ProtocolHandlerScopedVector protocol_interceptors) OVERRIDE;
|
2013-06-04 19:41:37 +02:00
|
|
|
virtual bool IsHandledURL(const GURL& url) OVERRIDE;
|
2014-04-04 18:50:38 +02:00
|
|
|
virtual void AppendExtraCommandLineSwitches(base::CommandLine* command_line,
|
2012-04-03 03:34:16 +02:00
|
|
|
int child_process_id) OVERRIDE;
|
2012-09-28 00:52:15 +02:00
|
|
|
virtual content::QuotaPermissionContext*
|
|
|
|
CreateQuotaPermissionContext() OVERRIDE;
|
2012-04-03 03:34:16 +02:00
|
|
|
virtual content::MediaObserver* GetMediaObserver() OVERRIDE;
|
2013-03-08 01:41:26 +01:00
|
|
|
virtual content::SpeechRecognitionManagerDelegate*
|
|
|
|
GetSpeechRecognitionManagerDelegate() OVERRIDE;
|
2013-04-04 19:50:35 +02:00
|
|
|
virtual void AllowCertificateError(
|
|
|
|
int render_process_id,
|
|
|
|
int render_view_id,
|
|
|
|
int cert_error,
|
|
|
|
const net::SSLInfo& ssl_info,
|
|
|
|
const GURL& request_url,
|
|
|
|
ResourceType::Type resource_type,
|
|
|
|
bool overridable,
|
|
|
|
bool strict_enforcement,
|
|
|
|
const base::Callback<void(bool)>& callback,
|
2013-06-04 19:41:37 +02:00
|
|
|
content::CertificateRequestResultType* result) OVERRIDE;
|
2012-04-03 03:34:16 +02:00
|
|
|
virtual content::AccessTokenStore* CreateAccessTokenStore() OVERRIDE;
|
2013-02-08 01:07:41 +01:00
|
|
|
virtual bool CanCreateWindow(const GURL& opener_url,
|
2013-10-16 02:25:38 +02:00
|
|
|
const GURL& opener_top_level_frame_url,
|
2013-08-15 21:38:55 +02:00
|
|
|
const GURL& source_origin,
|
2013-02-08 01:07:41 +01:00
|
|
|
WindowContainerType container_type,
|
2013-08-15 21:38:55 +02:00
|
|
|
const GURL& target_url,
|
|
|
|
const content::Referrer& referrer,
|
|
|
|
WindowOpenDisposition disposition,
|
2013-11-08 22:28:56 +01:00
|
|
|
const blink::WebWindowFeatures& features,
|
2013-08-15 21:38:55 +02:00
|
|
|
bool user_gesture,
|
|
|
|
bool opener_suppressed,
|
2013-02-08 01:07:41 +01:00
|
|
|
content::ResourceContext* context,
|
|
|
|
int render_process_id,
|
2013-08-15 21:38:55 +02:00
|
|
|
bool is_guest,
|
|
|
|
int opener_id,
|
2013-02-08 01:07:41 +01:00
|
|
|
bool* no_javascript_access) OVERRIDE;
|
2012-06-25 23:21:27 +02:00
|
|
|
virtual void ResourceDispatcherHostCreated() OVERRIDE;
|
2012-04-03 03:34:16 +02:00
|
|
|
virtual void OverrideWebkitPrefs(content::RenderViewHost* rvh,
|
|
|
|
const GURL& url,
|
2013-05-07 23:48:34 +02:00
|
|
|
WebPreferences* prefs) OVERRIDE;
|
2012-10-08 19:47:37 +02:00
|
|
|
virtual void BrowserURLHandlerCreated(
|
|
|
|
content::BrowserURLHandler* handler) OVERRIDE;
|
2012-04-03 03:34:16 +02:00
|
|
|
virtual std::string GetDefaultDownloadName() OVERRIDE;
|
2012-11-21 01:40:15 +01:00
|
|
|
|
2013-11-21 23:43:36 +01:00
|
|
|
#if defined(OS_POSIX) && !defined(OS_MACOSX)
|
|
|
|
virtual void GetAdditionalMappedFilesForChildProcess(
|
2014-04-04 18:50:38 +02:00
|
|
|
const base::CommandLine& command_line,
|
2013-11-21 23:43:36 +01:00
|
|
|
int child_process_id,
|
|
|
|
std::vector<content::FileDescriptorInfo>* mappings) OVERRIDE;
|
|
|
|
#endif
|
|
|
|
|
2012-09-11 00:19:19 +02:00
|
|
|
#if defined(OS_WIN)
|
|
|
|
const wchar_t* GetResourceDllName() OVERRIDE;
|
|
|
|
#endif
|
2012-04-03 03:34:16 +02:00
|
|
|
|
2013-06-05 01:37:26 +02:00
|
|
|
// Perform browser process registration for the custom scheme.
|
|
|
|
void RegisterCustomScheme(const std::string& scheme);
|
2013-06-04 19:41:37 +02:00
|
|
|
|
2013-02-08 01:07:41 +01:00
|
|
|
// Store additional state from the ViewHostMsg_CreateWindow message that will
|
|
|
|
// be used when CanCreateWindow() is called.
|
|
|
|
struct LastCreateWindowParams {
|
2013-02-09 23:38:24 +01:00
|
|
|
int opener_process_id;
|
|
|
|
int opener_view_id;
|
2013-02-08 01:07:41 +01:00
|
|
|
int64 opener_frame_id;
|
|
|
|
GURL target_url;
|
2013-12-17 23:04:35 +01:00
|
|
|
base::string16 target_frame_name;
|
2013-02-08 01:07:41 +01:00
|
|
|
};
|
|
|
|
void set_last_create_window_params(const LastCreateWindowParams& params);
|
|
|
|
|
2013-08-28 17:56:18 +02:00
|
|
|
// To disable window rendering call this function with |override|=true
|
|
|
|
// just before calling WebContents::Create. This will cause
|
|
|
|
// OverrideCreateWebContentsView to create a windowless WebContentsView.
|
|
|
|
void set_use_osr_next_contents_view(bool value) {
|
|
|
|
use_osr_next_contents_view_ = value;
|
|
|
|
}
|
|
|
|
bool use_osr_next_contents_view() const {
|
|
|
|
return use_osr_next_contents_view_;
|
|
|
|
}
|
|
|
|
|
2013-09-03 18:43:31 +02:00
|
|
|
CefBrowserContext* browser_context() const;
|
|
|
|
scoped_refptr<net::URLRequestContextGetter> request_context() const;
|
|
|
|
CefDevToolsDelegate* devtools_delegate() const;
|
|
|
|
PrefService* pref_service() const;
|
2013-02-23 01:43:28 +01:00
|
|
|
|
2013-09-03 18:43:31 +02:00
|
|
|
// Passes ownership.
|
|
|
|
scoped_ptr<net::ProxyConfigService> proxy_config_service() const;
|
|
|
|
|
|
|
|
private:
|
2012-04-03 03:34:16 +02:00
|
|
|
CefBrowserMainParts* browser_main_parts_;
|
|
|
|
|
2012-09-28 22:14:02 +02:00
|
|
|
scoped_ptr<content::PluginServiceFilter> plugin_service_filter_;
|
2012-06-25 23:21:27 +02:00
|
|
|
scoped_ptr<CefResourceDispatcherHostDelegate>
|
|
|
|
resource_dispatcher_host_delegate_;
|
2012-11-20 21:08:36 +01:00
|
|
|
|
2012-12-30 12:17:49 +01:00
|
|
|
base::Lock browser_info_lock_;
|
2012-11-20 21:08:36 +01:00
|
|
|
|
2012-12-30 12:17:49 +01:00
|
|
|
// Access must be protected by |browser_info_lock_|.
|
|
|
|
typedef std::list<scoped_refptr<CefBrowserInfo> > BrowserInfoList;
|
|
|
|
BrowserInfoList browser_info_list_;
|
|
|
|
int next_browser_id_;
|
2013-02-08 01:07:41 +01:00
|
|
|
|
|
|
|
// Only accessed on the IO thread.
|
|
|
|
LastCreateWindowParams last_create_window_params_;
|
2013-08-28 17:56:18 +02:00
|
|
|
|
|
|
|
bool use_osr_next_contents_view_;
|
2012-04-03 03:34:16 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // CEF_LIBCEF_BROWSER_CONTENT_BROWSER_CLIENT_H_
|