OLD | NEW |
---|---|
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_COMMON_EXTENSIONS_API_EXTENSION_ACTION_ACTION_INFO_H_ | 5 #ifndef CHROME_COMMON_EXTENSIONS_API_EXTENSION_ACTION_ACTION_INFO_H_ |
6 #define CHROME_COMMON_EXTENSIONS_API_EXTENSION_ACTION_ACTION_INFO_H_ | 6 #define CHROME_COMMON_EXTENSIONS_API_EXTENSION_ACTION_ACTION_INFO_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/string16.h" | |
10 #include "chrome/common/extensions/extension.h" | 11 #include "chrome/common/extensions/extension.h" |
11 #include "chrome/common/extensions/extension_icon_set.h" | 12 #include "chrome/common/extensions/extension_icon_set.h" |
12 #include "googleurl/src/gurl.h" | 13 #include "googleurl/src/gurl.h" |
13 | 14 |
15 namespace base { | |
16 class DictionaryValue; | |
17 } | |
18 | |
14 namespace extensions { | 19 namespace extensions { |
15 | 20 |
16 class Extension; | 21 class Extension; |
17 | 22 |
18 struct ActionInfo { | 23 struct ActionInfo { |
19 ActionInfo(); | 24 ActionInfo(); |
20 ~ActionInfo(); | 25 ~ActionInfo(); |
21 | 26 |
22 // The types of extension actions. | 27 // The types of extension actions. |
23 enum Type { | 28 enum Type { |
24 TYPE_BROWSER, | 29 TYPE_BROWSER, |
25 TYPE_PAGE, | 30 TYPE_PAGE, |
26 TYPE_SCRIPT_BADGE, | 31 TYPE_SCRIPT_BADGE, |
27 TYPE_SYSTEM_INDICATOR, | 32 TYPE_SYSTEM_INDICATOR, |
28 }; | 33 }; |
29 | 34 |
35 // Loads an ActionInfo from the given DictionaryValue. | |
36 static scoped_ptr<ActionInfo> Load(const Extension* extension, | |
37 const base::DictionaryValue* dict, | |
38 string16* error); | |
39 | |
30 // Returns the extension's browser action, if any. | 40 // Returns the extension's browser action, if any. |
31 static const ActionInfo* GetBrowserActionInfo(const Extension* extension); | 41 static const ActionInfo* GetBrowserActionInfo(const Extension* extension); |
32 | 42 |
33 // Returns the extension's page action, if any. | 43 // Returns the extension's page action, if any. |
34 static const ActionInfo* GetPageActionInfo(const Extension* extension); | 44 static const ActionInfo* GetPageActionInfo(const Extension* extension); |
35 | 45 |
36 // Returns the extension's script badge. | 46 // Returns the extension's script badge. |
37 static const ActionInfo* GetScriptBadgeInfo(const Extension* etxension); | 47 static const ActionInfo* GetScriptBadgeInfo(const Extension* etxension); |
38 | 48 |
39 // Returns the extension's page launcher. | 49 // Returns the extension's page launcher. |
40 static const ActionInfo* GetPageLauncherInfo(const Extension* extension); | 50 static const ActionInfo* GetPageLauncherInfo(const Extension* extension); |
41 | 51 |
52 // Returns the extension's system_indicator, if any. | |
Yoyo Zhou
2013/03/21 00:07:50
_ not necessary.
Devlin
2013/03/23 22:23:08
Done.
| |
53 static const ActionInfo* GetSystemIndicatorInfo(const Extension* extension); | |
54 | |
42 // Sets the extension's browser action. |extension| takes ownership of |info|. | 55 // Sets the extension's browser action. |extension| takes ownership of |info|. |
43 static void SetBrowserActionInfo(Extension* extension, ActionInfo* info); | 56 static void SetBrowserActionInfo(Extension* extension, ActionInfo* info); |
44 | 57 |
45 // Sets the extension's page action. |extension| takes ownership of |info|. | 58 // Sets the extension's page action. |extension| takes ownership of |info|. |
46 static void SetPageActionInfo(Extension* extension, ActionInfo* info); | 59 static void SetPageActionInfo(Extension* extension, ActionInfo* info); |
47 | 60 |
48 // Sets the extension's script badge. |extension| takes ownership of |info|. | 61 // Sets the extension's script badge. |extension| takes ownership of |info|. |
49 static void SetScriptBadgeInfo(Extension* extension, ActionInfo* info); | 62 static void SetScriptBadgeInfo(Extension* extension, ActionInfo* info); |
50 | 63 |
51 // Sets the extension's page launcher. |extension| takes ownership of |info|. | 64 // Sets the extension's page launcher. |extension| takes ownership of |info|. |
52 static void SetPageLauncherInfo(Extension* extension, ActionInfo* info); | 65 static void SetPageLauncherInfo(Extension* extension, ActionInfo* info); |
53 | 66 |
67 // Sets the extension's system indicator. |extension| takes ownership of | |
68 // |info|. | |
69 static void SetSystemIndicatorInfo(Extension* extension, ActionInfo* info); | |
70 | |
54 // Returns true if the extension needs a verbose install message because | 71 // Returns true if the extension needs a verbose install message because |
55 // of its page action. | 72 // of its page action. |
56 static bool IsVerboseInstallMessage(const Extension* extension); | 73 static bool IsVerboseInstallMessage(const Extension* extension); |
57 | 74 |
58 // Empty implies the key wasn't present. | 75 // Empty implies the key wasn't present. |
59 ExtensionIconSet default_icon; | 76 ExtensionIconSet default_icon; |
60 std::string default_title; | 77 std::string default_title; |
61 GURL default_popup_url; | 78 GURL default_popup_url; |
62 // action id -- only used with legacy page actions API. | 79 // action id -- only used with legacy page actions API. |
63 std::string id; | 80 std::string id; |
64 }; | 81 }; |
65 | 82 |
66 } // namespace extensions | 83 } // namespace extensions |
67 | 84 |
68 #endif // CHROME_COMMON_EXTENSIONS_API_EXTENSION_ACTION_ACTION_INFO_H_ | 85 #endif // CHROME_COMMON_EXTENSIONS_API_EXTENSION_ACTION_ACTION_INFO_H_ |
OLD | NEW |