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