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

Side by Side Diff: chrome/common/extensions/api/extension_action/action_info.cc

Issue 12042096: Move page action manifest parsing out of Extension; the first multi-key manifest handler. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 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 #include "chrome/common/extensions/api/extension_action/action_info.h" 5 #include "chrome/common/extensions/api/extension_action/action_info.h"
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "chrome/common/extensions/api/commands/commands_handler.h"
8 #include "chrome/common/extensions/extension.h" 9 #include "chrome/common/extensions/extension.h"
9 #include "chrome/common/extensions/extension_manifest_constants.h" 10 #include "chrome/common/extensions/extension_manifest_constants.h"
10 11
11 namespace extensions { 12 namespace extensions {
12 13
13 namespace { 14 namespace {
14 15
15 // The manifest data container for the ActionInfos for BrowserActions and 16 // The manifest data container for the ActionInfos for BrowserActions and
16 // ScriptBadges. 17 // ScriptBadges.
17 struct ActionInfoData : public Extension::ManifestData { 18 struct ActionInfoData : public Extension::ManifestData {
(...skipping 24 matching lines...) Expand all
42 } 43 }
43 44
44 ActionInfo::~ActionInfo() { 45 ActionInfo::~ActionInfo() {
45 } 46 }
46 47
47 // static 48 // static
48 const ActionInfo* ActionInfo::GetBrowserActionInfo(const Extension* extension) { 49 const ActionInfo* ActionInfo::GetBrowserActionInfo(const Extension* extension) {
49 return GetActionInfo(extension, extension_manifest_keys::kBrowserAction); 50 return GetActionInfo(extension, extension_manifest_keys::kBrowserAction);
50 } 51 }
51 52
53 const ActionInfo* ActionInfo::GetPageActionInfo(const Extension* extension) {
54 return GetActionInfo(extension, extension_manifest_keys::kPageAction);
55 }
56
52 // static 57 // static
53 const ActionInfo* ActionInfo::GetScriptBadgeInfo(const Extension* extension) { 58 const ActionInfo* ActionInfo::GetScriptBadgeInfo(const Extension* extension) {
54 return GetActionInfo(extension, extension_manifest_keys::kScriptBadge); 59 return GetActionInfo(extension, extension_manifest_keys::kScriptBadge);
55 } 60 }
56 61
57 // static 62 // static
58 const ActionInfo* ActionInfo::GetPageLauncherInfo(const Extension* extension) { 63 const ActionInfo* ActionInfo::GetPageLauncherInfo(const Extension* extension) {
59 return GetActionInfo(extension, extension_manifest_keys::kPageLauncher); 64 return GetActionInfo(extension, extension_manifest_keys::kPageLauncher);
60 } 65 }
61 66
62 // static 67 // static
63 void ActionInfo::SetBrowserActionInfo(Extension* extension, ActionInfo* info) { 68 void ActionInfo::SetBrowserActionInfo(Extension* extension, ActionInfo* info) {
64 extension->SetManifestData(extension_manifest_keys::kBrowserAction, 69 extension->SetManifestData(extension_manifest_keys::kBrowserAction,
65 new ActionInfoData(info)); 70 new ActionInfoData(info));
66 } 71 }
67 72
68 // static 73 // static
74 void ActionInfo::SetPageActionInfo(Extension* extension, ActionInfo* info) {
75 extension->SetManifestData(extension_manifest_keys::kPageAction,
76 new ActionInfoData(info));
77 }
78
79 // static
69 void ActionInfo::SetScriptBadgeInfo(Extension* extension, ActionInfo* info) { 80 void ActionInfo::SetScriptBadgeInfo(Extension* extension, ActionInfo* info) {
70 extension->SetManifestData(extension_manifest_keys::kScriptBadge, 81 extension->SetManifestData(extension_manifest_keys::kScriptBadge,
71 new ActionInfoData(info)); 82 new ActionInfoData(info));
72 } 83 }
73 84
74 // static 85 // static
75 void ActionInfo::SetPageLauncherInfo(Extension* extension, ActionInfo* info) { 86 void ActionInfo::SetPageLauncherInfo(Extension* extension, ActionInfo* info) {
76 extension->SetManifestData(extension_manifest_keys::kPageLauncher, 87 extension->SetManifestData(extension_manifest_keys::kPageLauncher,
77 new ActionInfoData(info)); 88 new ActionInfoData(info));
78 } 89 }
79 90
91 // static
92 bool ActionInfo::IsVerboseInstallMessage(const Extension* extension) {
93 const ActionInfo* page_action_info = GetPageActionInfo(extension);
94 return page_action_info &&
95 (CommandsInfo::GetPageActionCommand(extension) ||
96 !page_action_info->default_icon.empty());
97 }
98
80 } // namespace extensions 99 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698