| 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 "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
| 9 #include "components/content_settings/content/common/content_settings_messages.h
" | 9 #include "components/content_settings/content/common/content_settings_messages.h
" |
| 10 #include "content/public/common/url_constants.h" | 10 #include "content/public/common/url_constants.h" |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 | 251 |
| 252 void ContentSettingsObserver::DidCommitProvisionalLoad( | 252 void ContentSettingsObserver::DidCommitProvisionalLoad( |
| 253 bool is_new_navigation, | 253 bool is_new_navigation, |
| 254 bool is_same_page_navigation) { | 254 bool is_same_page_navigation) { |
| 255 WebFrame* frame = render_frame()->GetWebFrame(); | 255 WebFrame* frame = render_frame()->GetWebFrame(); |
| 256 if (frame->parent()) | 256 if (frame->parent()) |
| 257 return; // Not a top-level navigation. | 257 return; // Not a top-level navigation. |
| 258 | 258 |
| 259 if (!is_same_page_navigation) { | 259 if (!is_same_page_navigation) { |
| 260 // Clear "block" flags for the new page. This needs to happen before any of | 260 // Clear "block" flags for the new page. This needs to happen before any of |
| 261 // |allowScript()|, |allowScriptFromSource()|, |allowImage()|, or | 261 // |allowScript()|, |allowScriptFromSource()|, |allowImage()|, |
| 262 // |allowPlugins()| is called for the new page so that these functions can | 262 // |allowPlugins()|, or |allowKeygen()| is called for the new page so that |
| 263 // correctly detect that a piece of content flipped from "not blocked" to | 263 // these functions can correctly detect that a piece of content flipped from |
| 264 // "blocked". | 264 // "not blocked" to "blocked". |
| 265 ClearBlockedContentSettings(); | 265 ClearBlockedContentSettings(); |
| 266 temporarily_allowed_plugins_.clear(); | 266 temporarily_allowed_plugins_.clear(); |
| 267 } | 267 } |
| 268 | 268 |
| 269 GURL url = frame->document().url(); | 269 GURL url = frame->document().url(); |
| 270 // If we start failing this DCHECK, please makes sure we don't regress | 270 // If we start failing this DCHECK, please makes sure we don't regress |
| 271 // this bug: http://code.google.com/p/chromium/issues/detail?id=79304 | 271 // this bug: http://code.google.com/p/chromium/issues/detail?id=79304 |
| 272 DCHECK(frame->document().securityOrigin().toString() == "null" || | 272 DCHECK(frame->document().securityOrigin().toString() == "null" || |
| 273 !url.SchemeIs(url::kDataScheme)); | 273 !url.SchemeIs(url::kDataScheme)); |
| 274 } | 274 } |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 frame->top()->securityOrigin().isUnique()) | 342 frame->top()->securityOrigin().isUnique()) |
| 343 return false; | 343 return false; |
| 344 | 344 |
| 345 bool result = false; | 345 bool result = false; |
| 346 Send(new ChromeViewHostMsg_AllowIndexedDB( | 346 Send(new ChromeViewHostMsg_AllowIndexedDB( |
| 347 routing_id(), GURL(frame->securityOrigin().toString()), | 347 routing_id(), GURL(frame->securityOrigin().toString()), |
| 348 GURL(frame->top()->securityOrigin().toString()), name, &result)); | 348 GURL(frame->top()->securityOrigin().toString()), name, &result)); |
| 349 return result; | 349 return result; |
| 350 } | 350 } |
| 351 | 351 |
| 352 bool ContentSettingsObserver::allowKeygen() { |
| 353 if (is_interstitial_page_) |
| 354 return true; |
| 355 |
| 356 WebFrame* frame = render_frame()->GetWebFrame(); |
| 357 bool allow = false; |
| 358 Send(new ChromeViewHostMsg_AllowKeygen( |
| 359 routing_id(), GURL(frame->securityOrigin().toString()), &allow)); |
| 360 return allow; |
| 361 } |
| 362 |
| 352 bool ContentSettingsObserver::allowPlugins(bool enabled_per_settings) { | 363 bool ContentSettingsObserver::allowPlugins(bool enabled_per_settings) { |
| 353 return enabled_per_settings; | 364 return enabled_per_settings; |
| 354 } | 365 } |
| 355 | 366 |
| 356 bool ContentSettingsObserver::allowScript(bool enabled_per_settings) { | 367 bool ContentSettingsObserver::allowScript(bool enabled_per_settings) { |
| 357 if (!enabled_per_settings) | 368 if (!enabled_per_settings) |
| 358 return false; | 369 return false; |
| 359 if (is_interstitial_page_) | 370 if (is_interstitial_page_) |
| 360 return true; | 371 return true; |
| 361 | 372 |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 586 SendInsecureContentSignal(INSECURE_CONTENT_RUN_SWF); | 597 SendInsecureContentSignal(INSECURE_CONTENT_RUN_SWF); |
| 587 | 598 |
| 588 if (!allow_running_insecure_content_ && !allowed_per_settings) { | 599 if (!allow_running_insecure_content_ && !allowed_per_settings) { |
| 589 DidBlockContentType(CONTENT_SETTINGS_TYPE_MIXEDSCRIPT, origin.host()); | 600 DidBlockContentType(CONTENT_SETTINGS_TYPE_MIXEDSCRIPT, origin.host()); |
| 590 return false; | 601 return false; |
| 591 } | 602 } |
| 592 | 603 |
| 593 return true; | 604 return true; |
| 594 } | 605 } |
| 595 | 606 |
| 607 void ContentSettingsObserver::didNotAllowKeygen() { |
| 608 DidBlockContentType(CONTENT_SETTINGS_TYPE_KEYGEN); |
| 609 } |
| 610 |
| 596 void ContentSettingsObserver::didNotAllowPlugins() { | 611 void ContentSettingsObserver::didNotAllowPlugins() { |
| 597 DidBlockContentType(CONTENT_SETTINGS_TYPE_PLUGINS); | 612 DidBlockContentType(CONTENT_SETTINGS_TYPE_PLUGINS); |
| 598 } | 613 } |
| 599 | 614 |
| 600 void ContentSettingsObserver::didNotAllowScript() { | 615 void ContentSettingsObserver::didNotAllowScript() { |
| 601 DidBlockContentType(CONTENT_SETTINGS_TYPE_JAVASCRIPT); | 616 DidBlockContentType(CONTENT_SETTINGS_TYPE_JAVASCRIPT); |
| 602 } | 617 } |
| 603 | 618 |
| 604 bool ContentSettingsObserver::AreNPAPIPluginsBlocked() const { | 619 bool ContentSettingsObserver::AreNPAPIPluginsBlocked() const { |
| 605 return npapi_plugins_blocked_; | 620 return npapi_plugins_blocked_; |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 724 | 739 |
| 725 // If the scheme is file:, an empty file name indicates a directory listing, | 740 // If the scheme is file:, an empty file name indicates a directory listing, |
| 726 // which requires JavaScript to function properly. | 741 // which requires JavaScript to function properly. |
| 727 if (base::EqualsASCII(protocol, url::kFileScheme)) { | 742 if (base::EqualsASCII(protocol, url::kFileScheme)) { |
| 728 return document_url.SchemeIs(url::kFileScheme) && | 743 return document_url.SchemeIs(url::kFileScheme) && |
| 729 document_url.ExtractFileName().empty(); | 744 document_url.ExtractFileName().empty(); |
| 730 } | 745 } |
| 731 | 746 |
| 732 return false; | 747 return false; |
| 733 } | 748 } |
| OLD | NEW |