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