Roll src/third_party/WebKit a9df92e:64e9b6f (svn 202588:202589)
[chromium-blink-merge.git] / chromecast / browser / cast_content_browser_client.h
blob2e82fc848189b5f08b5b96149a82286519ba0072
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_
8 #include <map>
9 #include <string>
10 #include <vector>
12 #include "base/macros.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "content/public/browser/content_browser_client.h"
16 class PrefService;
18 namespace breakpad {
19 class CrashHandlerHostLinux;
22 namespace media {
23 class AudioManagerFactory;
24 class BrowserCdmFactory;
27 namespace metrics {
28 class MetricsService;
31 namespace chromecast {
32 class CastService;
34 namespace media {
35 class MediaPipelineBackend;
36 struct MediaPipelineDeviceParams;
37 class CmaMediaPipelineClient;
40 namespace shell {
42 class CastBrowserMainParts;
43 class URLRequestContextFactory;
45 class CastContentBrowserClient : public content::ContentBrowserClient {
46 public:
47 // Creates an implementation of CastContentBrowserClient. Platform should
48 // link in an implementation as needed.
49 static scoped_ptr<CastContentBrowserClient> Create();
51 ~CastContentBrowserClient() override;
53 // Appends extra command line arguments before launching a new process.
54 virtual void AppendExtraCommandLineSwitches(base::CommandLine* command_line);
56 // Creates and returns the CastService instance for the current process.
57 // Note: |request_context_getter| might be different than the main request
58 // getter accessible via CastBrowserProcess.
59 virtual scoped_ptr<CastService> CreateCastService(
60 content::BrowserContext* browser_context,
61 PrefService* pref_service,
62 net::URLRequestContextGetter* request_context_getter);
64 // Provide an AudioManagerFactory instance for WebAudio playback.
65 virtual scoped_ptr<::media::AudioManagerFactory> CreateAudioManagerFactory();
67 #if !defined(OS_ANDROID)
68 // Creates a CmaMediaPipelineClient which is responsible to create (CMA
69 // backend)
70 // for media playback and watch media pipeline status, called once per media
71 // player
72 // instance.
73 virtual scoped_refptr<media::CmaMediaPipelineClient>
74 CreateCmaMediaPipelineClient();
76 // Creates and returns a factory used for creating BrowserCdm instances for
77 // playing protected content. This is called once per browser lifetime.
78 virtual scoped_ptr<::media::BrowserCdmFactory> CreateBrowserCdmFactory();
79 #endif
81 // Performs cleanup for process exit (but before AtExitManager cleanup).
82 void ProcessExiting();
84 // Invoked when the metrics client ID changes.
85 virtual void SetMetricsClientId(const std::string& client_id);
87 // Allows registration of extra metrics providers.
88 virtual void RegisterMetricsProviders(
89 ::metrics::MetricsService* metrics_service);
91 // Returns whether or not the remote debugging service should be started
92 // on browser startup.
93 virtual bool EnableRemoteDebuggingImmediately();
95 // content::ContentBrowserClient implementation:
96 content::BrowserMainParts* CreateBrowserMainParts(
97 const content::MainFunctionParams& parameters) override;
98 void RenderProcessWillLaunch(content::RenderProcessHost* host) override;
99 net::URLRequestContextGetter* CreateRequestContext(
100 content::BrowserContext* browser_context,
101 content::ProtocolHandlerMap* protocol_handlers,
102 content::URLRequestInterceptorScopedVector request_interceptors)
103 override;
104 bool IsHandledURL(const GURL& url) override;
105 void AppendExtraCommandLineSwitches(base::CommandLine* command_line,
106 int child_process_id) override;
107 content::AccessTokenStore* CreateAccessTokenStore() override;
108 void OverrideWebkitPrefs(content::RenderViewHost* render_view_host,
109 content::WebPreferences* prefs) override;
110 void ResourceDispatcherHostCreated() override;
111 std::string GetApplicationLocale() override;
112 content::QuotaPermissionContext* CreateQuotaPermissionContext() override;
113 void AllowCertificateError(
114 int render_process_id,
115 int render_view_id,
116 int cert_error,
117 const net::SSLInfo& ssl_info,
118 const GURL& request_url,
119 content::ResourceType resource_type,
120 bool overridable,
121 bool strict_enforcement,
122 bool expired_previous_decision,
123 const base::Callback<void(bool)>& callback,
124 content::CertificateRequestResultType* result) override;
125 void SelectClientCertificate(
126 content::WebContents* web_contents,
127 net::SSLCertRequestInfo* cert_request_info,
128 scoped_ptr<content::ClientCertificateDelegate> delegate) override;
129 bool CanCreateWindow(
130 const GURL& opener_url,
131 const GURL& opener_top_level_frame_url,
132 const GURL& source_origin,
133 WindowContainerType container_type,
134 const GURL& target_url,
135 const content::Referrer& referrer,
136 WindowOpenDisposition disposition,
137 const blink::WebWindowFeatures& features,
138 bool user_gesture,
139 bool opener_suppressed,
140 content::ResourceContext* context,
141 int render_process_id,
142 int opener_render_view_id,
143 int opener_render_frame_id,
144 bool* no_javascript_access) override;
145 void RegisterUnsandboxedOutOfProcessMojoApplications(
146 std::map<GURL, base::string16>* apps) override;
147 #if defined(OS_ANDROID)
148 void GetAdditionalMappedFilesForChildProcess(
149 const base::CommandLine& command_line,
150 int child_process_id,
151 content::FileDescriptorInfo* mappings,
152 std::map<int, base::MemoryMappedFile::Region>* regions) override;
153 #else
154 void GetAdditionalMappedFilesForChildProcess(
155 const base::CommandLine& command_line,
156 int child_process_id,
157 content::FileDescriptorInfo* mappings) override;
158 #endif // defined(OS_ANDROID)
159 #if defined(OS_ANDROID) && defined(VIDEO_HOLE)
160 content::ExternalVideoSurfaceContainer*
161 OverrideCreateExternalVideoSurfaceContainer(
162 content::WebContents* web_contents) override;
163 #endif // defined(OS_ANDROID) && defined(VIDEO_HOLE)
165 protected:
166 CastContentBrowserClient();
168 URLRequestContextFactory* url_request_context_factory() const {
169 return url_request_context_factory_.get();
172 private:
173 void AddNetworkHintsMessageFilter(int render_process_id,
174 net::URLRequestContext* context);
176 net::X509Certificate* SelectClientCertificateOnIOThread(
177 GURL requesting_url,
178 int render_process_id);
180 #if !defined(OS_ANDROID)
181 // Returns the crash signal FD corresponding to the current process type.
182 int GetCrashSignalFD(const base::CommandLine& command_line);
184 // Creates a CrashHandlerHost instance for the given process type.
185 breakpad::CrashHandlerHostLinux* CreateCrashHandlerHost(
186 const std::string& process_type);
188 // A static cache to hold crash_handlers for each process_type
189 std::map<std::string, breakpad::CrashHandlerHostLinux*> crash_handlers_;
190 #endif
192 scoped_ptr<URLRequestContextFactory> url_request_context_factory_;
194 DISALLOW_COPY_AND_ASSIGN(CastContentBrowserClient);
197 } // namespace shell
198 } // namespace chromecast
200 #endif // CHROMECAST_BROWSER_CAST_CONTENT_BROWSER_CLIENT_H_