OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 5 #include "chrome/common/extensions/api/extension_action/action_info.h" |
| 6 |
| 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "chrome/common/extensions/extension.h" |
| 9 #include "chrome/common/extensions/extension_manifest_constants.h" |
| 10 |
| 11 namespace extensions { |
| 12 |
| 13 namespace { |
| 14 |
| 15 // The manifest data container for the ActionInfos for BrowserActions and |
| 16 // ScriptBadges. |
| 17 struct ActionInfoData : public Extension::ManifestData { |
| 18 explicit ActionInfoData(ActionInfo* action_info); |
| 19 virtual ~ActionInfoData(); |
| 20 |
| 21 // The action associated with the BrowserAction or ScriptBadge. |
| 22 // This is never NULL for ScriptBadge. |
| 23 scoped_ptr<ActionInfo> action_info; |
| 24 }; |
| 25 |
| 26 ActionInfoData::ActionInfoData(ActionInfo* info) : action_info(info) { |
| 27 } |
| 28 |
| 29 ActionInfoData::~ActionInfoData() { |
| 30 } |
| 31 |
| 32 } // namespace |
| 33 |
| 34 ActionInfo::ActionInfo() { |
| 35 } |
| 36 |
| 37 ActionInfo::~ActionInfo() { |
| 38 } |
| 39 |
| 40 // static |
| 41 const ActionInfo* ActionInfo::GetScriptBadgeInfo(const Extension* extension) { |
| 42 ActionInfoData* data = static_cast<ActionInfoData*>( |
| 43 extension->GetManifestData(extension_manifest_keys::kScriptBadge)); |
| 44 return data ? data->action_info.get() : NULL; |
| 45 } |
| 46 |
| 47 // static |
| 48 void ActionInfo::SetScriptBadgeInfo(Extension* extension, ActionInfo* info) { |
| 49 extension->SetManifestData(extension_manifest_keys::kScriptBadge, |
| 50 new ActionInfoData(info)); |
| 51 } |
| 52 |
| 53 } // namespace extensions |
OLD | NEW |