summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/extension_sidebar_api.h
blob: 7ad2a33113b5447094e821a4c507b9110152d32f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_SIDEBAR_API_H_
#define CHROME_BROWSER_EXTENSIONS_EXTENSION_SIDEBAR_API_H_

#include <string>
#include "chrome/browser/extensions/extension_function.h"

class DictionaryValue;
class Profile;
class RenderViewHost;
class TabContents;

namespace extension_sidebar_constants {
extern const char kActiveState[];
extern const char kHiddenState[];
extern const char kShownState[];
}  // namespace extension_sidebar_constants

// Event router class for events related to the sidebar API.
class ExtensionSidebarEventRouter {
 public:
  // Sidebar state changed.
  static void OnStateChanged(
      Profile* profile, TabContents* tab, const std::string& content_id,
      const std::string& state);

 private:
  DISALLOW_COPY_AND_ASSIGN(ExtensionSidebarEventRouter);
};

// Base class for sidebar function APIs.
class SidebarFunction : public SyncExtensionFunction {
 public:
  virtual bool RunImpl();
 private:
  virtual bool RunImpl(TabContents* tab,
                       const std::string& content_id,
                       const DictionaryValue& details) = 0;
};

class CollapseSidebarFunction : public SidebarFunction {
 private:
  virtual bool RunImpl(TabContents* tab,
                       const std::string& content_id,
                       const DictionaryValue& details);
  DECLARE_EXTENSION_FUNCTION_NAME("experimental.sidebar.collapse");
};

class ExpandSidebarFunction : public SidebarFunction {
 private:
  virtual bool RunImpl(TabContents* tab,
                       const std::string& content_id,
                       const DictionaryValue& details);
  DECLARE_EXTENSION_FUNCTION_NAME("experimental.sidebar.expand");
};

class GetStateSidebarFunction : public SidebarFunction {
 private:
  virtual bool RunImpl(TabContents* tab,
                       const std::string& content_id,
                       const DictionaryValue& details);
  DECLARE_EXTENSION_FUNCTION_NAME("experimental.sidebar.getState");
};

class HideSidebarFunction : public SidebarFunction {
 private:
  virtual bool RunImpl(TabContents* tab,
                       const std::string& content_id,
                       const DictionaryValue& details);
  DECLARE_EXTENSION_FUNCTION_NAME("experimental.sidebar.hide");
};

class NavigateSidebarFunction : public SidebarFunction {
 private:
  virtual bool RunImpl(TabContents* tab,
                       const std::string& content_id,
                       const DictionaryValue& details);
  DECLARE_EXTENSION_FUNCTION_NAME("experimental.sidebar.navigate");
};

class SetBadgeTextSidebarFunction : public SidebarFunction {
 private:
  virtual bool RunImpl(TabContents* tab,
                       const std::string& content_id,
                       const DictionaryValue& details);
  DECLARE_EXTENSION_FUNCTION_NAME("experimental.sidebar.setBadgeText");
};

class SetIconSidebarFunction : public SidebarFunction {
 private:
  virtual bool RunImpl(TabContents* tab,
                       const std::string& content_id,
                       const DictionaryValue& details);
  DECLARE_EXTENSION_FUNCTION_NAME("experimental.sidebar.setIcon");
};

class SetTitleSidebarFunction : public SidebarFunction {
 private:
  virtual bool RunImpl(TabContents* tab,
                       const std::string& content_id,
                       const DictionaryValue& details);
  DECLARE_EXTENSION_FUNCTION_NAME("experimental.sidebar.setTitle");
};

class ShowSidebarFunction : public SidebarFunction {
 private:
  virtual bool RunImpl(TabContents* tab,
                       const std::string& content_id,
                       const DictionaryValue& details);
  DECLARE_EXTENSION_FUNCTION_NAME("experimental.sidebar.show");
};

#endif  // CHROME_BROWSER_EXTENSIONS_EXTENSION_SIDEBAR_API_H_