| 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 "chrome/common/render_messages.h" | 7 #include "chrome/common/render_messages.h" |
| 8 #include "chrome/common/ssl_insecure_content.h" | 8 #include "chrome/common/ssl_insecure_content.h" |
| 9 #include "content/public/common/url_constants.h" | 9 #include "content/public/common/url_constants.h" |
| 10 #include "content/public/renderer/document_state.h" | 10 #include "content/public/renderer/document_state.h" |
| (...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 399 } | 399 } |
| 400 | 400 |
| 401 bool ContentSettingsObserver::allowMutationEvents(bool default_value) { | 401 bool ContentSettingsObserver::allowMutationEvents(bool default_value) { |
| 402 return IsPlatformApp() ? false : default_value; | 402 return IsPlatformApp() ? false : default_value; |
| 403 } | 403 } |
| 404 | 404 |
| 405 bool ContentSettingsObserver::allowRunningInsecureContent( | 405 bool ContentSettingsObserver::allowRunningInsecureContent( |
| 406 bool allowed_per_settings, | 406 bool allowed_per_settings, |
| 407 const blink::WebSecurityOrigin& origin, | 407 const blink::WebSecurityOrigin& origin, |
| 408 const blink::WebURL& resource_url) { | 408 const blink::WebURL& resource_url) { |
| 409 // Note: this implementation is a mirror of |
| 410 // Browser::ShouldAllowRunningInsecureContent. |
| 409 FilteredReportInsecureContentRan(GURL(resource_url)); | 411 FilteredReportInsecureContentRan(GURL(resource_url)); |
| 410 | 412 |
| 411 if (!allow_running_insecure_content_ && !allowed_per_settings) { | 413 if (!allow_running_insecure_content_ && !allowed_per_settings) { |
| 412 DidBlockContentType(CONTENT_SETTINGS_TYPE_MIXEDSCRIPT); | 414 DidBlockContentType(CONTENT_SETTINGS_TYPE_MIXEDSCRIPT); |
| 413 return false; | 415 return false; |
| 414 } | 416 } |
| 415 | 417 |
| 416 return true; | 418 return true; |
| 417 } | 419 } |
| 418 | 420 |
| 419 bool ContentSettingsObserver::allowAutoplay(bool default_value) { | 421 bool ContentSettingsObserver::allowAutoplay(bool default_value) { |
| 420 if (!content_setting_rules_) | 422 if (!content_setting_rules_) |
| 421 return default_value; | 423 return default_value; |
| 422 | 424 |
| 423 WebFrame* frame = render_frame()->GetWebFrame(); | 425 WebFrame* frame = render_frame()->GetWebFrame(); |
| 424 return GetContentSettingFromRules( | 426 return GetContentSettingFromRules( |
| 425 content_setting_rules_->autoplay_rules, frame, | 427 content_setting_rules_->autoplay_rules, frame, |
| 426 url::Origin(frame->document().getSecurityOrigin()).GetURL()) == | 428 url::Origin(frame->document().getSecurityOrigin()).GetURL()) == |
| 427 CONTENT_SETTING_ALLOW; | 429 CONTENT_SETTING_ALLOW; |
| 428 } | 430 } |
| 429 | 431 |
| 430 void ContentSettingsObserver::passiveInsecureContentFound( | 432 void ContentSettingsObserver::passiveInsecureContentFound( |
| 431 const blink::WebURL& resource_url) { | 433 const blink::WebURL& resource_url) { |
| 434 // Note: this implementation is a mirror of |
| 435 // Browser::PassiveInsecureContentFound. |
| 432 ReportInsecureContent(SslInsecureContentType::DISPLAY); | 436 ReportInsecureContent(SslInsecureContentType::DISPLAY); |
| 433 FilteredReportInsecureContentDisplayed(GURL(resource_url)); | 437 FilteredReportInsecureContentDisplayed(GURL(resource_url)); |
| 434 } | 438 } |
| 435 | 439 |
| 436 void ContentSettingsObserver::didNotAllowPlugins() { | 440 void ContentSettingsObserver::didNotAllowPlugins() { |
| 437 DidBlockContentType(CONTENT_SETTINGS_TYPE_PLUGINS); | 441 DidBlockContentType(CONTENT_SETTINGS_TYPE_PLUGINS); |
| 438 } | 442 } |
| 439 | 443 |
| 440 void ContentSettingsObserver::didNotAllowScript() { | 444 void ContentSettingsObserver::didNotAllowScript() { |
| 441 DidBlockContentType(CONTENT_SETTINGS_TYPE_JAVASCRIPT); | 445 DidBlockContentType(CONTENT_SETTINGS_TYPE_JAVASCRIPT); |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 535 #endif | 539 #endif |
| 536 | 540 |
| 537 // If the scheme is file:, an empty file name indicates a directory listing, | 541 // If the scheme is file:, an empty file name indicates a directory listing, |
| 538 // which requires JavaScript to function properly. | 542 // which requires JavaScript to function properly. |
| 539 if (protocol == url::kFileScheme && | 543 if (protocol == url::kFileScheme && |
| 540 document_url.protocolIs(url::kFileScheme)) { | 544 document_url.protocolIs(url::kFileScheme)) { |
| 541 return GURL(document_url).ExtractFileName().empty(); | 545 return GURL(document_url).ExtractFileName().empty(); |
| 542 } | 546 } |
| 543 return false; | 547 return false; |
| 544 } | 548 } |
| OLD | NEW |