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_ACTION_BOX_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_ACTION_BOX_CONTROLLER_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_ACTION_BOX_CONTROLLER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_ACTION_BOX_CONTROLLER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <set> | |
10 #include <string> | 9 #include <string> |
11 #include <vector> | 10 #include <vector> |
12 | 11 |
13 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
14 | 13 |
15 class ExtensionAction; | 14 class ExtensionAction; |
16 | 15 |
17 namespace extensions { | 16 namespace extensions { |
18 | 17 |
19 // Controller of the "badges" (aka "page actions") in the UI. | 18 // Controller of the "badges" (aka "page actions") in the UI. |
20 class ActionBoxController { | 19 class ActionBoxController { |
21 public: | 20 public: |
| 21 // UI decoration on a page box item. |
| 22 enum Decoration { |
| 23 DECORATION_NONE, |
| 24 }; |
| 25 |
| 26 // Data about a UI badge. |
| 27 struct Data { |
| 28 // The type of decoration that should be applied to the badge. |
| 29 Decoration decoration; |
| 30 |
| 31 // The ExtensionAction that corresponds to the badge. |
| 32 ExtensionAction* action; |
| 33 }; |
| 34 |
| 35 typedef std::vector<Data> DataList; |
| 36 |
22 // The reaction that the UI should take after executing |OnClicked|. | 37 // The reaction that the UI should take after executing |OnClicked|. |
23 enum Action { | 38 enum Action { |
24 ACTION_NONE, | 39 ACTION_NONE, |
25 ACTION_SHOW_POPUP, | 40 ACTION_SHOW_POPUP, |
26 ACTION_SHOW_CONTEXT_MENU, | 41 ACTION_SHOW_CONTEXT_MENU, |
27 }; | 42 }; |
28 | 43 |
29 virtual ~ActionBoxController() {} | 44 virtual ~ActionBoxController() {} |
30 | 45 |
31 // Utility to add any actions to |out| which aren't present in |actions|. | 46 // Gets the badge data for all extensions. |
32 static void AddMissingActions( | 47 virtual scoped_ptr<DataList> GetAllBadgeData() = 0; |
33 const std::set<ExtensionAction*>& actions, | |
34 std::vector<ExtensionAction*>* out); | |
35 | |
36 // Gets the action data for all extensions. | |
37 virtual scoped_ptr<std::vector<ExtensionAction*> > GetCurrentActions() = 0; | |
38 | 48 |
39 // Notifies this that the badge for an extension has been clicked with some | 49 // Notifies this that the badge for an extension has been clicked with some |
40 // mouse button (1 for left, 2 for middle, and 3 for right click), and | 50 // mouse button (1 for left, 2 for middle, and 3 for right click), and |
41 // returns the action that should be taken in response (if any). | 51 // returns the action that should be taken in response (if any). |
42 virtual Action OnClicked(const std::string& extension_id, | 52 virtual Action OnClicked(const std::string& extension_id, |
43 int mouse_button) = 0; | 53 int mouse_button) = 0; |
44 }; | 54 }; |
45 | 55 |
46 } // namespace extensions | 56 } // namespace extensions |
47 | 57 |
48 #endif // CHROME_BROWSER_EXTENSIONS_ACTION_BOX_CONTROLLER_H_ | 58 #endif // CHROME_BROWSER_EXTENSIONS_ACTION_BOX_CONTROLLER_H_ |
OLD | NEW |