OLD | NEW |
| (Empty) |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_SIDEBAR_API_H_ | |
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_SIDEBAR_API_H_ | |
7 | |
8 #include <string> | |
9 #include "chrome/browser/extensions/extension_function.h" | |
10 | |
11 class Profile; | |
12 class TabContents; | |
13 | |
14 namespace base { | |
15 class DictionaryValue; | |
16 } | |
17 | |
18 namespace extension_sidebar_constants { | |
19 extern const char kActiveState[]; | |
20 extern const char kHiddenState[]; | |
21 extern const char kShownState[]; | |
22 } // namespace extension_sidebar_constants | |
23 | |
24 // Event router class for events related to the sidebar API. | |
25 class ExtensionSidebarEventRouter { | |
26 public: | |
27 // Sidebar state changed. | |
28 static void OnStateChanged( | |
29 Profile* profile, TabContents* tab, const std::string& content_id, | |
30 const std::string& state); | |
31 | |
32 private: | |
33 DISALLOW_COPY_AND_ASSIGN(ExtensionSidebarEventRouter); | |
34 }; | |
35 | |
36 // Base class for sidebar function APIs. | |
37 class SidebarFunction : public SyncExtensionFunction { | |
38 public: | |
39 virtual bool RunImpl() OVERRIDE; | |
40 private: | |
41 virtual bool RunImpl(TabContents* tab, | |
42 const std::string& content_id, | |
43 const base::DictionaryValue& details) = 0; | |
44 }; | |
45 | |
46 class CollapseSidebarFunction : public SidebarFunction { | |
47 private: | |
48 virtual bool RunImpl(TabContents* tab, | |
49 const std::string& content_id, | |
50 const base::DictionaryValue& details) OVERRIDE; | |
51 DECLARE_EXTENSION_FUNCTION_NAME("experimental.sidebar.collapse"); | |
52 }; | |
53 | |
54 class ExpandSidebarFunction : public SidebarFunction { | |
55 private: | |
56 virtual bool RunImpl(TabContents* tab, | |
57 const std::string& content_id, | |
58 const base::DictionaryValue& details) OVERRIDE; | |
59 DECLARE_EXTENSION_FUNCTION_NAME("experimental.sidebar.expand"); | |
60 }; | |
61 | |
62 class GetStateSidebarFunction : public SidebarFunction { | |
63 private: | |
64 virtual bool RunImpl(TabContents* tab, | |
65 const std::string& content_id, | |
66 const base::DictionaryValue& details) OVERRIDE; | |
67 DECLARE_EXTENSION_FUNCTION_NAME("experimental.sidebar.getState"); | |
68 }; | |
69 | |
70 class HideSidebarFunction : public SidebarFunction { | |
71 private: | |
72 virtual bool RunImpl(TabContents* tab, | |
73 const std::string& content_id, | |
74 const base::DictionaryValue& details) OVERRIDE; | |
75 DECLARE_EXTENSION_FUNCTION_NAME("experimental.sidebar.hide"); | |
76 }; | |
77 | |
78 class NavigateSidebarFunction : public SidebarFunction { | |
79 private: | |
80 virtual bool RunImpl(TabContents* tab, | |
81 const std::string& content_id, | |
82 const base::DictionaryValue& details) OVERRIDE; | |
83 DECLARE_EXTENSION_FUNCTION_NAME("experimental.sidebar.navigate"); | |
84 }; | |
85 | |
86 class SetBadgeTextSidebarFunction : public SidebarFunction { | |
87 private: | |
88 virtual bool RunImpl(TabContents* tab, | |
89 const std::string& content_id, | |
90 const base::DictionaryValue& details) OVERRIDE; | |
91 DECLARE_EXTENSION_FUNCTION_NAME("experimental.sidebar.setBadgeText"); | |
92 }; | |
93 | |
94 class SetIconSidebarFunction : public SidebarFunction { | |
95 private: | |
96 virtual bool RunImpl(TabContents* tab, | |
97 const std::string& content_id, | |
98 const base::DictionaryValue& details) OVERRIDE; | |
99 DECLARE_EXTENSION_FUNCTION_NAME("experimental.sidebar.setIcon"); | |
100 }; | |
101 | |
102 class SetTitleSidebarFunction : public SidebarFunction { | |
103 private: | |
104 virtual bool RunImpl(TabContents* tab, | |
105 const std::string& content_id, | |
106 const base::DictionaryValue& details) OVERRIDE; | |
107 DECLARE_EXTENSION_FUNCTION_NAME("experimental.sidebar.setTitle"); | |
108 }; | |
109 | |
110 class ShowSidebarFunction : public SidebarFunction { | |
111 private: | |
112 virtual bool RunImpl(TabContents* tab, | |
113 const std::string& content_id, | |
114 const base::DictionaryValue& details) OVERRIDE; | |
115 DECLARE_EXTENSION_FUNCTION_NAME("experimental.sidebar.show"); | |
116 }; | |
117 | |
118 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SIDEBAR_API_H_ | |
OLD | NEW |