Chromium Code Reviews| 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..7051974bafd6813d1a3c627119c4f8c59c8ad883 100644 |
| --- a/chrome/browser/extensions/location_bar_controller.h |
| +++ b/chrome/browser/extensions/location_bar_controller.h |
| @@ -5,40 +5,73 @@ |
| #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 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 |
|
not at google - send to devlin
2014/05/08 20:47:09
hey this comment makes sense again!
|
| // 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() {} |
| + 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() { |
|
not at google - send to devlin
2014/05/08 20:47:09
hey if the activity log exposed an observer interf
|
| + return active_script_controller_.get(); |
| + } |
| + |
| + PageActionController* page_action_controller() { |
| + return page_action_controller_.get(); |
| + } |
|
not at google - send to devlin
2014/05/08 20:47:09
if you don't need to expose this, don't. the activ
Devlin
2014/05/08 23:01:00
Done.
|
| + |
| + 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 |