Chromium Code Reviews| Index: chrome/common/extensions/manifest_handlers/app_icon_color_info.cc |
| diff --git a/chrome/common/extensions/manifest_handlers/app_icon_color_info.cc b/chrome/common/extensions/manifest_handlers/app_icon_color_info.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..164396ae9f51cd4fbb5cafc5da05bb160b10514e |
| --- /dev/null |
| +++ b/chrome/common/extensions/manifest_handlers/app_icon_color_info.cc |
| @@ -0,0 +1,81 @@ |
| +// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/common/extensions/manifest_handlers/app_icon_color_info.h" |
| + |
| +#include "base/lazy_instance.h" |
| +#include "base/values.h" |
| +#include "extensions/common/image_util.h" |
| +#include "extensions/common/manifest.h" |
| +#include "extensions/common/manifest_constants.h" |
| + |
| +namespace extensions { |
| + |
| +namespace keys = manifest_keys; |
| +namespace errors = manifest_errors; |
| + |
| +namespace { |
| + |
| +static base::LazyInstance<AppIconColorInfo> g_empty_app_icon_color_info = |
| + LAZY_INSTANCE_INITIALIZER; |
| + |
| +const AppIconColorInfo& GetInfo(const Extension* extension) { |
| + AppIconColorInfo* info = static_cast<AppIconColorInfo*>( |
| + extension->GetManifestData(keys::kAppIconColor)); |
| + return info ? *info : g_empty_app_icon_color_info.Get(); |
| +} |
| + |
| +} // namespace |
| + |
| +AppIconColorInfo::AppIconColorInfo() : icon_color_(SK_ColorTRANSPARENT) { |
| +} |
| + |
| +AppIconColorInfo::~AppIconColorInfo() { |
| +} |
| + |
| +// static |
| +SkColor AppIconColorInfo::GetIconColor(const Extension* extension) { |
| + return GetInfo(extension).icon_color_; |
| +} |
| + |
| +// static |
| +const std::string& AppIconColorInfo::GetIconColorString( |
| + const Extension* extension) { |
| + return GetInfo(extension).icon_color_string_; |
| +} |
| + |
| +AppIconColorHandler::AppIconColorHandler() { |
| +} |
| + |
| +AppIconColorHandler::~AppIconColorHandler() { |
| +} |
| + |
| +bool AppIconColorHandler::Parse(Extension* extension, base::string16* error) { |
| + scoped_ptr<AppIconColorInfo> app_icon_color_info(new AppIconColorInfo); |
| + |
| + const base::Value* temp = NULL; |
| + if (extension->manifest()->Get(keys::kAppIconColor, &temp)) { |
| + if (!temp->GetAsString(&app_icon_color_info->icon_color_string_)) { |
| + // TODO(benwells): Add proper error |
| + return false; |
| + } |
| + |
| + if (!image_util::ParseCSSColorString( |
| + app_icon_color_info->icon_color_string_, |
| + &app_icon_color_info->icon_color_)) { |
| + // TODO(benwells): ditto. |
|
calamity
2014/12/09 03:46:11
Eh. Just copy-paste the comment above. I don't wan
benwells
2014/12/09 08:28:35
Oops they are both gone now.
|
| + return false; |
| + } |
| + } |
| + |
| + extension->SetManifestData(keys::kAppIconColor, |
| + app_icon_color_info.release()); |
| + return true; |
| +} |
| + |
| +const std::vector<std::string> AppIconColorHandler::Keys() const { |
| + return SingleKey(keys::kAppIconColor); |
| +} |
| + |
| +} // namespace extensions |