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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/extensions/active_script_controller_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/browser/extensions/active_tab_permission_granter.h" 5 #include "chrome/browser/extensions/active_tab_permission_granter.h"
6 6
7 #include "chrome/browser/extensions/active_script_controller.h" 7 #include "chrome/browser/extensions/active_script_controller.h"
8 #include "chrome/browser/profiles/profile.h" 8 #include "chrome/browser/profiles/profile.h"
9 #include "content/public/browser/navigation_details.h" 9 #include "content/public/browser/navigation_details.h"
10 #include "content/public/browser/navigation_entry.h" 10 #include "content/public/browser/navigation_entry.h"
11 #include "content/public/browser/web_contents.h" 11 #include "content/public/browser/web_contents.h"
12 #include "extensions/browser/extension_registry.h" 12 #include "extensions/browser/extension_registry.h"
13 #include "extensions/common/extension_messages.h" 13 #include "extensions/common/extension_messages.h"
14 #include "extensions/common/feature_switch.h"
14 #include "extensions/common/permissions/permission_set.h" 15 #include "extensions/common/permissions/permission_set.h"
15 #include "extensions/common/permissions/permissions_data.h" 16 #include "extensions/common/permissions/permissions_data.h"
16 #include "extensions/common/user_script.h" 17 #include "extensions/common/user_script.h"
17 #include "url/gurl.h" 18 #include "url/gurl.h"
18 19
19 using content::RenderProcessHost; 20 using content::RenderProcessHost;
20 using content::WebContentsObserver; 21 using content::WebContentsObserver;
21 22
22 namespace extensions { 23 namespace extensions {
23 24
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 } 84 }
84 } 85 }
85 } 86 }
86 87
87 void ActiveTabPermissionGranter::DidNavigateMainFrame( 88 void ActiveTabPermissionGranter::DidNavigateMainFrame(
88 const content::LoadCommittedDetails& details, 89 const content::LoadCommittedDetails& details,
89 const content::FrameNavigateParams& params) { 90 const content::FrameNavigateParams& params) {
90 if (details.is_in_page) 91 if (details.is_in_page)
91 return; 92 return;
92 DCHECK(details.is_main_frame); // important: sub-frames don't get granted! 93 DCHECK(details.is_main_frame); // important: sub-frames don't get granted!
93 ClearActiveExtensionsAndNotify(); 94
95 // Only clear the granted permissions for cross-origin navigations.
96 //
97 // See http://crbug.com/404243 for why. Currently we only differentiate
98 // between same-origin and cross-origin navigations when the
99 // script-require-action flag is on. It's not clear it's good for general
100 // activeTab consumption (we likely need to build some UI around it first).
101 // However, the scripts-require-action feature is all-but unusable without
102 // this behaviour.
103 if (FeatureSwitch::scripts_require_action()->IsEnabled()) {
104 const content::NavigationEntry* navigation_entry =
105 web_contents()->GetController().GetVisibleEntry();
106 if (!navigation_entry || (navigation_entry->GetURL().GetOrigin() !=
107 details.previous_url.GetOrigin())) {
108 ClearActiveExtensionsAndNotify();
109 }
110 } else {
111 ClearActiveExtensionsAndNotify();
112 }
94 } 113 }
95 114
96 void ActiveTabPermissionGranter::WebContentsDestroyed() { 115 void ActiveTabPermissionGranter::WebContentsDestroyed() {
97 ClearActiveExtensionsAndNotify(); 116 ClearActiveExtensionsAndNotify();
98 } 117 }
99 118
100 void ActiveTabPermissionGranter::OnExtensionUnloaded( 119 void ActiveTabPermissionGranter::OnExtensionUnloaded(
101 content::BrowserContext* browser_context, 120 content::BrowserContext* browser_context,
102 const Extension* extension, 121 const Extension* extension,
103 UnloadedExtensionInfo::Reason reason) { 122 UnloadedExtensionInfo::Reason reason) {
(...skipping 12 matching lines...) Expand all
116 it != granted_extensions_.end(); ++it) { 135 it != granted_extensions_.end(); ++it) {
117 it->get()->permissions_data()->ClearTabSpecificPermissions(tab_id_); 136 it->get()->permissions_data()->ClearTabSpecificPermissions(tab_id_);
118 extension_ids.push_back((*it)->id()); 137 extension_ids.push_back((*it)->id());
119 } 138 }
120 139
121 Send(new ExtensionMsg_ClearTabSpecificPermissions(tab_id_, extension_ids)); 140 Send(new ExtensionMsg_ClearTabSpecificPermissions(tab_id_, extension_ids));
122 granted_extensions_.Clear(); 141 granted_extensions_.Clear();
123 } 142 }
124 143
125 } // namespace extensions 144 } // namespace extensions
OLDNEW
« 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