Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / chromecast / shell / browser / cast_content_browser_client.cc
blob720bbb82de7447cd05f7fc01aec294f7eefd608b
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 #include "chromecast/shell/browser/cast_content_browser_client.h"
7 #include "base/command_line.h"
8 #include "chromecast/shell/browser/cast_browser_context.h"
9 #include "chromecast/shell/browser/cast_browser_main_parts.h"
10 #include "chromecast/shell/browser/geolocation/cast_access_token_store.h"
11 #include "chromecast/shell/browser/url_request_context_factory.h"
12 #include "content/public/browser/certificate_request_result_type.h"
13 #include "content/public/browser/render_process_host.h"
14 #include "content/public/common/content_descriptors.h"
15 #include "content/public/common/content_switches.h"
16 #include "content/public/common/url_constants.h"
17 #include "content/public/common/web_preferences.h"
19 namespace chromecast {
20 namespace shell {
22 CastContentBrowserClient::CastContentBrowserClient()
23 : url_request_context_factory_(new URLRequestContextFactory()) {
26 CastContentBrowserClient::~CastContentBrowserClient() {
29 content::BrowserMainParts* CastContentBrowserClient::CreateBrowserMainParts(
30 const content::MainFunctionParams& parameters) {
31 shell_browser_main_parts_ =
32 new CastBrowserMainParts(parameters, url_request_context_factory_.get());
33 return shell_browser_main_parts_;
36 void CastContentBrowserClient::RenderProcessWillLaunch(
37 content::RenderProcessHost* host) {
40 net::URLRequestContextGetter* CastContentBrowserClient::CreateRequestContext(
41 content::BrowserContext* browser_context,
42 content::ProtocolHandlerMap* protocol_handlers,
43 content::URLRequestInterceptorScopedVector request_interceptors) {
44 return url_request_context_factory_->CreateMainGetter(
45 browser_context,
46 protocol_handlers,
47 request_interceptors.Pass());
50 bool CastContentBrowserClient::IsHandledURL(const GURL& url) {
51 if (!url.is_valid())
52 return false;
54 static const char* const kProtocolList[] = {
55 url::kBlobScheme,
56 url::kFileSystemScheme,
57 content::kChromeUIScheme,
58 content::kChromeDevToolsScheme,
59 url::kDataScheme,
62 const std::string& scheme = url.scheme();
63 for (size_t i = 0; i < arraysize(kProtocolList); ++i) {
64 if (scheme == kProtocolList[i])
65 return true;
67 return false;
70 void CastContentBrowserClient::AppendExtraCommandLineSwitches(
71 base::CommandLine* command_line,
72 int child_process_id) {
74 std::string process_type =
75 command_line->GetSwitchValueNative(switches::kProcessType);
76 // Renderer process comamndline
77 if (process_type == switches::kRendererProcess) {
78 // Any browser command-line switches that should be propagated to
79 // the renderer go here.
83 content::AccessTokenStore* CastContentBrowserClient::CreateAccessTokenStore() {
84 return new CastAccessTokenStore(shell_browser_main_parts_->browser_context());
87 void CastContentBrowserClient::OverrideWebkitPrefs(
88 content::RenderViewHost* render_view_host,
89 const GURL& url,
90 content::WebPreferences* prefs) {
91 prefs->allow_scripts_to_close_windows = true;
92 // TODO(lcwu): http://crbug.com/391089. This pref is set to true by default
93 // because some content providers such as YouTube use plain http requests
94 // to retrieve media data chunks while running in a https page. This pref
95 // should be disabled once all the content providers are no longer doing that.
96 prefs->allow_running_insecure_content = true;
99 std::string CastContentBrowserClient::GetApplicationLocale() {
100 return "en-US";
103 void CastContentBrowserClient::AllowCertificateError(
104 int render_process_id,
105 int render_view_id,
106 int cert_error,
107 const net::SSLInfo& ssl_info,
108 const GURL& request_url,
109 content::ResourceType resource_type,
110 bool overridable,
111 bool strict_enforcement,
112 bool expired_previous_decision,
113 const base::Callback<void(bool)>& callback,
114 content::CertificateRequestResultType* result) {
115 // Allow developers to override certificate errors.
116 // Otherwise, any fatal certificate errors will cause an abort.
117 *result = content::CERTIFICATE_REQUEST_RESULT_TYPE_CANCEL;
118 return;
121 bool CastContentBrowserClient::CanCreateWindow(
122 const GURL& opener_url,
123 const GURL& opener_top_level_frame_url,
124 const GURL& source_origin,
125 WindowContainerType container_type,
126 const GURL& target_url,
127 const content::Referrer& referrer,
128 WindowOpenDisposition disposition,
129 const blink::WebWindowFeatures& features,
130 bool user_gesture,
131 bool opener_suppressed,
132 content::ResourceContext* context,
133 int render_process_id,
134 int opener_id,
135 bool* no_javascript_access) {
136 *no_javascript_access = true;
137 return false;
140 void CastContentBrowserClient::GetAdditionalMappedFilesForChildProcess(
141 const base::CommandLine& command_line,
142 int child_process_id,
143 std::vector<content::FileDescriptorInfo>* mappings) {
146 } // namespace shell
147 } // namespace chromecast