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_
12 #include "base/macros.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "content/public/browser/content_browser_client.h"
17 class CrashHandlerHostLinux
;
21 class BrowserMessageFilter
;
25 class AudioManagerFactory
;
32 namespace chromecast
{
34 class MediaPipelineBackend
;
35 struct MediaPipelineDeviceParams
;
40 class CastBrowserMainParts
;
41 class URLRequestContextFactory
;
43 class CastContentBrowserClient
: public content::ContentBrowserClient
{
45 // Creates an implementation of CastContentBrowserClient. Platform should
46 // link in an implementation as needed.
47 static scoped_ptr
<CastContentBrowserClient
> Create();
49 ~CastContentBrowserClient() override
;
51 // Appends extra command line arguments before launching a new process.
52 virtual void AppendExtraCommandLineSwitches(base::CommandLine
* command_line
);
54 // Returns any BrowserMessageFilters that should be added when launching a
55 // new render process.
56 virtual std::vector
<scoped_refptr
<content::BrowserMessageFilter
>>
57 GetBrowserMessageFilters();
59 // Provide an AudioManagerFactory instance for WebAudio playback.
60 virtual scoped_ptr
<::media::AudioManagerFactory
> CreateAudioManagerFactory();
62 #if !defined(OS_ANDROID)
63 // Creates a MediaPipelineDevice (CMA backend) for media playback, called
64 // once per media player instance.
65 virtual scoped_ptr
<media::MediaPipelineBackend
> CreateMediaPipelineBackend(
66 const media::MediaPipelineDeviceParams
& params
);
69 // Performs cleanup for process exit (but before AtExitManager cleanup).
70 void ProcessExiting();
72 // Invoked when the metrics client ID changes.
73 virtual void SetMetricsClientId(const std::string
& client_id
);
75 // Allows registration of extra metrics providers.
76 virtual void RegisterMetricsProviders(
77 ::metrics::MetricsService
* metrics_service
);
79 // content::ContentBrowserClient implementation:
80 content::BrowserMainParts
* CreateBrowserMainParts(
81 const content::MainFunctionParams
& parameters
) override
;
82 void RenderProcessWillLaunch(content::RenderProcessHost
* host
) override
;
83 net::URLRequestContextGetter
* CreateRequestContext(
84 content::BrowserContext
* browser_context
,
85 content::ProtocolHandlerMap
* protocol_handlers
,
86 content::URLRequestInterceptorScopedVector request_interceptors
)
88 bool IsHandledURL(const GURL
& url
) override
;
89 void AppendExtraCommandLineSwitches(base::CommandLine
* command_line
,
90 int child_process_id
) override
;
91 content::AccessTokenStore
* CreateAccessTokenStore() override
;
92 void OverrideWebkitPrefs(content::RenderViewHost
* render_view_host
,
93 content::WebPreferences
* prefs
) override
;
94 void ResourceDispatcherHostCreated() override
;
95 std::string
GetApplicationLocale() override
;
96 content::QuotaPermissionContext
* CreateQuotaPermissionContext() override
;
97 void AllowCertificateError(
98 int render_process_id
,
101 const net::SSLInfo
& ssl_info
,
102 const GURL
& request_url
,
103 content::ResourceType resource_type
,
105 bool strict_enforcement
,
106 bool expired_previous_decision
,
107 const base::Callback
<void(bool)>& callback
,
108 content::CertificateRequestResultType
* result
) override
;
109 void SelectClientCertificate(
110 content::WebContents
* web_contents
,
111 net::SSLCertRequestInfo
* cert_request_info
,
112 scoped_ptr
<content::ClientCertificateDelegate
> delegate
) override
;
113 bool CanCreateWindow(
114 const GURL
& opener_url
,
115 const GURL
& opener_top_level_frame_url
,
116 const GURL
& source_origin
,
117 WindowContainerType container_type
,
118 const GURL
& target_url
,
119 const content::Referrer
& referrer
,
120 WindowOpenDisposition disposition
,
121 const blink::WebWindowFeatures
& features
,
123 bool opener_suppressed
,
124 content::ResourceContext
* context
,
125 int render_process_id
,
126 int opener_render_view_id
,
127 int opener_render_frame_id
,
128 bool* no_javascript_access
) override
;
129 void RegisterUnsandboxedOutOfProcessMojoApplications(
130 std::vector
<GURL
>* urls
) override
;
131 #if defined(OS_ANDROID)
132 void GetAdditionalMappedFilesForChildProcess(
133 const base::CommandLine
& command_line
,
134 int child_process_id
,
135 content::FileDescriptorInfo
* mappings
,
136 std::map
<int, base::MemoryMappedFile::Region
>* regions
) override
;
138 void GetAdditionalMappedFilesForChildProcess(
139 const base::CommandLine
& command_line
,
140 int child_process_id
,
141 content::FileDescriptorInfo
* mappings
) override
;
142 #endif // defined(OS_ANDROID)
143 #if defined(OS_ANDROID) && defined(VIDEO_HOLE)
144 content::ExternalVideoSurfaceContainer
*
145 OverrideCreateExternalVideoSurfaceContainer(
146 content::WebContents
* web_contents
) override
;
147 #endif // defined(OS_ANDROID) && defined(VIDEO_HOLE)
150 CastContentBrowserClient();
153 void AddNetworkHintsMessageFilter(int render_process_id
,
154 net::URLRequestContext
* context
);
156 net::X509Certificate
* SelectClientCertificateOnIOThread(
158 int render_process_id
);
160 #if !defined(OS_ANDROID)
161 // Returns the crash signal FD corresponding to the current process type.
162 int GetCrashSignalFD(const base::CommandLine
& command_line
);
164 // Creates a CrashHandlerHost instance for the given process type.
165 breakpad::CrashHandlerHostLinux
* CreateCrashHandlerHost(
166 const std::string
& process_type
);
168 // A static cache to hold crash_handlers for each process_type
169 std::map
<std::string
, breakpad::CrashHandlerHostLinux
*> crash_handlers_
;
172 scoped_ptr
<URLRequestContextFactory
> url_request_context_factory_
;
174 DISALLOW_COPY_AND_ASSIGN(CastContentBrowserClient
);
178 } // namespace chromecast
180 #endif // CHROMECAST_BROWSER_CAST_CONTENT_BROWSER_CLIENT_H_