1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROMECAST_BROWSER_CAST_CONTENT_BROWSER_CLIENT_H_
6 #define CHROMECAST_BROWSER_CAST_CONTENT_BROWSER_CLIENT_H_
10 #include "base/macros.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "content/public/browser/content_browser_client.h"
15 class CrashHandlerHostLinux
;
19 class BrowserMessageFilter
;
22 namespace chromecast
{
25 class CastBrowserMainParts
;
26 class URLRequestContextFactory
;
28 class CastContentBrowserClient
: public content::ContentBrowserClient
{
30 CastContentBrowserClient();
31 ~CastContentBrowserClient() override
;
33 // Appends extra command line arguments before launching a new process.
34 void PlatformAppendExtraCommandLineSwitches(base::CommandLine
* command_line
);
36 // Returns any BrowserMessageFilters from the platform implementation that
37 // should be added when launching a new render process.
38 std::vector
<scoped_refptr
<content::BrowserMessageFilter
>>
39 PlatformGetBrowserMessageFilters();
41 // content::ContentBrowserClient implementation:
42 content::BrowserMainParts
* CreateBrowserMainParts(
43 const content::MainFunctionParams
& parameters
) override
;
44 void RenderProcessWillLaunch(content::RenderProcessHost
* host
) override
;
45 net::URLRequestContextGetter
* CreateRequestContext(
46 content::BrowserContext
* browser_context
,
47 content::ProtocolHandlerMap
* protocol_handlers
,
48 content::URLRequestInterceptorScopedVector request_interceptors
)
50 bool IsHandledURL(const GURL
& url
) override
;
51 void AppendExtraCommandLineSwitches(base::CommandLine
* command_line
,
52 int child_process_id
) override
;
53 content::AccessTokenStore
* CreateAccessTokenStore() override
;
54 void OverrideWebkitPrefs(content::RenderViewHost
* render_view_host
,
55 content::WebPreferences
* prefs
) override
;
56 void ResourceDispatcherHostCreated() override
;
57 std::string
GetApplicationLocale() override
;
58 void AllowCertificateError(
59 int render_process_id
,
62 const net::SSLInfo
& ssl_info
,
63 const GURL
& request_url
,
64 content::ResourceType resource_type
,
66 bool strict_enforcement
,
67 bool expired_previous_decision
,
68 const base::Callback
<void(bool)>& callback
,
69 content::CertificateRequestResultType
* result
) override
;
70 void SelectClientCertificate(
71 content::WebContents
* web_contents
,
72 net::SSLCertRequestInfo
* cert_request_info
,
73 scoped_ptr
<content::ClientCertificateDelegate
> delegate
) override
;
74 void RequestPermission(
75 content::PermissionType permission
,
76 content::WebContents
* web_contents
,
78 const GURL
& requesting_frame
,
80 const base::Callback
<void(content::PermissionStatus
)>& callback
) override
;
81 content::PermissionStatus
GetPermissionStatus(
82 content::PermissionType permission
,
83 content::BrowserContext
* browser_context
,
84 const GURL
& requesting_origin
,
85 const GURL
& embedding_origin
) override
;
87 const GURL
& opener_url
,
88 const GURL
& opener_top_level_frame_url
,
89 const GURL
& source_origin
,
90 WindowContainerType container_type
,
91 const GURL
& target_url
,
92 const content::Referrer
& referrer
,
93 WindowOpenDisposition disposition
,
94 const blink::WebWindowFeatures
& features
,
96 bool opener_suppressed
,
97 content::ResourceContext
* context
,
98 int render_process_id
,
100 bool* no_javascript_access
) override
;
101 content::DevToolsManagerDelegate
* GetDevToolsManagerDelegate() override
;
102 void GetAdditionalMappedFilesForChildProcess(
103 const base::CommandLine
& command_line
,
104 int child_process_id
,
105 content::FileDescriptorInfo
* mappings
) override
;
106 #if defined(OS_ANDROID) && defined(VIDEO_HOLE)
107 content::ExternalVideoSurfaceContainer
*
108 OverrideCreateExternalVideoSurfaceContainer(
109 content::WebContents
* web_contents
) override
;
110 #endif // defined(OS_ANDROID) && defined(VIDEO_HOLE)
113 net::X509Certificate
* SelectClientCertificateOnIOThread(
115 int render_process_id
);
117 #if !defined(OS_ANDROID)
118 // Returns the crash signal FD corresponding to the current process type.
119 int GetCrashSignalFD(const base::CommandLine
& command_line
);
121 // Creates a CrashHandlerHost instance for the given process type.
122 breakpad::CrashHandlerHostLinux
* CreateCrashHandlerHost(
123 const std::string
& process_type
);
125 // A static cache to hold crash_handlers for each process_type
126 std::map
<std::string
, breakpad::CrashHandlerHostLinux
*> crash_handlers_
;
129 scoped_ptr
<URLRequestContextFactory
> url_request_context_factory_
;
131 DISALLOW_COPY_AND_ASSIGN(CastContentBrowserClient
);
135 } // namespace chromecast
137 #endif // CHROMECAST_BROWSER_CAST_CONTENT_BROWSER_CLIENT_H_