Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / common / extensions / api / extension_action / action_info.h
blob09e497c6b93d8bd2a75bebba562a1a1714d2fa3b
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
3 // found in the LICENSE file.
5 #ifndef CHROME_COMMON_EXTENSIONS_API_EXTENSION_ACTION_ACTION_INFO_H_
6 #define CHROME_COMMON_EXTENSIONS_API_EXTENSION_ACTION_ACTION_INFO_H_
8 #include <string>
10 #include "base/strings/string16.h"
11 #include "extensions/common/extension.h"
12 #include "extensions/common/extension_icon_set.h"
13 #include "url/gurl.h"
15 namespace base {
16 class DictionaryValue;
19 namespace extensions {
21 class Extension;
23 struct ActionInfo {
24 ActionInfo();
25 ~ActionInfo();
27 // The types of extension actions.
28 enum Type {
29 TYPE_BROWSER,
30 TYPE_PAGE,
31 TYPE_SYSTEM_INDICATOR,
34 // Loads an ActionInfo from the given DictionaryValue.
35 static scoped_ptr<ActionInfo> Load(const Extension* extension,
36 const base::DictionaryValue* dict,
37 base::string16* error);
39 // Returns the extension's browser action, if any.
40 static const ActionInfo* GetBrowserActionInfo(const Extension* extension);
42 // Returns the extension's page action, if any.
43 static const ActionInfo* GetPageActionInfo(const Extension* extension);
45 // Returns the extension's system indicator, if any.
46 static const ActionInfo* GetSystemIndicatorInfo(const Extension* extension);
48 // Sets the extension's browser action. |extension| takes ownership of |info|.
49 static void SetBrowserActionInfo(Extension* extension, ActionInfo* info);
51 // Sets the extension's page action. |extension| takes ownership of |info|.
52 static void SetPageActionInfo(Extension* extension, ActionInfo* info);
54 // Sets the extension's system indicator. |extension| takes ownership of
55 // |info|.
56 static void SetSystemIndicatorInfo(Extension* extension, ActionInfo* info);
58 // Returns true if the extension needs a verbose install message because
59 // of its page action.
60 static bool IsVerboseInstallMessage(const Extension* extension);
62 // Empty implies the key wasn't present.
63 ExtensionIconSet default_icon;
64 std::string default_title;
65 GURL default_popup_url;
66 // action id -- only used with legacy page actions API.
67 std::string id;
70 } // namespace extensions
72 #endif // CHROME_COMMON_EXTENSIONS_API_EXTENSION_ACTION_ACTION_INFO_H_