| 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 #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/extension.h" | 8 #include "chrome/common/extensions/extension.h" |
| 9 #include "chrome/common/extensions/extension_manifest_constants.h" | 9 #include "chrome/common/extensions/extension_manifest_constants.h" |
| 10 | 10 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 // This is never NULL for ScriptBadge. | 22 // This is never NULL for ScriptBadge. |
| 23 scoped_ptr<ActionInfo> action_info; | 23 scoped_ptr<ActionInfo> action_info; |
| 24 }; | 24 }; |
| 25 | 25 |
| 26 ActionInfoData::ActionInfoData(ActionInfo* info) : action_info(info) { | 26 ActionInfoData::ActionInfoData(ActionInfo* info) : action_info(info) { |
| 27 } | 27 } |
| 28 | 28 |
| 29 ActionInfoData::~ActionInfoData() { | 29 ActionInfoData::~ActionInfoData() { |
| 30 } | 30 } |
| 31 | 31 |
| 32 static const ActionInfo* GetActionInfo(const Extension* extension, |
| 33 const std::string& key) { |
| 34 ActionInfoData* data = static_cast<ActionInfoData*>( |
| 35 extension->GetManifestData(key)); |
| 36 return data ? data->action_info.get() : NULL; |
| 37 } |
| 38 |
| 32 } // namespace | 39 } // namespace |
| 33 | 40 |
| 34 ActionInfo::ActionInfo() { | 41 ActionInfo::ActionInfo() { |
| 35 } | 42 } |
| 36 | 43 |
| 37 ActionInfo::~ActionInfo() { | 44 ActionInfo::~ActionInfo() { |
| 38 } | 45 } |
| 39 | 46 |
| 40 // static | 47 // static |
| 48 const ActionInfo* ActionInfo::GetBrowserActionInfo(const Extension* extension) { |
| 49 return GetActionInfo(extension, extension_manifest_keys::kBrowserAction); |
| 50 } |
| 51 |
| 52 // static |
| 41 const ActionInfo* ActionInfo::GetScriptBadgeInfo(const Extension* extension) { | 53 const ActionInfo* ActionInfo::GetScriptBadgeInfo(const Extension* extension) { |
| 42 ActionInfoData* data = static_cast<ActionInfoData*>( | 54 return GetActionInfo(extension, extension_manifest_keys::kScriptBadge); |
| 43 extension->GetManifestData(extension_manifest_keys::kScriptBadge)); | |
| 44 return data ? data->action_info.get() : NULL; | |
| 45 } | 55 } |
| 46 | 56 |
| 47 // static | 57 // static |
| 58 void ActionInfo::SetBrowserActionInfo(Extension* extension, ActionInfo* info) { |
| 59 extension->SetManifestData(extension_manifest_keys::kBrowserAction, |
| 60 new ActionInfoData(info)); |
| 61 } |
| 62 |
| 63 // static |
| 48 void ActionInfo::SetScriptBadgeInfo(Extension* extension, ActionInfo* info) { | 64 void ActionInfo::SetScriptBadgeInfo(Extension* extension, ActionInfo* info) { |
| 49 extension->SetManifestData(extension_manifest_keys::kScriptBadge, | 65 extension->SetManifestData(extension_manifest_keys::kScriptBadge, |
| 50 new ActionInfoData(info)); | 66 new ActionInfoData(info)); |
| 51 } | 67 } |
| 52 | 68 |
| 53 } // namespace extensions | 69 } // namespace extensions |
| OLD | NEW |