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