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

Side by Side Diff: chrome/browser/extensions/active_tab_permission_granter.cc

Issue 2677053004: Convert ActiveTabPermissionGranter to use the new navigation callbacks. (Closed)
Patch Set: Created 3 years, 10 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
« no previous file with comments | « chrome/browser/extensions/active_tab_permission_granter.h ('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/extension_action_runner.h" 7 #include "chrome/browser/extensions/extension_action_runner.h"
8 #include "chrome/browser/profiles/profile.h" 8 #include "chrome/browser/profiles/profile.h"
9 #include "content/public/browser/navigation_details.h"
10 #include "content/public/browser/navigation_entry.h" 9 #include "content/public/browser/navigation_entry.h"
10 #include "content/public/browser/navigation_handle.h"
11 #include "content/public/browser/render_frame_host.h" 11 #include "content/public/browser/render_frame_host.h"
12 #include "content/public/browser/render_process_host.h" 12 #include "content/public/browser/render_process_host.h"
13 #include "content/public/browser/web_contents.h" 13 #include "content/public/browser/web_contents.h"
14 #include "extensions/browser/extension_registry.h" 14 #include "extensions/browser/extension_registry.h"
15 #include "extensions/browser/process_manager.h" 15 #include "extensions/browser/process_manager.h"
16 #include "extensions/common/extension_messages.h" 16 #include "extensions/common/extension_messages.h"
17 #include "extensions/common/feature_switch.h" 17 #include "extensions/common/feature_switch.h"
18 #include "extensions/common/permissions/permission_set.h" 18 #include "extensions/common/permissions/permission_set.h"
19 #include "extensions/common/permissions/permissions_data.h" 19 #include "extensions/common/permissions/permissions_data.h"
20 #include "extensions/common/user_script.h" 20 #include "extensions/common/user_script.h"
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 ExtensionActionRunner::GetForWebContents(web_contents()) 132 ExtensionActionRunner::GetForWebContents(web_contents())
133 ->OnActiveTabPermissionGranted(extension); 133 ->OnActiveTabPermissionGranted(extension);
134 } 134 }
135 } 135 }
136 } 136 }
137 137
138 void ActiveTabPermissionGranter::RevokeForTesting() { 138 void ActiveTabPermissionGranter::RevokeForTesting() {
139 ClearActiveExtensionsAndNotify(); 139 ClearActiveExtensionsAndNotify();
140 } 140 }
141 141
142 void ActiveTabPermissionGranter::DidNavigateMainFrame( 142 void ActiveTabPermissionGranter::DidFinishNavigation(
143 const content::LoadCommittedDetails& details, 143 content::NavigationHandle* navigation_handle) {
144 const content::FrameNavigateParams& params) { 144 if (!navigation_handle->IsInMainFrame() ||
145 if (details.is_in_page) 145 !navigation_handle->HasCommitted() ||
146 navigation_handle->IsSamePage()) {
146 return; 147 return;
147 DCHECK(details.is_main_frame); // important: sub-frames don't get granted! 148 }
Devlin 2017/02/07 02:42:47 Nit: maybe preserve this comment?
jam 2017/02/07 04:17:03 Done.
148 149
149 // Only clear the granted permissions for cross-origin navigations. 150 // Only clear the granted permissions for cross-origin navigations.
150 // 151 //
151 // See http://crbug.com/404243 for why. Currently we only differentiate 152 // See http://crbug.com/404243 for why. Currently we only differentiate
152 // between same-origin and cross-origin navigations when the 153 // between same-origin and cross-origin navigations when the
153 // script-require-action flag is on. It's not clear it's good for general 154 // script-require-action flag is on. It's not clear it's good for general
154 // activeTab consumption (we likely need to build some UI around it first). 155 // activeTab consumption (we likely need to build some UI around it first).
155 // However, the scripts-require-action feature is all-but unusable without 156 // However, the scripts-require-action feature is all-but unusable without
156 // this behaviour. 157 // this behaviour.
157 if (FeatureSwitch::scripts_require_action()->IsEnabled()) { 158 if (FeatureSwitch::scripts_require_action()->IsEnabled()) {
158 const content::NavigationEntry* navigation_entry = 159 const content::NavigationEntry* navigation_entry =
159 web_contents()->GetController().GetVisibleEntry(); 160 web_contents()->GetController().GetVisibleEntry();
160 if (!navigation_entry || (navigation_entry->GetURL().GetOrigin() != 161 if (!navigation_entry ||
161 details.previous_url.GetOrigin())) { 162 (navigation_entry->GetURL().GetOrigin() !=
163 navigation_handle->GetPreviousURL().GetOrigin())) {
162 ClearActiveExtensionsAndNotify(); 164 ClearActiveExtensionsAndNotify();
163 } 165 }
164 } else { 166 } else {
165 ClearActiveExtensionsAndNotify(); 167 ClearActiveExtensionsAndNotify();
166 } 168 }
167 } 169 }
168 170
169 void ActiveTabPermissionGranter::WebContentsDestroyed() { 171 void ActiveTabPermissionGranter::WebContentsDestroyed() {
170 ClearActiveExtensionsAndNotify(); 172 ClearActiveExtensionsAndNotify();
171 } 173 }
(...skipping 27 matching lines...) Expand all
199 CreateMessageFunction clear_message = 201 CreateMessageFunction clear_message =
200 base::Bind(&CreateClearMessage, extension_ids, tab_id_); 202 base::Bind(&CreateClearMessage, extension_ids, tab_id_);
201 SendMessageToProcesses(frame_hosts, 203 SendMessageToProcesses(frame_hosts,
202 web_contents()->GetRenderProcessHost(), 204 web_contents()->GetRenderProcessHost(),
203 clear_message); 205 clear_message);
204 206
205 granted_extensions_.Clear(); 207 granted_extensions_.Clear();
206 } 208 }
207 209
208 } // namespace extensions 210 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/active_tab_permission_granter.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698