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

Unified Diff: chrome/browser/extensions/location_bar_controller.h

Issue 270153004: Introduce ActiveScriptController; track active extension scripts (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/location_bar_controller.h
diff --git a/chrome/browser/extensions/location_bar_controller.h b/chrome/browser/extensions/location_bar_controller.h
index ee99c443c071fe93131465fa3dc01d3445b55ed6..a8bf3b4699f93fd3455cbaeab518b610010478a3 100644
--- a/chrome/browser/extensions/location_bar_controller.h
+++ b/chrome/browser/extensions/location_bar_controller.h
@@ -5,40 +5,87 @@
#ifndef CHROME_BROWSER_EXTENSIONS_LOCATION_BAR_CONTROLLER_H_
#define CHROME_BROWSER_EXTENSIONS_LOCATION_BAR_CONTROLLER_H_
-#include <set>
-#include <string>
#include <vector>
+#include "base/macros.h"
+#include "base/memory/scoped_ptr.h"
+#include "content/public/browser/web_contents_observer.h"
+
+namespace content {
+class WebContents;
+}
+
class ExtensionAction;
namespace extensions {
+class ActiveScriptController;
+class Extension;
+class PageActionController;
+
// Interface for a class that controls the the extension icons that show up in
// the location bar. Depending on switches, these icons can have differing
// behavior.
-class LocationBarController {
+class LocationBarController : public content::WebContentsObserver {
public:
- // The reaction that the UI should take after executing |OnClicked|.
+ // The action that the UI should take after executing |OnClicked|.
enum Action {
ACTION_NONE,
ACTION_SHOW_POPUP,
ACTION_SHOW_CONTEXT_MENU,
};
- virtual ~LocationBarController() {}
+ class ActionProvider {
+ public:
+ // Returns the action for the given extension, or NULL if there isn't one.
+ virtual ExtensionAction* GetActionForExtension(
+ const Extension* extension) = 0;
+
+ // Handles a click on an extension action.
+ virtual LocationBarController::Action OnClicked(
+ const Extension* extension) = 0;
+
+ // A notification that the WebContents has navigated in the main frame (and
+ // not in page), so any state relating to the current page should likely be
+ // reset.
+ virtual void OnNavigated() = 0;
+ };
+
+ explicit LocationBarController(content::WebContents* web_contents);
+ virtual ~LocationBarController();
+
+ // Returns the actions which should be displayed in the location bar.
+ std::vector<ExtensionAction*> GetCurrentActions();
+
+ // Notifies this that an ExtensionAction has been clicked, and returns the
+ // action which should be taken in response (if any).
+ Action OnClicked(const ExtensionAction* action);
+
+ // Notifies the window that the actions have changed.
+ static void NotifyChange(content::WebContents* web_contents);
+
+ ActiveScriptController* active_script_controller() {
+ return active_script_controller_.get();
+ }
+
+ private:
+ // content::WebContentsObserver implementation.
+ virtual void DidNavigateMainFrame(
+ const content::LoadCommittedDetails& details,
+ const content::FrameNavigateParams& params) OVERRIDE;
- // Gets the action data for all extensions.
- virtual std::vector<ExtensionAction*> GetCurrentActions() const = 0;
+ // The associated WebContents.
+ content::WebContents* web_contents_;
- // Notifies this that the badge for an extension has been clicked with some
- // mouse button (1 for left, 2 for middle, and 3 for right click), and
- // returns the action that should be taken in response (if any).
- // TODO(kalman): make mouse_button an enum.
- virtual Action OnClicked(const std::string& extension_id,
- int mouse_button) = 0;
+ // The controllers for different sources of actions in the location bar.
+ // Currently, this is only page actions and active script actions, so we
+ // explicitly own and create both. If there are ever more, it will be worth
+ // considering making this class own a list of LocationBarControllerProviders
+ // instead.
+ scoped_ptr<ActiveScriptController> active_script_controller_;
+ scoped_ptr<PageActionController> page_action_controller_;
- // Notifies clients that the icons have changed.
- virtual void NotifyChange() = 0;
+ DISALLOW_COPY_AND_ASSIGN(LocationBarController);
};
} // namespace extensions

Powered by Google App Engine
This is Rietveld 408576698