#ifndef CHROME_BROWSER_CHROME_CONTENT_BROWSER_CLIENT_H_
#define CHROME_BROWSER_CHROME_CONTENT_BROWSER_CLIENT_H_
#include <set>
#include <string>
#include <utility>
#include <vector>
#include "base/compiler_specific.h"
#include "base/gtest_prod_util.h"
#include "chrome/common/chrome_version_info.h"
#include "content/public/browser/content_browser_client.h"
#if defined(OS_ANDROID)
#include "base/memory/scoped_ptr.h"
#endif
namespace base {
class CommandLine;
}
namespace content {
class QuotaPermissionContext;
}
namespace extensions {
class BrowserPermissionsPolicyDelegate;
}
namespace user_prefs {
class PrefRegistrySyncable;
}
namespace chrome {
class ChromeContentBrowserClient : public content::ContentBrowserClient {
public:
ChromeContentBrowserClient();
virtual ~ChromeContentBrowserClient();
static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
static void SetApplicationLocale(const std::string& locale);
virtual content::BrowserMainParts* CreateBrowserMainParts(
const content::MainFunctionParams& parameters) OVERRIDE;
virtual std::string GetStoragePartitionIdForSite(
content::BrowserContext* browser_context,
const GURL& site) OVERRIDE;
virtual bool IsValidStoragePartitionId(
content::BrowserContext* browser_context,
const std::string& partition_id) OVERRIDE;
virtual void GetStoragePartitionConfigForSite(
content::BrowserContext* browser_context,
const GURL& site,
bool can_be_default,
std::string* partition_domain,
std::string* partition_name,
bool* in_memory) OVERRIDE;
virtual content::WebContentsViewDelegate* GetWebContentsViewDelegate(
content::WebContents* web_contents) OVERRIDE;
virtual void GuestWebContentsCreated(
content::SiteInstance* guest_site_instance,
content::WebContents* guest_web_contents,
content::WebContents* opener_web_contents,
content::BrowserPluginGuestDelegate** guest_delegate,
scoped_ptr<base::DictionaryValue> extra_params) OVERRIDE;
virtual void GuestWebContentsAttached(
content::WebContents* guest_web_contents,
content::WebContents* embedder_web_contents,
const base::DictionaryValue& extra_params) OVERRIDE;
virtual void RenderProcessWillLaunch(
content::RenderProcessHost* host) OVERRIDE;
virtual bool ShouldUseProcessPerSite(content::BrowserContext* browser_context,
const GURL& effective_url) OVERRIDE;
virtual GURL GetEffectiveURL(content::BrowserContext* browser_context,
const GURL& url) OVERRIDE;
virtual void GetAdditionalWebUISchemes(
std::vector<std::string>* additional_schemes) OVERRIDE;
virtual void GetAdditionalWebUIHostsToIgnoreParititionCheck(
std::vector<std::string>* hosts) OVERRIDE;
virtual net::URLRequestContextGetter* CreateRequestContext(
content::BrowserContext* browser_context,
content::ProtocolHandlerMap* protocol_handlers,
content::ProtocolHandlerScopedVector protocol_interceptors) OVERRIDE;
virtual net::URLRequestContextGetter* CreateRequestContextForStoragePartition(
content::BrowserContext* browser_context,
const base::FilePath& partition_path,
bool in_memory,
content::ProtocolHandlerMap* protocol_handlers,
content::ProtocolHandlerScopedVector protocol_interceptors) OVERRIDE;
virtual bool IsHandledURL(const GURL& url) OVERRIDE;
virtual bool CanCommitURL(content::RenderProcessHost* process_host,
const GURL& url) OVERRIDE;
virtual bool ShouldAllowOpenURL(content::SiteInstance* site_instance,
const GURL& url) OVERRIDE;
virtual bool IsSuitableHost(content::RenderProcessHost* process_host,
const GURL& site_url) OVERRIDE;
virtual bool ShouldTryToUseExistingProcessHost(
content::BrowserContext* browser_context, const GURL& url) OVERRIDE;
virtual void SiteInstanceGotProcess(
content::SiteInstance* site_instance) OVERRIDE;
virtual void SiteInstanceDeleting(content::SiteInstance* site_instance)
OVERRIDE;
virtual void WorkerProcessCreated(content::SiteInstance* site_instance,
int worker_process_id) OVERRIDE;
virtual void WorkerProcessTerminated(content::SiteInstance* site_instance,
int worker_process_id) OVERRIDE;
virtual bool ShouldSwapBrowsingInstancesForNavigation(
content::SiteInstance* site_instance,
const GURL& current_url,
const GURL& new_url) OVERRIDE;
virtual bool ShouldSwapProcessesForRedirect(
content::ResourceContext* resource_context,
const GURL& current_url,
const GURL& new_url) OVERRIDE;
virtual bool ShouldAssignSiteForURL(const GURL& url) OVERRIDE;
virtual std::string GetCanonicalEncodingNameByAliasName(
const std::string& alias_name) OVERRIDE;
virtual void AppendExtraCommandLineSwitches(base::CommandLine* command_line,
int child_process_id) OVERRIDE;
virtual std::string GetApplicationLocale() OVERRIDE;
virtual std::string GetAcceptLangs(
content::BrowserContext* context) OVERRIDE;
virtual gfx::ImageSkia* GetDefaultFavicon() OVERRIDE;
virtual bool AllowAppCache(const GURL& manifest_url,
const GURL& first_party,
content::ResourceContext* context) OVERRIDE;
virtual bool AllowGetCookie(const GURL& url,
const GURL& first_party,
const net::CookieList& cookie_list,
content::ResourceContext* context,
int render_process_id,
int render_frame_id) OVERRIDE;
virtual bool AllowSetCookie(const GURL& url,
const GURL& first_party,
const std::string& cookie_line,
content::ResourceContext* context,
int render_process_id,
int render_frame_id,
net::CookieOptions* options) OVERRIDE;
virtual bool AllowSaveLocalState(content::ResourceContext* context) OVERRIDE;
virtual bool AllowWorkerDatabase(
const GURL& url,
const base::string16& name,
const base::string16& display_name,
unsigned long estimated_size,
content::ResourceContext* context,
const std::vector<std::pair<int, int> >& render_frames) OVERRIDE;
virtual bool AllowWorkerFileSystem(
const GURL& url,
content::ResourceContext* context,
const std::vector<std::pair<int, int> >& render_frames) OVERRIDE;
virtual bool AllowWorkerIndexedDB(
const GURL& url,
const base::string16& name,
content::ResourceContext* context,
const std::vector<std::pair<int, int> >& render_frames) OVERRIDE;
virtual net::URLRequestContext* OverrideRequestContextForURL(
const GURL& url, content::ResourceContext* context) OVERRIDE;
virtual content::QuotaPermissionContext*
CreateQuotaPermissionContext() OVERRIDE;
virtual void AllowCertificateError(
int render_process_id,
int render_frame_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,
content::CertificateRequestResultType* request) OVERRIDE;
virtual void SelectClientCertificate(
int render_process_id,
int render_frame_id,
const net::HttpNetworkSession* network_session,
net::SSLCertRequestInfo* cert_request_info,
const base::Callback<void(net::X509Certificate*)>& callback) OVERRIDE;
virtual void AddCertificate(
net::URLRequest* request,
net::CertificateMimeType cert_type,
const void* cert_data,
size_t cert_size,
int render_process_id,
int render_view_id) OVERRIDE;
virtual content::MediaObserver* GetMediaObserver() OVERRIDE;
virtual void RequestDesktopNotificationPermission(
const GURL& source_origin,
int callback_context,
int render_process_id,
int render_view_id) OVERRIDE;
virtual blink::WebNotificationPresenter::Permission
CheckDesktopNotificationPermission(
const GURL& source_origin,
content::ResourceContext* context,
int render_process_id) OVERRIDE;
virtual void ShowDesktopNotification(
const content::ShowDesktopNotificationHostMsgParams& params,
int render_process_id,
int render_view_id,
bool worker) OVERRIDE;
virtual void CancelDesktopNotification(
int render_process_id,
int render_view_id,
int notification_id) OVERRIDE;
virtual bool CanCreateWindow(const GURL& opener_url,
const GURL& opener_top_level_frame_url,
const GURL& source_origin,
WindowContainerType container_type,
const GURL& target_url,
const content::Referrer& referrer,
WindowOpenDisposition disposition,
const blink::WebWindowFeatures& features,
bool user_gesture,
bool opener_suppressed,
content::ResourceContext* context,
int render_process_id,
bool is_guest,
int opener_id,
bool* no_javascript_access) OVERRIDE;
virtual std::string GetWorkerProcessTitle(
const GURL& url, content::ResourceContext* context) OVERRIDE;
virtual void ResourceDispatcherHostCreated() OVERRIDE;
virtual content::SpeechRecognitionManagerDelegate*
GetSpeechRecognitionManagerDelegate() OVERRIDE;
virtual net::NetLog* GetNetLog() OVERRIDE;
virtual content::AccessTokenStore* CreateAccessTokenStore() OVERRIDE;
virtual bool IsFastShutdownPossible() OVERRIDE;
virtual void OverrideWebkitPrefs(content::RenderViewHost* rvh,
const GURL& url,
WebPreferences* prefs) OVERRIDE;
virtual void UpdateInspectorSetting(content::RenderViewHost* rvh,
const std::string& key,
const std::string& value) OVERRIDE;
virtual void BrowserURLHandlerCreated(
content::BrowserURLHandler* handler) OVERRIDE;
virtual void ClearCache(content::RenderViewHost* rvh) OVERRIDE;
virtual void ClearCookies(content::RenderViewHost* rvh) OVERRIDE;
virtual base::FilePath GetDefaultDownloadDirectory() OVERRIDE;
virtual std::string GetDefaultDownloadName() OVERRIDE;
virtual void DidCreatePpapiPlugin(
content::BrowserPpapiHost* browser_host) OVERRIDE;
virtual content::BrowserPpapiHost* GetExternalBrowserPpapiHost(
int plugin_process_id) OVERRIDE;
virtual bool SupportsBrowserPlugin(content::BrowserContext* browser_context,
const GURL& site_url) OVERRIDE;
virtual bool AllowPepperSocketAPI(
content::BrowserContext* browser_context,
const GURL& url,
bool private_api,
const content::SocketPermissionRequest* params) OVERRIDE;
virtual ui::SelectFilePolicy* CreateSelectFilePolicy(
content::WebContents* web_contents) OVERRIDE;
virtual void GetAdditionalAllowedSchemesForFileSystem(
std::vector<std::string>* additional_schemes) OVERRIDE;
virtual void GetURLRequestAutoMountHandlers(
std::vector<fileapi::URLRequestAutoMountHandler>* handlers) OVERRIDE;
virtual void GetAdditionalFileSystemBackends(
content::BrowserContext* browser_context,
const base::FilePath& storage_partition_path,
ScopedVector<fileapi::FileSystemBackend>* additional_backends) OVERRIDE;
#if defined(OS_POSIX) && !defined(OS_MACOSX)
virtual void GetAdditionalMappedFilesForChildProcess(
const base::CommandLine& command_line,
int child_process_id,
std::vector<content::FileDescriptorInfo>* mappings) OVERRIDE;
#endif
#if defined(OS_WIN)
virtual const wchar_t* GetResourceDllName() OVERRIDE;
virtual void PreSpawnRenderer(sandbox::TargetPolicy* policy,
bool* success) OVERRIDE;
#endif
virtual bool IsPluginAllowedToCallRequestOSFileHandle(
content::BrowserContext* browser_context,
const GURL& url) OVERRIDE;
virtual bool IsPluginAllowedToUseDevChannelAPIs() OVERRIDE;
private:
#if defined(ENABLE_WEBRTC)
static void MaybeCopyDisableWebRtcEncryptionSwitch(
base::CommandLine* to_command_line,
const base::CommandLine& from_command_line,
VersionInfo::Channel channel);
#endif
#if defined(ENABLE_PLUGINS)
std::set<std::string> allowed_socket_origins_;
std::set<std::string> allowed_file_handle_origins_;
#endif
scoped_ptr<extensions::BrowserPermissionsPolicyDelegate>
permissions_policy_delegate_;
friend class DisableWebRtcEncryptionFlagTest;
DISALLOW_COPY_AND_ASSIGN(ChromeContentBrowserClient);
};
}
#endif