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

Unified Diff: chrome/common/extensions/manifest_handlers/app_icon_color_info.cc

Issue 782693002: Ensure there are always nice icons for bookmark apps. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Mac compile Created 6 years 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 side-by-side diff with in-line comments
Download patch
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..01e83d67c1370c89356018ac3a1e3262143d1c0d
--- /dev/null
+++ b/chrome/common/extensions/manifest_handlers/app_icon_color_info.cc
@@ -0,0 +1,84 @@
+// Copyright 2014 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/strings/utf_string_conversions.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_)) {
+ *error =
+ base::UTF8ToUTF16(extensions::manifest_errors::kInvalidAppIconColor);
+ return false;
+ }
+
+ if (!image_util::ParseCSSColorString(
+ app_icon_color_info->icon_color_string_,
+ &app_icon_color_info->icon_color_)) {
+ *error =
+ base::UTF8ToUTF16(extensions::manifest_errors::kInvalidAppIconColor);
+ 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
« no previous file with comments | « chrome/common/extensions/manifest_handlers/app_icon_color_info.h ('k') | chrome/common/web_application_info.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698