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 void PlatformAppendExtraCommandLineSwitches(base::CommandLine
* command_line
);
54 // Returns any BrowserMessageFilters from the platform implementation that
55 // should be added when launching a new render process.
56 std::vector
<scoped_refptr
<content::BrowserMessageFilter
>>
57 PlatformGetBrowserMessageFilters();
59 #if !defined(OS_ANDROID)
60 // Creates a MediaPipelineDevice (CMA backend) for media playback, called
61 // once per media player instance.
62 scoped_ptr
<media::MediaPipelineDevice
> PlatformCreateMediaPipelineDevice(
63 const media::MediaPipelineDeviceParams
& params
);
66 // content::ContentBrowserClient implementation:
67 content::BrowserMainParts
* CreateBrowserMainParts(
68 const content::MainFunctionParams
& parameters
) override
;
69 void RenderProcessWillLaunch(content::RenderProcessHost
* host
) override
;
70 net::URLRequestContextGetter
* CreateRequestContext(
71 content::BrowserContext
* browser_context
,
72 content::ProtocolHandlerMap
* protocol_handlers
,
73 content::URLRequestInterceptorScopedVector request_interceptors
)
75 bool IsHandledURL(const GURL
& url
) override
;
76 void AppendExtraCommandLineSwitches(base::CommandLine
* command_line
,
77 int child_process_id
) override
;
78 void AppendMappedFileCommandLineSwitches(
79 base::CommandLine
* command_line
) override
;
80 content::AccessTokenStore
* CreateAccessTokenStore() override
;
81 void OverrideWebkitPrefs(content::RenderViewHost
* render_view_host
,
82 content::WebPreferences
* prefs
) override
;
83 void ResourceDispatcherHostCreated() override
;
84 std::string
GetApplicationLocale() override
;
85 content::QuotaPermissionContext
* CreateQuotaPermissionContext() override
;
86 void AllowCertificateError(
87 int render_process_id
,
90 const net::SSLInfo
& ssl_info
,
91 const GURL
& request_url
,
92 content::ResourceType resource_type
,
94 bool strict_enforcement
,
95 bool expired_previous_decision
,
96 const base::Callback
<void(bool)>& callback
,
97 content::CertificateRequestResultType
* result
) override
;
98 void SelectClientCertificate(
99 content::WebContents
* web_contents
,
100 net::SSLCertRequestInfo
* cert_request_info
,
101 scoped_ptr
<content::ClientCertificateDelegate
> delegate
) override
;
102 bool CanCreateWindow(
103 const GURL
& opener_url
,
104 const GURL
& opener_top_level_frame_url
,
105 const GURL
& source_origin
,
106 WindowContainerType container_type
,
107 const GURL
& target_url
,
108 const content::Referrer
& referrer
,
109 WindowOpenDisposition disposition
,
110 const blink::WebWindowFeatures
& features
,
112 bool opener_suppressed
,
113 content::ResourceContext
* context
,
114 int render_process_id
,
115 int opener_render_view_id
,
116 int opener_render_frame_id
,
117 bool* no_javascript_access
) override
;
118 void GetAdditionalMappedFilesForChildProcess(
119 const base::CommandLine
& command_line
,
120 int child_process_id
,
121 content::FileDescriptorInfo
* mappings
) override
;
122 #if defined(OS_ANDROID) && defined(VIDEO_HOLE)
123 content::ExternalVideoSurfaceContainer
*
124 OverrideCreateExternalVideoSurfaceContainer(
125 content::WebContents
* web_contents
) override
;
126 #endif // defined(OS_ANDROID) && defined(VIDEO_HOLE)
129 CastContentBrowserClient();
132 void AddNetworkHintsMessageFilter(int render_process_id
,
133 net::URLRequestContext
* context
);
135 net::X509Certificate
* SelectClientCertificateOnIOThread(
137 int render_process_id
);
139 scoped_ptr
<::media::AudioManagerFactory
> PlatformCreateAudioManagerFactory();
141 #if !defined(OS_ANDROID)
142 // Returns the crash signal FD corresponding to the current process type.
143 int GetCrashSignalFD(const base::CommandLine
& command_line
);
145 // Creates a CrashHandlerHost instance for the given process type.
146 breakpad::CrashHandlerHostLinux
* CreateCrashHandlerHost(
147 const std::string
& process_type
);
149 // A static cache to hold crash_handlers for each process_type
150 std::map
<std::string
, breakpad::CrashHandlerHostLinux
*> crash_handlers_
;
153 base::ScopedFD v8_natives_fd_
;
154 base::ScopedFD v8_snapshot_fd_
;
155 bool natives_fd_exists() { return v8_natives_fd_
!= -1; }
156 bool snapshot_fd_exists() { return v8_snapshot_fd_
!= -1; }
158 scoped_ptr
<URLRequestContextFactory
> url_request_context_factory_
;
160 DISALLOW_COPY_AND_ASSIGN(CastContentBrowserClient
);
164 } // namespace chromecast
166 #endif // CHROMECAST_BROWSER_CAST_CONTENT_BROWSER_CLIENT_H_