Roll src/third_party/WebKit d9c6159:8139f33 (svn 201974:201975)
[chromium-blink-merge.git] / chromecast / browser / cast_content_browser_client.h
blob36ffae0ceb85660a95a9d3863de391d18a1ce6ea
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;
26 namespace metrics {
27 class MetricsService;
30 namespace chromecast {
31 class CastService;
33 namespace media {
34 class MediaPipelineBackend;
35 struct MediaPipelineDeviceParams;
36 class CmaMediaPipelineClient;
39 namespace shell {
41 class CastBrowserMainParts;
42 class URLRequestContextFactory;
44 class CastContentBrowserClient : public content::ContentBrowserClient {
45 public:
46 // Creates an implementation of CastContentBrowserClient. Platform should
47 // link in an implementation as needed.
48 static scoped_ptr<CastContentBrowserClient> Create();
50 ~CastContentBrowserClient() override;
52 // Appends extra command line arguments before launching a new process.
53 virtual void AppendExtraCommandLineSwitches(base::CommandLine* command_line);
55 // Creates and returns the CastService instance for the current process.
56 // Note: |request_context_getter| might be different than the main request
57 // getter accessible via CastBrowserProcess.
58 virtual scoped_ptr<CastService> CreateCastService(
59 content::BrowserContext* browser_context,
60 PrefService* pref_service,
61 net::URLRequestContextGetter* request_context_getter);
63 // Provide an AudioManagerFactory instance for WebAudio playback.
64 virtual scoped_ptr<::media::AudioManagerFactory> CreateAudioManagerFactory();
66 #if !defined(OS_ANDROID)
67 // Creates a CmaMediaPipelineClient which is responsible to create (CMA
68 // backend)
69 // for media playback and watch media pipeline status, called once per media
70 // player
71 // instance.
72 virtual scoped_refptr<media::CmaMediaPipelineClient>
73 CreateCmaMediaPipelineClient();
74 #endif
76 // Performs cleanup for process exit (but before AtExitManager cleanup).
77 void ProcessExiting();
79 // Invoked when the metrics client ID changes.
80 virtual void SetMetricsClientId(const std::string& client_id);
82 // Allows registration of extra metrics providers.
83 virtual void RegisterMetricsProviders(
84 ::metrics::MetricsService* metrics_service);
86 // content::ContentBrowserClient implementation:
87 content::BrowserMainParts* CreateBrowserMainParts(
88 const content::MainFunctionParams& parameters) override;
89 void RenderProcessWillLaunch(content::RenderProcessHost* host) override;
90 net::URLRequestContextGetter* CreateRequestContext(
91 content::BrowserContext* browser_context,
92 content::ProtocolHandlerMap* protocol_handlers,
93 content::URLRequestInterceptorScopedVector request_interceptors)
94 override;
95 bool IsHandledURL(const GURL& url) override;
96 void AppendExtraCommandLineSwitches(base::CommandLine* command_line,
97 int child_process_id) override;
98 content::AccessTokenStore* CreateAccessTokenStore() override;
99 void OverrideWebkitPrefs(content::RenderViewHost* render_view_host,
100 content::WebPreferences* prefs) override;
101 void ResourceDispatcherHostCreated() override;
102 std::string GetApplicationLocale() override;
103 content::QuotaPermissionContext* CreateQuotaPermissionContext() override;
104 void AllowCertificateError(
105 int render_process_id,
106 int render_view_id,
107 int cert_error,
108 const net::SSLInfo& ssl_info,
109 const GURL& request_url,
110 content::ResourceType resource_type,
111 bool overridable,
112 bool strict_enforcement,
113 bool expired_previous_decision,
114 const base::Callback<void(bool)>& callback,
115 content::CertificateRequestResultType* result) override;
116 void SelectClientCertificate(
117 content::WebContents* web_contents,
118 net::SSLCertRequestInfo* cert_request_info,
119 scoped_ptr<content::ClientCertificateDelegate> delegate) override;
120 bool CanCreateWindow(
121 const GURL& opener_url,
122 const GURL& opener_top_level_frame_url,
123 const GURL& source_origin,
124 WindowContainerType container_type,
125 const GURL& target_url,
126 const content::Referrer& referrer,
127 WindowOpenDisposition disposition,
128 const blink::WebWindowFeatures& features,
129 bool user_gesture,
130 bool opener_suppressed,
131 content::ResourceContext* context,
132 int render_process_id,
133 int opener_render_view_id,
134 int opener_render_frame_id,
135 bool* no_javascript_access) override;
136 void RegisterUnsandboxedOutOfProcessMojoApplications(
137 std::map<GURL, base::string16>* apps) override;
138 #if defined(OS_ANDROID)
139 void GetAdditionalMappedFilesForChildProcess(
140 const base::CommandLine& command_line,
141 int child_process_id,
142 content::FileDescriptorInfo* mappings,
143 std::map<int, base::MemoryMappedFile::Region>* regions) override;
144 #else
145 void GetAdditionalMappedFilesForChildProcess(
146 const base::CommandLine& command_line,
147 int child_process_id,
148 content::FileDescriptorInfo* mappings) override;
149 #endif // defined(OS_ANDROID)
150 #if defined(OS_ANDROID) && defined(VIDEO_HOLE)
151 content::ExternalVideoSurfaceContainer*
152 OverrideCreateExternalVideoSurfaceContainer(
153 content::WebContents* web_contents) override;
154 #endif // defined(OS_ANDROID) && defined(VIDEO_HOLE)
156 protected:
157 CastContentBrowserClient();
159 private:
160 void AddNetworkHintsMessageFilter(int render_process_id,
161 net::URLRequestContext* context);
163 net::X509Certificate* SelectClientCertificateOnIOThread(
164 GURL requesting_url,
165 int render_process_id);
167 #if !defined(OS_ANDROID)
168 // Returns the crash signal FD corresponding to the current process type.
169 int GetCrashSignalFD(const base::CommandLine& command_line);
171 // Creates a CrashHandlerHost instance for the given process type.
172 breakpad::CrashHandlerHostLinux* CreateCrashHandlerHost(
173 const std::string& process_type);
175 // A static cache to hold crash_handlers for each process_type
176 std::map<std::string, breakpad::CrashHandlerHostLinux*> crash_handlers_;
177 #endif
179 scoped_ptr<URLRequestContextFactory> url_request_context_factory_;
181 DISALLOW_COPY_AND_ASSIGN(CastContentBrowserClient);
184 } // namespace shell
185 } // namespace chromecast
187 #endif // CHROMECAST_BROWSER_CAST_CONTENT_BROWSER_CLIENT_H_