Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(167)

Side by Side Diff: chrome/renderer/content_settings_observer.cc

Issue 1417033010: Adding <keygen> Content Setting (Blink) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@keygen_core
Patch Set: Fixing profile_io_data use in chrome_render_message_filter Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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 std::map<WebFrame*, bool>::const_iterator it =
358 cached_keygen_permissions_.find(frame);
359 if (it != cached_keygen_permissions_.end())
jochen (gone - plz use gerrit) 2015/11/07 05:53:29 do you expect that this happens so often that it's
svaldez 2015/11/10 15:23:41 Done.
360 return it->second;
361
362 bool allow = false;
363 Send(new ChromeViewHostMsg_AllowKeygen(
364 routing_id(), GURL(frame->securityOrigin().toString()), &allow));
365 cached_keygen_permissions_[frame] = allow;
366 return allow;
367 }
368
352 bool ContentSettingsObserver::allowPlugins(bool enabled_per_settings) { 369 bool ContentSettingsObserver::allowPlugins(bool enabled_per_settings) {
353 return enabled_per_settings; 370 return enabled_per_settings;
354 } 371 }
355 372
356 bool ContentSettingsObserver::allowScript(bool enabled_per_settings) { 373 bool ContentSettingsObserver::allowScript(bool enabled_per_settings) {
357 if (!enabled_per_settings) 374 if (!enabled_per_settings)
358 return false; 375 return false;
359 if (is_interstitial_page_) 376 if (is_interstitial_page_)
360 return true; 377 return true;
361 378
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 SendInsecureContentSignal(INSECURE_CONTENT_RUN_SWF); 603 SendInsecureContentSignal(INSECURE_CONTENT_RUN_SWF);
587 604
588 if (!allow_running_insecure_content_ && !allowed_per_settings) { 605 if (!allow_running_insecure_content_ && !allowed_per_settings) {
589 DidBlockContentType(CONTENT_SETTINGS_TYPE_MIXEDSCRIPT, origin.host()); 606 DidBlockContentType(CONTENT_SETTINGS_TYPE_MIXEDSCRIPT, origin.host());
590 return false; 607 return false;
591 } 608 }
592 609
593 return true; 610 return true;
594 } 611 }
595 612
613 void ContentSettingsObserver::didNotAllowKeygen() {
614 DidBlockContentType(CONTENT_SETTINGS_TYPE_KEYGEN);
615 }
616
596 void ContentSettingsObserver::didNotAllowPlugins() { 617 void ContentSettingsObserver::didNotAllowPlugins() {
597 DidBlockContentType(CONTENT_SETTINGS_TYPE_PLUGINS); 618 DidBlockContentType(CONTENT_SETTINGS_TYPE_PLUGINS);
598 } 619 }
599 620
600 void ContentSettingsObserver::didNotAllowScript() { 621 void ContentSettingsObserver::didNotAllowScript() {
601 DidBlockContentType(CONTENT_SETTINGS_TYPE_JAVASCRIPT); 622 DidBlockContentType(CONTENT_SETTINGS_TYPE_JAVASCRIPT);
602 } 623 }
603 624
604 bool ContentSettingsObserver::AreNPAPIPluginsBlocked() const { 625 bool ContentSettingsObserver::AreNPAPIPluginsBlocked() const {
605 return npapi_plugins_blocked_; 626 return npapi_plugins_blocked_;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
647 callbacks.doAllow(); 668 callbacks.doAllow();
648 return; 669 return;
649 } 670 }
650 callbacks.doDeny(); 671 callbacks.doDeny();
651 } 672 }
652 673
653 void ContentSettingsObserver::ClearBlockedContentSettings() { 674 void ContentSettingsObserver::ClearBlockedContentSettings() {
654 content_blocked_.clear(); 675 content_blocked_.clear();
655 cached_storage_permissions_.clear(); 676 cached_storage_permissions_.clear();
656 cached_script_permissions_.clear(); 677 cached_script_permissions_.clear();
678 cached_keygen_permissions_.clear();
657 } 679 }
658 680
659 bool ContentSettingsObserver::IsPlatformApp() { 681 bool ContentSettingsObserver::IsPlatformApp() {
660 #if defined(ENABLE_EXTENSIONS) 682 #if defined(ENABLE_EXTENSIONS)
661 WebFrame* frame = render_frame()->GetWebFrame(); 683 WebFrame* frame = render_frame()->GetWebFrame();
662 WebSecurityOrigin origin = frame->document().securityOrigin(); 684 WebSecurityOrigin origin = frame->document().securityOrigin();
663 const extensions::Extension* extension = GetExtension(origin); 685 const extensions::Extension* extension = GetExtension(origin);
664 return extension && extension->is_platform_app(); 686 return extension && extension->is_platform_app();
665 #else 687 #else
666 return false; 688 return false;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
724 746
725 // If the scheme is file:, an empty file name indicates a directory listing, 747 // If the scheme is file:, an empty file name indicates a directory listing,
726 // which requires JavaScript to function properly. 748 // which requires JavaScript to function properly.
727 if (base::EqualsASCII(protocol, url::kFileScheme)) { 749 if (base::EqualsASCII(protocol, url::kFileScheme)) {
728 return document_url.SchemeIs(url::kFileScheme) && 750 return document_url.SchemeIs(url::kFileScheme) &&
729 document_url.ExtractFileName().empty(); 751 document_url.ExtractFileName().empty();
730 } 752 }
731 753
732 return false; 754 return false;
733 } 755 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698