| OLD | NEW |
| 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 #ifndef CHROME_BROWSER_EXTENSIONS_LOCATION_BAR_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_LOCATION_BAR_CONTROLLER_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_LOCATION_BAR_CONTROLLER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_LOCATION_BAR_CONTROLLER_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 // behavior. | 30 // behavior. |
| 31 class LocationBarController : public content::WebContentsObserver, | 31 class LocationBarController : public content::WebContentsObserver, |
| 32 public ExtensionRegistryObserver { | 32 public ExtensionRegistryObserver { |
| 33 public: | 33 public: |
| 34 class ActionProvider { | 34 class ActionProvider { |
| 35 public: | 35 public: |
| 36 // Returns the action for the given extension, or NULL if there isn't one. | 36 // Returns the action for the given extension, or NULL if there isn't one. |
| 37 virtual ExtensionAction* GetActionForExtension( | 37 virtual ExtensionAction* GetActionForExtension( |
| 38 const Extension* extension) = 0; | 38 const Extension* extension) = 0; |
| 39 | 39 |
| 40 // Handles a click on an extension action. | |
| 41 virtual ExtensionAction::ShowAction OnClicked( | |
| 42 const Extension* extension) = 0; | |
| 43 | |
| 44 // A notification that the WebContents has navigated in the main frame (and | 40 // A notification that the WebContents has navigated in the main frame (and |
| 45 // not in page), so any state relating to the current page should likely be | 41 // not in page), so any state relating to the current page should likely be |
| 46 // reset. | 42 // reset. |
| 47 virtual void OnNavigated() = 0; | 43 virtual void OnNavigated() = 0; |
| 48 | 44 |
| 49 // A notification that the given |extension| has been unloaded, and any | 45 // A notification that the given |extension| has been unloaded, and any |
| 50 // actions associated with it should be removed. | 46 // actions associated with it should be removed. |
| 51 // The location bar controller will update itself after this if needed, so | 47 // The location bar controller will update itself after this if needed, so |
| 52 // Providers should not call NotifyChange(). | 48 // Providers should not call NotifyChange(). |
| 53 virtual void OnExtensionUnloaded(const Extension* extension) {} | 49 virtual void OnExtensionUnloaded(const Extension* extension) {} |
| 54 }; | 50 }; |
| 55 | 51 |
| 56 explicit LocationBarController(content::WebContents* web_contents); | 52 explicit LocationBarController(content::WebContents* web_contents); |
| 57 virtual ~LocationBarController(); | 53 virtual ~LocationBarController(); |
| 58 | 54 |
| 59 // Returns the actions which should be displayed in the location bar. | 55 // Returns the actions which should be displayed in the location bar. |
| 60 std::vector<ExtensionAction*> GetCurrentActions(); | 56 std::vector<ExtensionAction*> GetCurrentActions(); |
| 61 | 57 |
| 62 // Notifies this that an ExtensionAction has been clicked, and returns the | |
| 63 // action which should be taken in response (if any). | |
| 64 ExtensionAction::ShowAction OnClicked(const ExtensionAction* action); | |
| 65 | |
| 66 // Notifies the window that the actions have changed. | 58 // Notifies the window that the actions have changed. |
| 67 static void NotifyChange(content::WebContents* web_contents); | 59 static void NotifyChange(content::WebContents* web_contents); |
| 68 | 60 |
| 69 ActiveScriptController* active_script_controller() { | 61 ActiveScriptController* active_script_controller() { |
| 70 return active_script_controller_.get(); | 62 return active_script_controller_.get(); |
| 71 } | 63 } |
| 72 | 64 |
| 73 private: | 65 private: |
| 74 // content::WebContentsObserver implementation. | 66 // content::WebContentsObserver implementation. |
| 75 virtual void DidNavigateMainFrame( | 67 virtual void DidNavigateMainFrame( |
| (...skipping 19 matching lines...) Expand all Loading... |
| 95 | 87 |
| 96 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> | 88 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> |
| 97 extension_registry_observer_; | 89 extension_registry_observer_; |
| 98 | 90 |
| 99 DISALLOW_COPY_AND_ASSIGN(LocationBarController); | 91 DISALLOW_COPY_AND_ASSIGN(LocationBarController); |
| 100 }; | 92 }; |
| 101 | 93 |
| 102 } // namespace extensions | 94 } // namespace extensions |
| 103 | 95 |
| 104 #endif // CHROME_BROWSER_EXTENSIONS_LOCATION_BAR_CONTROLLER_H_ | 96 #endif // CHROME_BROWSER_EXTENSIONS_LOCATION_BAR_CONTROLLER_H_ |
| OLD | NEW |