| 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_PAGE_ACTION_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_PAGE_ACTION_CONTROLLER_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_PAGE_ACTION_CONTROLLER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_PAGE_ACTION_CONTROLLER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/observer_list.h" | 10 #include "chrome/browser/extensions/location_bar_controller_provider.h" |
| 11 #include "chrome/browser/extensions/location_bar_controller.h" | |
| 12 #include "content/public/browser/web_contents_observer.h" | |
| 13 | 11 |
| 14 class Profile; | 12 class Profile; |
| 15 | 13 |
| 16 namespace extensions { | 14 namespace extensions { |
| 17 class ExtensionRegistry; | 15 class ExtensionRegistry; |
| 18 | 16 |
| 19 // A LocationBarController which populates the location bar with icons based | 17 // A LocationBarController which populates the location bar with icons based |
| 20 // on the page_action extension API. | 18 // on the page_action extension API. |
| 21 class PageActionController : public LocationBarController, | 19 class PageActionController : public LocationBarControllerProvider { |
| 22 public content::WebContentsObserver { | |
| 23 public: | 20 public: |
| 24 explicit PageActionController(content::WebContents* web_contents); | 21 explicit PageActionController(content::WebContents* web_contents); |
| 25 virtual ~PageActionController(); | 22 virtual ~PageActionController(); |
| 26 | 23 |
| 27 // LocationBarController implementation. | 24 // LocationBarController::Provider implementation. |
| 28 virtual std::vector<ExtensionAction*> GetCurrentActions() const OVERRIDE; | 25 virtual ExtensionAction* GetActionForExtension(const Extension* extension) |
| 29 virtual Action OnClicked(const std::string& extension_id, | 26 OVERRIDE; |
| 30 int mouse_button) OVERRIDE; | 27 virtual LocationBarController::Action OnClicked( |
| 31 virtual void NotifyChange() OVERRIDE; | 28 const Extension* extension) OVERRIDE; |
| 32 | 29 virtual void OnNavigated() OVERRIDE; |
| 33 // content::WebContentsObserver implementation. | |
| 34 virtual void DidNavigateMainFrame( | |
| 35 const content::LoadCommittedDetails& details, | |
| 36 const content::FrameNavigateParams& params) OVERRIDE; | |
| 37 | 30 |
| 38 private: | 31 private: |
| 39 // Gets the Profile for the web contents. | 32 // Returns the associated Profile. |
| 40 Profile* GetProfile() const; | 33 Profile* GetProfile(); |
| 41 | 34 |
| 42 // Gets the ExtensionRegistry for the web contents. | 35 // The current page actions for the associated WebContents. |
| 43 ExtensionRegistry* GetExtensionRegistry() const; | 36 std::vector<ExtensionAction*> current_actions_; |
| 37 |
| 38 // The associated WebContents. |
| 39 content::WebContents* web_contents_; |
| 44 | 40 |
| 45 DISALLOW_COPY_AND_ASSIGN(PageActionController); | 41 DISALLOW_COPY_AND_ASSIGN(PageActionController); |
| 46 }; | 42 }; |
| 47 | 43 |
| 48 } // namespace extensions | 44 } // namespace extensions |
| 49 | 45 |
| 50 #endif // CHROME_BROWSER_EXTENSIONS_PAGE_ACTION_CONTROLLER_H_ | 46 #endif // CHROME_BROWSER_EXTENSIONS_PAGE_ACTION_CONTROLLER_H_ |
| OLD | NEW |