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

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

Issue 296483011: Run any pending injections in ActiveScriptController if permission is granted (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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/browser/extensions/active_script_controller.cc
diff --git a/chrome/browser/extensions/active_script_controller.cc b/chrome/browser/extensions/active_script_controller.cc
index 2c3c6b7813450221b85f06be4bdfb87b7f11d6cb..20b5ce9ada647909b7f134f5d8b8db28609682f0 100644
--- a/chrome/browser/extensions/active_script_controller.cc
+++ b/chrome/browser/extensions/active_script_controller.cc
@@ -101,6 +101,12 @@ void ActiveScriptController::RequestScriptInjection(
LocationBarController::NotifyChange(web_contents());
}
+void ActiveScriptController::OnActiveTabPermissionGranted(
+ const Extension* extension) {
+ DCHECK(extension);
+ RunPendingForExtension(extension);
+}
+
void ActiveScriptController::OnAdInjectionDetected(
const std::vector<std::string> ad_injectors) {
// We're only interested in data if there are ad injectors detected.
@@ -150,16 +156,31 @@ ExtensionAction* ActiveScriptController::GetActionForExtension(
LocationBarController::Action ActiveScriptController::OnClicked(
const Extension* extension) {
DCHECK(extension);
+ DCHECK(ContainsKey(pending_requests_, extension->id()));
+ RunPendingForExtension(extension);
+ return LocationBarController::ACTION_NONE;
+}
+
+void ActiveScriptController::OnNavigated() {
+ LogUMA();
+ permitted_extensions_.clear();
+ pending_requests_.clear();
+}
+
+void ActiveScriptController::RunPendingForExtension(
+ const Extension* extension) {
+ DCHECK(extension);
not at google - send to devlin 2014/05/22 20:44:49 you already DCHECK the extension at all call sites
Devlin 2014/05/22 22:12:36 Fair enough - maybe I was a bit DCHECK() happy. :)
PendingRequestMap::iterator iter =
pending_requests_.find(extension->id());
- DCHECK(iter != pending_requests_.end());
+ if (iter ==pending_requests_.end())
not at google - send to devlin 2014/05/22 20:44:49 s/ ==/ == /
Devlin 2014/05/22 22:12:36 Done.
+ return;
content::NavigationEntry* visible_entry =
web_contents()->GetController().GetVisibleEntry();
// Refuse to run if there's no visible entry, because we have no idea of
// determining if it's the proper page. This should rarely, if ever, happen.
if (!visible_entry)
- return LocationBarController::ACTION_NONE;
+ return;
int page_id = visible_entry->GetPageID();
@@ -173,6 +194,8 @@ LocationBarController::Action ActiveScriptController::OnClicked(
// Clicking to run the extension counts as granting it permission to run on
// the given tab.
+ // The extension may already have active tab at this point, but granting
+ // it twice is essentially a no-op.
TabHelper::FromWebContents(web_contents())->
active_tab_permission_granter()->GrantIfRequested(extension);
@@ -187,14 +210,6 @@ LocationBarController::Action ActiveScriptController::OnClicked(
// Inform the location bar that the action is now gone.
LocationBarController::NotifyChange(web_contents());
-
- return LocationBarController::ACTION_NONE;
-}
-
-void ActiveScriptController::OnNavigated() {
- LogUMA();
- permitted_extensions_.clear();
- pending_requests_.clear();
}
void ActiveScriptController::OnNotifyExtensionScriptExecution(

Powered by Google App Engine
This is Rietveld 408576698