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 #if defined(OS_ANDROID)
120 void GetAdditionalMappedFilesForChildProcess(
121 const base::CommandLine
& command_line
,
122 int child_process_id
,
123 content::FileDescriptorInfo
* mappings
,
124 std::map
<int, base::MemoryMappedFile::Region
>* regions
) override
;
126 void GetAdditionalMappedFilesForChildProcess(
127 const base::CommandLine
& command_line
,
128 int child_process_id
,
129 content::FileDescriptorInfo
* mappings
) override
;
130 #endif // defined(OS_ANDROID)
131 #if defined(OS_ANDROID) && defined(VIDEO_HOLE)
132 content::ExternalVideoSurfaceContainer
*
133 OverrideCreateExternalVideoSurfaceContainer(
134 content::WebContents
* web_contents
) override
;
135 #endif // defined(OS_ANDROID) && defined(VIDEO_HOLE)
138 CastContentBrowserClient();
141 void AddNetworkHintsMessageFilter(int render_process_id
,
142 net::URLRequestContext
* context
);
144 net::X509Certificate
* SelectClientCertificateOnIOThread(
146 int render_process_id
);
148 #if !defined(OS_ANDROID)
149 // Returns the crash signal FD corresponding to the current process type.
150 int GetCrashSignalFD(const base::CommandLine
& command_line
);
152 // Creates a CrashHandlerHost instance for the given process type.
153 breakpad::CrashHandlerHostLinux
* CreateCrashHandlerHost(
154 const std::string
& process_type
);
156 // A static cache to hold crash_handlers for each process_type
157 std::map
<std::string
, breakpad::CrashHandlerHostLinux
*> crash_handlers_
;
160 scoped_ptr
<URLRequestContextFactory
> url_request_context_factory_
;
162 DISALLOW_COPY_AND_ASSIGN(CastContentBrowserClient
);
166 } // namespace chromecast
168 #endif // CHROMECAST_BROWSER_CAST_CONTENT_BROWSER_CLIENT_H_