OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/renderer/chrome_content_renderer_client.h" | 5 #include "chrome/renderer/chrome_content_renderer_client.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
12 #include "base/path_service.h" | 12 #include "base/path_service.h" |
13 #include "base/string_util.h" | 13 #include "base/string_util.h" |
14 #include "base/strings/string_tokenizer.h" | |
15 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
16 #include "base/values.h" | 15 #include "base/values.h" |
17 #include "chrome/common/child_process_logging.h" | 16 #include "chrome/common/child_process_logging.h" |
18 #include "chrome/common/chrome_content_client.h" | 17 #include "chrome/common/chrome_content_client.h" |
19 #include "chrome/common/chrome_paths.h" | 18 #include "chrome/common/chrome_paths.h" |
20 #include "chrome/common/chrome_switches.h" | 19 #include "chrome/common/chrome_switches.h" |
21 #include "chrome/common/content_settings_pattern.h" | 20 #include "chrome/common/content_settings_pattern.h" |
22 #include "chrome/common/extensions/api/extension_action/page_action_handler.h" | 21 #include "chrome/common/extensions/api/extension_action/page_action_handler.h" |
23 #include "chrome/common/extensions/background_info.h" | 22 #include "chrome/common/extensions/background_info.h" |
24 #include "chrome/common/extensions/csp_handler.h" | 23 #include "chrome/common/extensions/csp_handler.h" |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 // when included in protected resources. | 338 // when included in protected resources. |
340 WebSecurityPolicy::registerURLSchemeAsBypassingContentSecurityPolicy( | 339 WebSecurityPolicy::registerURLSchemeAsBypassingContentSecurityPolicy( |
341 extension_scheme); | 340 extension_scheme); |
342 WebSecurityPolicy::registerURLSchemeAsBypassingContentSecurityPolicy( | 341 WebSecurityPolicy::registerURLSchemeAsBypassingContentSecurityPolicy( |
343 extension_resource_scheme); | 342 extension_resource_scheme); |
344 | 343 |
345 extensions::ChromeAPIPermissions permissions; | 344 extensions::ChromeAPIPermissions permissions; |
346 extensions::PermissionsInfo::GetInstance()->InitializeWithDelegate( | 345 extensions::PermissionsInfo::GetInstance()->InitializeWithDelegate( |
347 permissions); | 346 permissions); |
348 RegisterExtensionManifestHandlers(); | 347 RegisterExtensionManifestHandlers(); |
349 | |
350 RegisterRequestOSFileHandleAllowedHosts( | |
351 command_line->GetSwitchValueASCII( | |
352 switches::kAllowRequestOSFileHandleAPI)); | |
353 } | 348 } |
354 | 349 |
355 void ChromeContentRendererClient::RenderViewCreated( | 350 void ChromeContentRendererClient::RenderViewCreated( |
356 content::RenderView* render_view) { | 351 content::RenderView* render_view) { |
357 ContentSettingsObserver* content_settings = | 352 ContentSettingsObserver* content_settings = |
358 new ContentSettingsObserver(render_view); | 353 new ContentSettingsObserver(render_view); |
359 if (chrome_observer_.get()) { | 354 if (chrome_observer_.get()) { |
360 content_settings->SetContentSettingRules( | 355 content_settings->SetContentSettingRules( |
361 chrome_observer_->content_setting_rules()); | 356 chrome_observer_->content_setting_rules()); |
362 } | 357 } |
(...skipping 833 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1196 return false; | 1191 return false; |
1197 | 1192 |
1198 if (container->element().shadowHost().isNull()) | 1193 if (container->element().shadowHost().isNull()) |
1199 return false; | 1194 return false; |
1200 | 1195 |
1201 WebString tag_name = container->element().shadowHost().tagName(); | 1196 WebString tag_name = container->element().shadowHost().tagName(); |
1202 return tag_name.equals(WebString::fromUTF8(kWebViewTagName)) || | 1197 return tag_name.equals(WebString::fromUTF8(kWebViewTagName)) || |
1203 tag_name.equals(WebString::fromUTF8(kAdViewTagName)); | 1198 tag_name.equals(WebString::fromUTF8(kAdViewTagName)); |
1204 } | 1199 } |
1205 | 1200 |
1206 void ChromeContentRendererClient::RegisterRequestOSFileHandleAllowedHosts( | |
1207 const std::string& allowed_list) { | |
1208 if (!allowed_list.empty()) { | |
1209 base::StringTokenizer t(allowed_list, ","); | |
1210 while (t.GetNext()) { | |
1211 request_os_file_handle_allowed_hosts_.push_back(t.token()); | |
1212 } | |
1213 } | |
1214 } | |
1215 | |
1216 bool ChromeContentRendererClient::IsRequestOSFileHandleAllowedForURL( | |
1217 const GURL& url) const { | |
1218 if (!url.is_valid() || !url.SchemeIsFileSystem() || !url.inner_url()) { | |
1219 return false; | |
1220 } | |
1221 | |
1222 const GURL& inner = *url.inner_url(); | |
1223 if (!inner.is_valid()) | |
1224 return false; | |
1225 | |
1226 if (inner.SchemeIs(extensions::kExtensionScheme)) { | |
1227 // TODO(hamaji): We don't need this whitelist once this issue is | |
1228 // fixed: http://crbug.com/224123 http://crbug.com/224753 | |
1229 if (inner.host() == "dolnidnbiendbodmklboojlnlpdeeipo") | |
1230 return true; | |
1231 } | |
1232 | |
1233 for (size_t i = 0; i < request_os_file_handle_allowed_hosts_.size(); ++i) { | |
1234 if (MatchPattern(inner.host(), request_os_file_handle_allowed_hosts_[i])) | |
1235 return true; | |
1236 } | |
1237 | |
1238 return false; | |
1239 } | |
1240 | |
1241 } // namespace chrome | 1201 } // namespace chrome |
OLD | NEW |