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

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

Issue 527963003: Uncouple ActiveScriptController from LocationBarController (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 e6f0cec5e0fb8c77a5ef533fbe601f9f2e64c48f..31574c9c22493e820bcdc178e795fd8a5848cfd7 100644
--- a/chrome/browser/extensions/active_script_controller.cc
+++ b/chrome/browser/extensions/active_script_controller.cc
@@ -14,7 +14,6 @@
#include "chrome/browser/extensions/extension_action.h"
#include "chrome/browser/extensions/extension_action_manager.h"
#include "chrome/browser/extensions/extension_util.h"
-#include "chrome/browser/extensions/location_bar_controller.h"
#include "chrome/browser/extensions/permissions_updater.h"
#include "chrome/browser/extensions/tab_helper.h"
#include "chrome/browser/profiles/profile.h"
@@ -78,13 +77,7 @@ ActiveScriptController* ActiveScriptController::GetForWebContents(
if (!web_contents)
return NULL;
TabHelper* tab_helper = TabHelper::FromWebContents(web_contents);
- if (!tab_helper)
- return NULL;
- LocationBarController* location_bar_controller =
- tab_helper->location_bar_controller();
- // This should never be NULL.
- DCHECK(location_bar_controller);
- return location_bar_controller->active_script_controller();
+ return tab_helper ? tab_helper->active_script_controller() : NULL;
}
void ActiveScriptController::OnActiveTabPermissionGranted(
@@ -149,29 +142,10 @@ void ActiveScriptController::OnClicked(const Extension* extension) {
RunPendingForExtension(extension);
}
-bool ActiveScriptController::HasActiveScriptAction(const Extension* extension) {
+bool ActiveScriptController::WantsToRun(const Extension* extension) {
return enabled_ && pending_requests_.count(extension->id()) > 0;
}
-ExtensionAction* ActiveScriptController::GetActionForExtension(
- const Extension* extension) {
- if (!enabled_ || pending_requests_.count(extension->id()) == 0)
- return NULL; // No action for this extension.
-
- ActiveScriptMap::iterator existing =
- active_script_actions_.find(extension->id());
- if (existing != active_script_actions_.end())
- return existing->second.get();
-
- linked_ptr<ExtensionAction> action(ExtensionActionManager::Get(
- Profile::FromBrowserContext(web_contents()->GetBrowserContext()))
- ->GetBestFitAction(*extension, ActionInfo::TYPE_PAGE).release());
- action->SetIsVisible(ExtensionAction::kDefaultTabId, true);
-
- active_script_actions_[extension->id()] = action;
- return action.get();
-}
-
PermissionsData::AccessType
ActiveScriptController::RequiresUserConsentForScriptInjection(
const Extension* extension,

Powered by Google App Engine
This is Rietveld 408576698