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_
10 #include "base/macros.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "content/public/browser/content_browser_client.h"
15 class CrashHandlerHostLinux
;
19 class BrowserMessageFilter
;
26 namespace chromecast
{
29 class CastBrowserMainParts
;
30 class URLRequestContextFactory
;
32 class CastContentBrowserClient
: public content::ContentBrowserClient
{
34 CastContentBrowserClient();
35 ~CastContentBrowserClient() override
;
37 // Appends extra command line arguments before launching a new process.
38 void PlatformAppendExtraCommandLineSwitches(base::CommandLine
* command_line
);
40 // Returns any BrowserMessageFilters from the platform implementation that
41 // should be added when launching a new render process.
42 std::vector
<scoped_refptr
<content::BrowserMessageFilter
>>
43 PlatformGetBrowserMessageFilters();
45 // content::ContentBrowserClient implementation:
46 content::BrowserMainParts
* CreateBrowserMainParts(
47 const content::MainFunctionParams
& parameters
) override
;
48 void RenderProcessWillLaunch(content::RenderProcessHost
* host
) override
;
49 net::URLRequestContextGetter
* CreateRequestContext(
50 content::BrowserContext
* browser_context
,
51 content::ProtocolHandlerMap
* protocol_handlers
,
52 content::URLRequestInterceptorScopedVector request_interceptors
)
54 bool IsHandledURL(const GURL
& url
) override
;
55 void AppendExtraCommandLineSwitches(base::CommandLine
* command_line
,
56 int child_process_id
) override
;
57 content::AccessTokenStore
* CreateAccessTokenStore() override
;
58 void OverrideWebkitPrefs(content::RenderViewHost
* render_view_host
,
59 content::WebPreferences
* prefs
) override
;
60 void ResourceDispatcherHostCreated() override
;
61 std::string
GetApplicationLocale() override
;
62 content::QuotaPermissionContext
* CreateQuotaPermissionContext() override
;
63 void AllowCertificateError(
64 int render_process_id
,
67 const net::SSLInfo
& ssl_info
,
68 const GURL
& request_url
,
69 content::ResourceType resource_type
,
71 bool strict_enforcement
,
72 bool expired_previous_decision
,
73 const base::Callback
<void(bool)>& callback
,
74 content::CertificateRequestResultType
* result
) override
;
75 void SelectClientCertificate(
76 content::WebContents
* web_contents
,
77 net::SSLCertRequestInfo
* cert_request_info
,
78 scoped_ptr
<content::ClientCertificateDelegate
> delegate
) override
;
80 const GURL
& opener_url
,
81 const GURL
& opener_top_level_frame_url
,
82 const GURL
& source_origin
,
83 WindowContainerType container_type
,
84 const GURL
& target_url
,
85 const content::Referrer
& referrer
,
86 WindowOpenDisposition disposition
,
87 const blink::WebWindowFeatures
& features
,
89 bool opener_suppressed
,
90 content::ResourceContext
* context
,
91 int render_process_id
,
93 bool* no_javascript_access
) override
;
94 void GetAdditionalMappedFilesForChildProcess(
95 const base::CommandLine
& command_line
,
97 content::FileDescriptorInfo
* mappings
) override
;
98 #if defined(OS_ANDROID) && defined(VIDEO_HOLE)
99 content::ExternalVideoSurfaceContainer
*
100 OverrideCreateExternalVideoSurfaceContainer(
101 content::WebContents
* web_contents
) override
;
102 #endif // defined(OS_ANDROID) && defined(VIDEO_HOLE)
105 void AddNetworkHintsMessageFilter(int render_process_id
,
106 net::URLRequestContext
* context
);
108 net::X509Certificate
* SelectClientCertificateOnIOThread(
110 int render_process_id
);
112 #if !defined(OS_ANDROID)
113 // Returns the crash signal FD corresponding to the current process type.
114 int GetCrashSignalFD(const base::CommandLine
& command_line
);
116 // Creates a CrashHandlerHost instance for the given process type.
117 breakpad::CrashHandlerHostLinux
* CreateCrashHandlerHost(
118 const std::string
& process_type
);
120 // A static cache to hold crash_handlers for each process_type
121 std::map
<std::string
, breakpad::CrashHandlerHostLinux
*> crash_handlers_
;
124 base::ScopedFD v8_natives_fd_
;
125 base::ScopedFD v8_snapshot_fd_
;
127 scoped_ptr
<URLRequestContextFactory
> url_request_context_factory_
;
129 DISALLOW_COPY_AND_ASSIGN(CastContentBrowserClient
);
133 } // namespace chromecast
135 #endif // CHROMECAST_BROWSER_CAST_CONTENT_BROWSER_CLIENT_H_