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>
|
|
|
|
|
|
|
|
#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-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;
|
2012-06-25 23:21:27 +02:00
|
|
|
class CefResourceDispatcherHostDelegate;
|
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-04-03 03:34:16 +02:00
|
|
|
CefBrowserMainParts* browser_main_parts() const {
|
|
|
|
return browser_main_parts_;
|
|
|
|
}
|
|
|
|
|
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.
|
2012-12-30 12:17:49 +01:00
|
|
|
scoped_refptr<CefBrowserInfo> CreateBrowserInfo();
|
|
|
|
scoped_refptr<CefBrowserInfo> GetOrCreateBrowserInfo(int render_process_id,
|
|
|
|
int render_view_id);
|
|
|
|
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
|
|
|
|
// method but consider using CefContext::GetBrowserByRoutingID() instead.
|
|
|
|
scoped_refptr<CefBrowserInfo> GetBrowserInfo(int render_process_id,
|
|
|
|
int render_view_id);
|
2012-11-20 21:08:36 +01:00
|
|
|
|
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;
|
2013-02-23 01:43:28 +01:00
|
|
|
virtual void RenderProcessHostCreated(
|
|
|
|
content::RenderProcessHost* host) OVERRIDE;
|
|
|
|
virtual net::URLRequestContextGetter* CreateRequestContext(
|
|
|
|
content::BrowserContext* browser_context,
|
2013-03-12 21:23:24 +01:00
|
|
|
content::ProtocolHandlerMap* protocol_handlers) 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,
|
2013-03-12 21:23:24 +01:00
|
|
|
content::ProtocolHandlerMap* protocol_handlers) OVERRIDE;
|
2013-06-04 19:41:37 +02:00
|
|
|
virtual bool IsHandledURL(const GURL& url) OVERRIDE;
|
2012-04-03 03:34:16 +02:00
|
|
|
virtual void AppendExtraCommandLineSwitches(CommandLine* command_line,
|
|
|
|
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,
|
|
|
|
const GURL& origin,
|
|
|
|
WindowContainerType container_type,
|
|
|
|
content::ResourceContext* context,
|
|
|
|
int render_process_id,
|
|
|
|
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
|
|
|
|
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;
|
|
|
|
string16 target_frame_name;
|
|
|
|
};
|
|
|
|
void set_last_create_window_params(const LastCreateWindowParams& params);
|
|
|
|
|
2012-04-03 03:34:16 +02:00
|
|
|
private:
|
2013-02-23 01:43:28 +01:00
|
|
|
CefBrowserContext* CefBrowserContextForBrowserContext(
|
|
|
|
content::BrowserContext* content_browser_context);
|
|
|
|
|
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_;
|
2012-04-03 03:34:16 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // CEF_LIBCEF_BROWSER_CONTENT_BROWSER_CLIENT_H_
|