OLD | NEW |
---|---|
(Empty) | |
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. | |
4 | |
5 #include "chromecast/shell/browser/cast_content_browser_client.h" | |
6 | |
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 "webkit/common/webpreferences.h" | |
18 | |
19 namespace chromecast { | |
20 namespace shell { | |
21 | |
22 CastContentBrowserClient::CastContentBrowserClient() | |
23 : url_request_context_factory_(new URLRequestContextFactory()) { | |
24 } | |
25 | |
26 CastContentBrowserClient::~CastContentBrowserClient() { | |
27 } | |
28 | |
29 content::BrowserMainParts* CastContentBrowserClient::CreateBrowserMainParts( | |
30 const content::MainFunctionParams& parameters) { | |
31 shell_browser_main_parts_.reset( | |
32 new CastBrowserMainParts(parameters, url_request_context_factory_.get())); | |
33 return shell_browser_main_parts_.get(); | |
34 } | |
35 | |
36 void CastContentBrowserClient::RenderProcessWillLaunch( | |
37 content::RenderProcessHost* host) { | |
38 } | |
39 | |
40 net::URLRequestContextGetter* CastContentBrowserClient::CreateRequestContext( | |
41 content::BrowserContext* browser_context, | |
42 content::ProtocolHandlerMap* protocol_handlers, | |
43 content::URLRequestInterceptorScopedVector protocol_interceptors) { | |
44 return url_request_context_factory_->CreateMainGetter(browser_context, | |
45 protocol_handlers); | |
mmenke
2014/07/08 15:43:59
Not passing the interceptors along and hooking the
lcwu1
2014/07/09 02:16:29
Done. Hooked up the interceptors as suggested.
| |
46 } | |
47 | |
48 bool CastContentBrowserClient::IsHandledURL(const GURL& url) { | |
49 if (!url.is_valid()) | |
50 return false; | |
51 | |
52 static const char* const kProtocolList[] = { | |
53 url::kBlobScheme, | |
54 url::kFileSystemScheme, | |
55 content::kChromeUIScheme, | |
56 content::kChromeDevToolsScheme, | |
57 url::kDataScheme, | |
58 }; | |
59 for (size_t i = 0; i < arraysize(kProtocolList); ++i) { | |
60 if (url.scheme() == kProtocolList[i]) | |
mmenke
2014/07/08 15:43:59
optional nit: While this isn't remotely performan
lcwu1
2014/07/09 02:16:29
Done.
| |
61 return true; | |
62 } | |
63 return false; | |
64 } | |
65 | |
66 void CastContentBrowserClient::AppendExtraCommandLineSwitches( | |
67 base::CommandLine* command_line, | |
68 int child_process_id) { | |
69 | |
70 std::string process_type = | |
71 command_line->GetSwitchValueNative(switches::kProcessType); | |
72 // Renderer process comamndline | |
73 if (process_type == switches::kRendererProcess) { | |
74 // Any browser command-line switches that should be propagated to | |
75 // the renderer go here. | |
76 } | |
77 } | |
78 | |
79 content::AccessTokenStore* CastContentBrowserClient::CreateAccessTokenStore() { | |
80 return new CastAccessTokenStore(shell_browser_main_parts_->browser_context()); | |
81 } | |
82 | |
83 void CastContentBrowserClient::OverrideWebkitPrefs( | |
84 content::RenderViewHost* render_view_host, | |
85 const GURL& url, | |
86 WebPreferences* prefs) { | |
87 prefs->allow_scripts_to_close_windows = true; | |
88 // TODO(lcwu): http://crbug.com/391089. This pref is set to true by default | |
89 // because some content providers such as YouTube use plain http requests | |
90 // to retrieve media data chunks while running in a https page. This pref | |
91 // should be disabled once all the content providers are no longer doing that. | |
92 prefs->allow_running_insecure_content = true; | |
93 } | |
94 | |
95 std::string CastContentBrowserClient::GetApplicationLocale() { | |
96 return "en-US"; | |
97 } | |
98 | |
99 void CastContentBrowserClient::AllowCertificateError( | |
100 int render_process_id, | |
101 int render_view_id, | |
102 int cert_error, | |
103 const net::SSLInfo& ssl_info, | |
104 const GURL& request_url, | |
105 content::ResourceType::Type resource_type, | |
106 bool overridable, | |
107 bool strict_enforcement, | |
108 const base::Callback<void(bool)>& callback, | |
109 content::CertificateRequestResultType* result) { | |
110 // Allow developers to override certificate errors. | |
111 // Otherwise, any fatal certificate errors will cause an abort. | |
112 *result = content::CERTIFICATE_REQUEST_RESULT_TYPE_CANCEL; | |
113 return; | |
114 } | |
115 | |
116 bool CastContentBrowserClient::CanCreateWindow( | |
117 const GURL& opener_url, | |
118 const GURL& opener_top_level_frame_url, | |
119 const GURL& source_origin, | |
120 WindowContainerType container_type, | |
121 const GURL& target_url, | |
122 const content::Referrer& referrer, | |
123 WindowOpenDisposition disposition, | |
124 const blink::WebWindowFeatures& features, | |
125 bool user_gesture, | |
126 bool opener_suppressed, | |
127 content::ResourceContext* context, | |
128 int render_process_id, | |
129 int opener_id, | |
130 bool* no_javascript_access) { | |
131 *no_javascript_access = true; | |
132 return false; | |
133 } | |
134 | |
135 void CastContentBrowserClient::GetAdditionalMappedFilesForChildProcess( | |
136 const base::CommandLine& command_line, | |
137 int child_process_id, | |
138 std::vector<content::FileDescriptorInfo>* mappings) { | |
139 } | |
140 | |
141 } // namespace shell | |
142 } // namespace chromecast | |
OLD | NEW |