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

Unified Diff: chrome/renderer/content_settings_observer.cc

Issue 1835753002: Reset content settings caches during provisional load start instead of commit. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add another browsertest Created 4 years, 9 months 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 side-by-side diff with in-line comments
Download patch
Index: chrome/renderer/content_settings_observer.cc
diff --git a/chrome/renderer/content_settings_observer.cc b/chrome/renderer/content_settings_observer.cc
index 2e48be56122421ad169c48629000ce9051e82c19..0574d4fb790ed13999c2c5a7b2e40b71899b72bb 100644
--- a/chrome/renderer/content_settings_observer.cc
+++ b/chrome/renderer/content_settings_observer.cc
@@ -8,7 +8,6 @@
#include "base/metrics/histogram.h"
#include "components/content_settings/content/common/content_settings_messages.h"
#include "content/public/common/url_constants.h"
-#include "content/public/renderer/document_state.h"
#include "content/public/renderer/render_frame.h"
#include "content/public/renderer/render_view.h"
#include "third_party/WebKit/public/platform/URLConversion.h"
@@ -39,8 +38,6 @@ using blink::WebSecurityOrigin;
using blink::WebString;
using blink::WebURL;
using blink::WebView;
-using content::DocumentState;
-using content::NavigationState;
namespace {
@@ -233,17 +230,6 @@ void ContentSettingsObserver::DidCommitProvisionalLoad(
WebFrame* frame = render_frame()->GetWebFrame();
if (frame->parent())
return; // Not a top-level navigation.
-
- if (!is_same_page_navigation) {
- // Clear "block" flags for the new page. This needs to happen before any of
- // |allowScript()|, |allowScriptFromSource()|, |allowImage()|, or
- // |allowPlugins()| is called for the new page so that these functions can
- // correctly detect that a piece of content flipped from "not blocked" to
- // "blocked".
- ClearBlockedContentSettings();
- temporarily_allowed_plugins_.clear();
- }
-
GURL url = frame->document().url();
// If we start failing this DCHECK, please makes sure we don't regress
// this bug: http://code.google.com/p/chromium/issues/detail?id=79304
@@ -251,6 +237,20 @@ void ContentSettingsObserver::DidCommitProvisionalLoad(
!url.SchemeIs(url::kDataScheme));
}
+void ContentSettingsObserver::DidStartProvisionalLoad() {
Bernhard Bauer 2016/03/29 08:33:33 Hm... isn't this called when we send out a network
meacer 2016/03/29 18:34:36 It sounds like this would only affect temporarily
+ // Clear "block" flags for the new page. This needs to happen before any of
+ // |allowScript()|, |allowScriptFromSource()|, |allowImage()|, or
+ // |allowPlugins()| is called for the new page so that these functions can
+ // correctly detect that a piece of content flipped from "not blocked" to
+ // "blocked".
+ // This also needs to happen before the document load begins, as parsing the
+ // document can trigger calls to ScriptController::canExecuteScripts.
+ // There is no need to check for same page navigations here as those don't
+ // trigger DidStartProvisionalLoad.
+ ClearBlockedContentSettings();
+ temporarily_allowed_plugins_.clear();
+}
+
bool ContentSettingsObserver::allowDatabase(const WebString& name,
const WebString& display_name,
unsigned long estimated_size) {

Powered by Google App Engine
This is Rietveld 408576698