| 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 content { | |
| 19 class WebContents; | |
| 20 } | |
| 21 | |
| 22 namespace extension_sidebar_constants { | |
| 23 extern const char kActiveState[]; | |
| 24 extern const char kHiddenState[]; | |
| 25 extern const char kShownState[]; | |
| 26 } // namespace extension_sidebar_constants | |
| 27 | |
| 28 // Event router class for events related to the sidebar API. | |
| 29 class ExtensionSidebarEventRouter { | |
| 30 public: | |
| 31 // Sidebar state changed. | |
| 32 static void OnStateChanged( | |
| 33 Profile* profile, content::WebContents* tab, | |
| 34 const std::string& content_id, const std::string& state); | |
| 35 | |
| 36 private: | |
| 37 DISALLOW_COPY_AND_ASSIGN(ExtensionSidebarEventRouter); | |
| 38 }; | |
| 39 | |
| 40 // Base class for sidebar function APIs. | |
| 41 class SidebarFunction : public SyncExtensionFunction { | |
| 42 public: | |
| 43 virtual bool RunImpl() OVERRIDE; | |
| 44 private: | |
| 45 virtual bool RunImpl(TabContents* tab, | |
| 46 const std::string& content_id, | |
| 47 const base::DictionaryValue& details) = 0; | |
| 48 }; | |
| 49 | |
| 50 class CollapseSidebarFunction : public SidebarFunction { | |
| 51 private: | |
| 52 virtual bool RunImpl(TabContents* tab, | |
| 53 const std::string& content_id, | |
| 54 const base::DictionaryValue& details) OVERRIDE; | |
| 55 DECLARE_EXTENSION_FUNCTION_NAME("experimental.sidebar.collapse"); | |
| 56 }; | |
| 57 | |
| 58 class ExpandSidebarFunction : public SidebarFunction { | |
| 59 private: | |
| 60 virtual bool RunImpl(TabContents* tab, | |
| 61 const std::string& content_id, | |
| 62 const base::DictionaryValue& details) OVERRIDE; | |
| 63 DECLARE_EXTENSION_FUNCTION_NAME("experimental.sidebar.expand"); | |
| 64 }; | |
| 65 | |
| 66 class GetStateSidebarFunction : public SidebarFunction { | |
| 67 private: | |
| 68 virtual bool RunImpl(TabContents* tab, | |
| 69 const std::string& content_id, | |
| 70 const base::DictionaryValue& details) OVERRIDE; | |
| 71 DECLARE_EXTENSION_FUNCTION_NAME("experimental.sidebar.getState"); | |
| 72 }; | |
| 73 | |
| 74 class HideSidebarFunction : public SidebarFunction { | |
| 75 private: | |
| 76 virtual bool RunImpl(TabContents* tab, | |
| 77 const std::string& content_id, | |
| 78 const base::DictionaryValue& details) OVERRIDE; | |
| 79 DECLARE_EXTENSION_FUNCTION_NAME("experimental.sidebar.hide"); | |
| 80 }; | |
| 81 | |
| 82 class NavigateSidebarFunction : public SidebarFunction { | |
| 83 private: | |
| 84 virtual bool RunImpl(TabContents* tab, | |
| 85 const std::string& content_id, | |
| 86 const base::DictionaryValue& details) OVERRIDE; | |
| 87 DECLARE_EXTENSION_FUNCTION_NAME("experimental.sidebar.navigate"); | |
| 88 }; | |
| 89 | |
| 90 class SetBadgeTextSidebarFunction : public SidebarFunction { | |
| 91 private: | |
| 92 virtual bool RunImpl(TabContents* tab, | |
| 93 const std::string& content_id, | |
| 94 const base::DictionaryValue& details) OVERRIDE; | |
| 95 DECLARE_EXTENSION_FUNCTION_NAME("experimental.sidebar.setBadgeText"); | |
| 96 }; | |
| 97 | |
| 98 class SetIconSidebarFunction : public SidebarFunction { | |
| 99 private: | |
| 100 virtual bool RunImpl(TabContents* tab, | |
| 101 const std::string& content_id, | |
| 102 const base::DictionaryValue& details) OVERRIDE; | |
| 103 DECLARE_EXTENSION_FUNCTION_NAME("experimental.sidebar.setIcon"); | |
| 104 }; | |
| 105 | |
| 106 class SetTitleSidebarFunction : public SidebarFunction { | |
| 107 private: | |
| 108 virtual bool RunImpl(TabContents* tab, | |
| 109 const std::string& content_id, | |
| 110 const base::DictionaryValue& details) OVERRIDE; | |
| 111 DECLARE_EXTENSION_FUNCTION_NAME("experimental.sidebar.setTitle"); | |
| 112 }; | |
| 113 | |
| 114 class ShowSidebarFunction : public SidebarFunction { | |
| 115 private: | |
| 116 virtual bool RunImpl(TabContents* tab, | |
| 117 const std::string& content_id, | |
| 118 const base::DictionaryValue& details) OVERRIDE; | |
| 119 DECLARE_EXTENSION_FUNCTION_NAME("experimental.sidebar.show"); | |
| 120 }; | |
| 121 | |
| 122 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SIDEBAR_API_H_ | |
| OLD | NEW |