| 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/content_settings_observer.h" | 5 #include "chrome/renderer/content_settings_observer.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "chrome/common/chrome_switches.h" | 8 #include "chrome/common/chrome_switches.h" |
| 9 #include "chrome/common/render_messages.h" | 9 #include "chrome/common/render_messages.h" |
| 10 #include "chrome/common/url_constants.h" | 10 #include "chrome/common/url_constants.h" |
| 11 #include "content/public/renderer/document_state.h" | 11 #include "content/public/renderer/document_state.h" |
| 12 #include "content/public/renderer/navigation_state.h" | 12 #include "content/public/renderer/navigation_state.h" |
| 13 #include "content/public/renderer/render_view.h" | 13 #include "content/public/renderer/render_view.h" |
| 14 #include "extensions/common/constants.h" | 14 #include "extensions/common/constants.h" |
| 15 #include "third_party/WebKit/public/platform/WebURL.h" | 15 #include "third_party/WebKit/public/platform/WebURL.h" |
| 16 #include "third_party/WebKit/public/web/WebDataSource.h" | 16 #include "third_party/WebKit/public/web/WebDataSource.h" |
| 17 #include "third_party/WebKit/public/web/WebDocument.h" | 17 #include "third_party/WebKit/public/web/WebDocument.h" |
| 18 #include "third_party/WebKit/public/web/WebFrame.h" | 18 #include "third_party/WebKit/public/web/WebFrame.h" |
| 19 #include "third_party/WebKit/public/web/WebFrameClient.h" | 19 #include "third_party/WebKit/public/web/WebFrameClient.h" |
| 20 #include "third_party/WebKit/public/web/WebSecurityOrigin.h" | 20 #include "third_party/WebKit/public/web/WebSecurityOrigin.h" |
| 21 #include "third_party/WebKit/public/web/WebView.h" | 21 #include "third_party/WebKit/public/web/WebView.h" |
| 22 #include "webkit/child/weburlresponse_extradata_impl.h" | 22 #include "webkit/child/weburlresponse_extradata_impl.h" |
| 23 | 23 |
| 24 using WebKit::WebDataSource; | 24 using blink::WebDataSource; |
| 25 using WebKit::WebFrame; | 25 using blink::WebFrame; |
| 26 using WebKit::WebFrameClient; | 26 using blink::WebFrameClient; |
| 27 using WebKit::WebSecurityOrigin; | 27 using blink::WebSecurityOrigin; |
| 28 using WebKit::WebString; | 28 using blink::WebString; |
| 29 using WebKit::WebURL; | 29 using blink::WebURL; |
| 30 using WebKit::WebView; | 30 using blink::WebView; |
| 31 using content::DocumentState; | 31 using content::DocumentState; |
| 32 using content::NavigationState; | 32 using content::NavigationState; |
| 33 | 33 |
| 34 namespace { | 34 namespace { |
| 35 | 35 |
| 36 GURL GetOriginOrURL(const WebFrame* frame) { | 36 GURL GetOriginOrURL(const WebFrame* frame) { |
| 37 WebString top_origin = frame->top()->document().securityOrigin().toString(); | 37 WebString top_origin = frame->top()->document().securityOrigin().toString(); |
| 38 // The the |top_origin| is unique ("null") e.g., for file:// URLs. Use the | 38 // The the |top_origin| is unique ("null") e.g., for file:// URLs. Use the |
| 39 // document URL as the primary URL in those cases. | 39 // document URL as the primary URL in those cases. |
| 40 if (top_origin == "null") | 40 if (top_origin == "null") |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 } | 247 } |
| 248 allow = allow || IsWhitelistedForContentSettings(frame); | 248 allow = allow || IsWhitelistedForContentSettings(frame); |
| 249 | 249 |
| 250 cached_script_permissions_[frame] = allow; | 250 cached_script_permissions_[frame] = allow; |
| 251 return allow; | 251 return allow; |
| 252 } | 252 } |
| 253 | 253 |
| 254 bool ContentSettingsObserver::AllowScriptFromSource( | 254 bool ContentSettingsObserver::AllowScriptFromSource( |
| 255 WebFrame* frame, | 255 WebFrame* frame, |
| 256 bool enabled_per_settings, | 256 bool enabled_per_settings, |
| 257 const WebKit::WebURL& script_url) { | 257 const blink::WebURL& script_url) { |
| 258 if (!enabled_per_settings) | 258 if (!enabled_per_settings) |
| 259 return false; | 259 return false; |
| 260 if (is_interstitial_page_) | 260 if (is_interstitial_page_) |
| 261 return true; | 261 return true; |
| 262 | 262 |
| 263 bool allow = true; | 263 bool allow = true; |
| 264 if (content_setting_rules_) { | 264 if (content_setting_rules_) { |
| 265 ContentSetting setting = GetContentSettingFromRules( | 265 ContentSetting setting = GetContentSettingFromRules( |
| 266 content_setting_rules_->script_rules, | 266 content_setting_rules_->script_rules, |
| 267 frame, | 267 frame, |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 | 367 |
| 368 // If the scheme is file:, an empty file name indicates a directory listing, | 368 // If the scheme is file:, an empty file name indicates a directory listing, |
| 369 // which requires JavaScript to function properly. | 369 // which requires JavaScript to function properly. |
| 370 if (EqualsASCII(origin.protocol(), chrome::kFileScheme)) { | 370 if (EqualsASCII(origin.protocol(), chrome::kFileScheme)) { |
| 371 return document_url.SchemeIs(chrome::kFileScheme) && | 371 return document_url.SchemeIs(chrome::kFileScheme) && |
| 372 document_url.ExtractFileName().empty(); | 372 document_url.ExtractFileName().empty(); |
| 373 } | 373 } |
| 374 | 374 |
| 375 return false; | 375 return false; |
| 376 } | 376 } |
| OLD | NEW |