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 MediaPipelineDevice
;
35 class 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::MediaPipelineDevice
> CreateMediaPipelineDevice(
66 const media::MediaPipelineDeviceParams
& params
);
69 // content::ContentBrowserClient implementation:
70 content::BrowserMainParts
* CreateBrowserMainParts(
71 const content::MainFunctionParams
& parameters
) override
;
72 void RenderProcessWillLaunch(content::RenderProcessHost
* host
) override
;
73 net::URLRequestContextGetter
* CreateRequestContext(
74 content::BrowserContext
* browser_context
,
75 content::ProtocolHandlerMap
* protocol_handlers
,
76 content::URLRequestInterceptorScopedVector request_interceptors
)
78 bool IsHandledURL(const GURL
& url
) override
;
79 void AppendExtraCommandLineSwitches(base::CommandLine
* command_line
,
80 int child_process_id
) override
;
81 content::AccessTokenStore
* CreateAccessTokenStore() override
;
82 void OverrideWebkitPrefs(content::RenderViewHost
* render_view_host
,
83 content::WebPreferences
* prefs
) override
;
84 void ResourceDispatcherHostCreated() override
;
85 std::string
GetApplicationLocale() override
;
86 content::QuotaPermissionContext
* CreateQuotaPermissionContext() override
;
87 void AllowCertificateError(
88 int render_process_id
,
91 const net::SSLInfo
& ssl_info
,
92 const GURL
& request_url
,
93 content::ResourceType resource_type
,
95 bool strict_enforcement
,
96 bool expired_previous_decision
,
97 const base::Callback
<void(bool)>& callback
,
98 content::CertificateRequestResultType
* result
) override
;
99 void SelectClientCertificate(
100 content::WebContents
* web_contents
,
101 net::SSLCertRequestInfo
* cert_request_info
,
102 scoped_ptr
<content::ClientCertificateDelegate
> delegate
) override
;
103 bool CanCreateWindow(
104 const GURL
& opener_url
,
105 const GURL
& opener_top_level_frame_url
,
106 const GURL
& source_origin
,
107 WindowContainerType container_type
,
108 const GURL
& target_url
,
109 const content::Referrer
& referrer
,
110 WindowOpenDisposition disposition
,
111 const blink::WebWindowFeatures
& features
,
113 bool opener_suppressed
,
114 content::ResourceContext
* context
,
115 int render_process_id
,
116 int opener_render_view_id
,
117 int opener_render_frame_id
,
118 bool* no_javascript_access
) override
;
119 void RegisterUnsandboxedOutOfProcessMojoApplications(
120 std::vector
<GURL
>* urls
) override
;
121 #if defined(OS_ANDROID)
122 void GetAdditionalMappedFilesForChildProcess(
123 const base::CommandLine
& command_line
,
124 int child_process_id
,
125 content::FileDescriptorInfo
* mappings
,
126 std::map
<int, base::MemoryMappedFile::Region
>* regions
) override
;
128 void GetAdditionalMappedFilesForChildProcess(
129 const base::CommandLine
& command_line
,
130 int child_process_id
,
131 content::FileDescriptorInfo
* mappings
) override
;
132 #endif // defined(OS_ANDROID)
133 #if defined(OS_ANDROID) && defined(VIDEO_HOLE)
134 content::ExternalVideoSurfaceContainer
*
135 OverrideCreateExternalVideoSurfaceContainer(
136 content::WebContents
* web_contents
) override
;
137 #endif // defined(OS_ANDROID) && defined(VIDEO_HOLE)
140 CastContentBrowserClient();
143 void AddNetworkHintsMessageFilter(int render_process_id
,
144 net::URLRequestContext
* context
);
146 net::X509Certificate
* SelectClientCertificateOnIOThread(
148 int render_process_id
);
150 #if !defined(OS_ANDROID)
151 // Returns the crash signal FD corresponding to the current process type.
152 int GetCrashSignalFD(const base::CommandLine
& command_line
);
154 // Creates a CrashHandlerHost instance for the given process type.
155 breakpad::CrashHandlerHostLinux
* CreateCrashHandlerHost(
156 const std::string
& process_type
);
158 // A static cache to hold crash_handlers for each process_type
159 std::map
<std::string
, breakpad::CrashHandlerHostLinux
*> crash_handlers_
;
162 scoped_ptr
<URLRequestContextFactory
> url_request_context_factory_
;
164 DISALLOW_COPY_AND_ASSIGN(CastContentBrowserClient
);
168 } // namespace chromecast
170 #endif // CHROMECAST_BROWSER_CAST_CONTENT_BROWSER_CLIENT_H_