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

Unified Diff: chrome/browser/extensions/active_tab_permission_granter.cc

Issue 475333006: Don't clear the activeTab permission for same-origin navigations when the (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comments... fix another test Created 6 years, 4 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
« no previous file with comments | « chrome/browser/extensions/active_script_controller_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/active_tab_permission_granter.cc
diff --git a/chrome/browser/extensions/active_tab_permission_granter.cc b/chrome/browser/extensions/active_tab_permission_granter.cc
index 608eaa171c31549c8176b39df6c3d9ebb9ef7a7e..4a25df9dcc2d8a7b87ff9047217e5a104779c6e2 100644
--- a/chrome/browser/extensions/active_tab_permission_granter.cc
+++ b/chrome/browser/extensions/active_tab_permission_granter.cc
@@ -11,6 +11,7 @@
#include "content/public/browser/web_contents.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/common/extension_messages.h"
+#include "extensions/common/feature_switch.h"
#include "extensions/common/permissions/permission_set.h"
#include "extensions/common/permissions/permissions_data.h"
#include "extensions/common/user_script.h"
@@ -90,7 +91,25 @@ void ActiveTabPermissionGranter::DidNavigateMainFrame(
if (details.is_in_page)
return;
DCHECK(details.is_main_frame); // important: sub-frames don't get granted!
- ClearActiveExtensionsAndNotify();
+
+ // Only clear the granted permissions for cross-origin navigations.
+ //
+ // See http://crbug.com/404243 for why. Currently we only differentiate
+ // between same-origin and cross-origin navigations when the
+ // script-require-action flag is on. It's not clear it's good for general
+ // activeTab consumption (we likely need to build some UI around it first).
+ // However, the scripts-require-action feature is all-but unusable without
+ // this behaviour.
+ if (FeatureSwitch::scripts_require_action()->IsEnabled()) {
+ const content::NavigationEntry* navigation_entry =
+ web_contents()->GetController().GetVisibleEntry();
+ if (!navigation_entry || (navigation_entry->GetURL().GetOrigin() !=
+ details.previous_url.GetOrigin())) {
+ ClearActiveExtensionsAndNotify();
+ }
+ } else {
+ ClearActiveExtensionsAndNotify();
+ }
}
void ActiveTabPermissionGranter::WebContentsDestroyed() {
« no previous file with comments | « chrome/browser/extensions/active_script_controller_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698