| 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 <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/observer_list.h" | 11 #include "base/observer_list.h" |
| 12 #include "chrome/browser/extensions/location_bar_controller.h" | 12 #include "chrome/browser/extensions/location_bar_controller.h" |
| 13 #include "content/public/browser/web_contents_observer.h" | 13 #include "content/public/browser/web_contents_observer.h" |
| 14 | 14 |
| 15 class ExtensionService; | 15 class ExtensionService; |
| 16 class TabContents; | 16 class TabContents; |
| 17 | 17 |
| 18 namespace extensions { | 18 namespace extensions { |
| 19 | 19 |
| 20 // A LocationBarController which populates the location bar with icons based | 20 // A LocationBarController which populates the location bar with icons based |
| 21 // on the page_action extension API. | 21 // on the page_action extension API. |
| 22 class PageActionController : public LocationBarController, | 22 class PageActionController : public LocationBarController, |
| 23 public content::WebContentsObserver { | 23 public content::WebContentsObserver { |
| 24 public: | 24 public: |
| 25 explicit PageActionController(TabContents* tab_contents); | 25 explicit PageActionController(TabContents* tab_contents); |
| 26 virtual ~PageActionController(); | 26 virtual ~PageActionController(); |
| 27 | 27 |
| 28 // LocationBarController implementation. | 28 // LocationBarController implementation. |
| 29 virtual std::vector<ExtensionAction*> GetCurrentActions() const OVERRIDE; | 29 virtual std::vector<ExtensionAction*> GetCurrentActions() const OVERRIDE; |
| 30 // Page actions can't try to get attention. |
| 31 virtual void GetAttentionFor(const std::string& extension_id) OVERRIDE {} |
| 30 virtual Action OnClicked(const std::string& extension_id, | 32 virtual Action OnClicked(const std::string& extension_id, |
| 31 int mouse_button) OVERRIDE; | 33 int mouse_button) OVERRIDE; |
| 32 virtual void NotifyChange() OVERRIDE; | 34 virtual void NotifyChange() OVERRIDE; |
| 33 | 35 |
| 34 // content::WebContentsObserver implementation. | 36 // content::WebContentsObserver implementation. |
| 35 virtual void DidNavigateMainFrame( | 37 virtual void DidNavigateMainFrame( |
| 36 const content::LoadCommittedDetails& details, | 38 const content::LoadCommittedDetails& details, |
| 37 const content::FrameNavigateParams& params) OVERRIDE; | 39 const content::FrameNavigateParams& params) OVERRIDE; |
| 38 | 40 |
| 39 private: | 41 private: |
| 40 // Gets the ExtensionService for |tab_contents_|. | 42 // Gets the ExtensionService for |tab_contents_|. |
| 41 ExtensionService* GetExtensionService() const; | 43 ExtensionService* GetExtensionService() const; |
| 42 | 44 |
| 43 TabContents* tab_contents_; | 45 TabContents* tab_contents_; |
| 44 | 46 |
| 45 DISALLOW_COPY_AND_ASSIGN(PageActionController); | 47 DISALLOW_COPY_AND_ASSIGN(PageActionController); |
| 46 }; | 48 }; |
| 47 | 49 |
| 48 } // namespace extensions | 50 } // namespace extensions |
| 49 | 51 |
| 50 #endif // CHROME_BROWSER_EXTENSIONS_PAGE_ACTION_CONTROLLER_H_ | 52 #endif // CHROME_BROWSER_EXTENSIONS_PAGE_ACTION_CONTROLLER_H_ |
| OLD | NEW |