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

Unified Diff: chrome/browser/ui/webui/color_utils.cc

Issue 2714633003: Adds more metadata to the about:webapks page (Closed)
Patch Set: Adds more metadata to the about:webapks page Created 3 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/webui/color_utils.cc
diff --git a/chrome/browser/ui/webui/color_utils.cc b/chrome/browser/ui/webui/color_utils.cc
new file mode 100644
index 0000000000000000000000000000000000000000..add22396cc834eca6d7424d6765f306c2bb0ae32
--- /dev/null
+++ b/chrome/browser/ui/webui/color_utils.cc
@@ -0,0 +1,30 @@
+// Copyright 2017 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/browser/ui/webui/color_utils.h"
+
+#include "base/strings/string_number_conversions.h"
+#include "base/strings/stringprintf.h"
+#include "content/public/common/manifest.h"
+
+std::string ColorUtils::ColorToString(int64_t color) {
+ if (color == content::Manifest::kInvalidOrMissingColor) {
+ return "";
+ }
+ return SkColorToRGBAString(reinterpret_cast<uint32_t&>(color));
+}
+
+std::string ColorUtils::SkColorToRGBAString(SkColor color) {
+ // We convert the alpha using DoubleToString because StringPrintf will use
+ // locale specific formatters (e.g., use , instead of . in German).
+ return base::StringPrintf(
+ "rgba(%d,%d,%d,%s)", SkColorGetR(color), SkColorGetG(color),
+ SkColorGetB(color),
+ base::DoubleToString(SkColorGetA(color) / 255.0).c_str());
+}
+
+std::string ColorUtils::SkColorToRGBComponents(SkColor color) {
+ return base::StringPrintf("%d,%d,%d", SkColorGetR(color), SkColorGetG(color),
+ SkColorGetB(color));
+}

Powered by Google App Engine
This is Rietveld 408576698