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