Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(535)

Side by Side Diff: chrome/browser/extensions/api/extension_action/extension_actions_api.h

Issue 10231002: Fully merge the implementations of the browserAction and pageAction APIs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_API_EXTENSION_ACTION_EXTENSION_ACTIONS_API_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_EXTENSION_ACTION_EXTENSION_ACTIONS_API_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_EXTENSION_ACTION_EXTENSION_ACTIONS_API_H_ 6 #define CHROME_BROWSER_EXTENSIONS_API_EXTENSION_ACTION_EXTENSION_ACTIONS_API_H_
7 #pragma once 7 #pragma once
8 8
9 #include "chrome/browser/extensions/extension_function.h" 9 #include "chrome/browser/extensions/extension_function.h"
10 #include "chrome/common/extensions/extension_action.h" 10 #include "chrome/common/extensions/extension_action.h"
11 11
12 namespace base { 12 namespace base {
13 class DictionaryValue; 13 class DictionaryValue;
14 } 14 }
15 class TabContentsWrapper;
15 16
16 // Base class for chrome.(browserAction|pageAction).* APIs. 17 // Implementation of both the browserAction and pageAction APIs.
18 //
19 // Divergent behaviour between the two is minimal (pageAction has required
20 // tabIds while browserAction's are optional, they have different internal
21 // browser notification requirements, and not all functions are defined for
22 // both APIs).
17 class ExtensionActionFunction : public SyncExtensionFunction { 23 class ExtensionActionFunction : public SyncExtensionFunction {
18 public: 24 public:
19 static bool ParseCSSColorString(const std::string& color_string, 25 static bool ParseCSSColorString(const std::string& color_string,
20 SkColor* result); 26 SkColor* result);
21 27
22 protected: 28 protected:
23 ExtensionActionFunction(); 29 ExtensionActionFunction();
24 virtual ~ExtensionActionFunction(); 30 virtual ~ExtensionActionFunction();
25 virtual bool RunImpl() OVERRIDE; 31 virtual bool RunImpl() OVERRIDE;
26 virtual bool RunExtensionAction() = 0; 32 virtual bool RunExtensionAction() = 0;
27 bool SetIcon(); 33 void NotifyChange();
28 bool SetTitle(); 34 void NotifyBrowserActionChange();
29 bool SetPopup(); 35 void NotifyPageActionChange();
30 bool SetBadgeBackgroundColor(); 36 bool SetVisible(bool visible);
31 bool SetBadgeText();
32 bool GetTitle();
33 bool GetPopup();
34 bool GetBadgeBackgroundColor();
35 bool GetBadgeText();
36 37
37 // All the browser action APIs take a single argument called details that is 38 // All the extension action APIs take a single argument called details that
38 // a dictionary. 39 // is a dictionary.
39 base::DictionaryValue* details_; 40 base::DictionaryValue* details_;
40 41
41 // The tab id the extension action function should apply to, if any, or 42 // The tab id the extension action function should apply to, if any, or
42 // kDefaultTabId if none was specified. 43 // kDefaultTabId if none was specified.
43 int tab_id_; 44 int tab_id_;
44 45
46 // Tab content for |tab_id_| if one exists.
47 TabContentsWrapper* contents_;
48
45 // The extension action for the current extension. 49 // The extension action for the current extension.
46 ExtensionAction* extension_action_; 50 ExtensionAction* extension_action_;
47 }; 51 };
48 52
53 //
54 // Implementations of each extension action API.
55 //
56 // pageAction and browserAction bindings are created for these by extending them
57 // then declaring an EXTENSION_FUNCTION_NAME.
58 //
59
60 // show
61 class ExtensionActionShowFunction : public ExtensionActionFunction {
62 protected:
63 virtual ~ExtensionActionShowFunction() {}
64 virtual bool RunExtensionAction() OVERRIDE;
65 };
66
67 // hide
68 class ExtensionActionHideFunction : public ExtensionActionFunction {
69 protected:
70 virtual ~ExtensionActionHideFunction() {}
71 virtual bool RunExtensionAction() OVERRIDE;
72 };
73
74 // setIcon
75 class ExtensionActionSetIconFunction : public ExtensionActionFunction {
76 protected:
77 virtual ~ExtensionActionSetIconFunction() {}
78 virtual bool RunExtensionAction() OVERRIDE;
79 };
80
81 // setTitle
82 class ExtensionActionSetTitleFunction : public ExtensionActionFunction {
83 protected:
84 virtual ~ExtensionActionSetTitleFunction() {}
85 virtual bool RunExtensionAction() OVERRIDE;
86 };
87
88 // setPopup
89 class ExtensionActionSetPopupFunction : public ExtensionActionFunction {
90 protected:
91 virtual ~ExtensionActionSetPopupFunction() {}
92 virtual bool RunExtensionAction() OVERRIDE;
93 };
94
95 // setBadgeText
96 class ExtensionActionSetBadgeTextFunction : public ExtensionActionFunction {
97 protected:
98 virtual ~ExtensionActionSetBadgeTextFunction() {}
99 virtual bool RunExtensionAction() OVERRIDE;
100 };
101
102 // setBadgeBackgroundColor
103 class ExtensionActionSetBadgeBackgroundColorFunction
104 : public ExtensionActionFunction {
105 protected:
106 virtual ~ExtensionActionSetBadgeBackgroundColorFunction() {}
107 virtual bool RunExtensionAction() OVERRIDE;
108 };
109
110 // getTitle
111 class ExtensionActionGetTitleFunction : public ExtensionActionFunction {
112 protected:
113 virtual ~ExtensionActionGetTitleFunction() {}
114 virtual bool RunExtensionAction() OVERRIDE;
115 };
116
117 // getPopup
118 class ExtensionActionGetPopupFunction : public ExtensionActionFunction {
119 protected:
120 virtual ~ExtensionActionGetPopupFunction() {}
121 virtual bool RunExtensionAction() OVERRIDE;
122 };
123
124 // getBadgeText
125 class ExtensionActionGetBadgeTextFunction : public ExtensionActionFunction {
126 protected:
127 virtual ~ExtensionActionGetBadgeTextFunction() {}
128 virtual bool RunExtensionAction() OVERRIDE;
129 };
130
131 // getBadgeBackgroundColor
132 class ExtensionActionGetBadgeBackgroundColorFunction
133 : public ExtensionActionFunction {
134 protected:
135 virtual ~ExtensionActionGetBadgeBackgroundColorFunction() {}
136 virtual bool RunExtensionAction() OVERRIDE;
137 };
138
49 #endif // CHROME_BROWSER_EXTENSIONS_API_EXTENSION_ACTION_EXTENSION_ACTIONS_API_ H_ 139 #endif // CHROME_BROWSER_EXTENSIONS_API_EXTENSION_ACTION_EXTENSION_ACTIONS_API_ H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698