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

Unified Diff: ui/gfx/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
« no previous file with comments | « ui/gfx/color_utils.h ('k') | ui/gfx/color_utils_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/color_utils.cc
diff --git a/ui/gfx/color_utils.cc b/ui/gfx/color_utils.cc
index e35d7b33fb8dc8576969c3908e2da96541060f3a..95dea0936c0fc4d35494ef7ed8e450b7873c013f 100644
--- a/ui/gfx/color_utils.cc
+++ b/ui/gfx/color_utils.cc
@@ -11,6 +11,8 @@
#include "base/logging.h"
#include "base/numerics/safe_conversions.h"
+#include "base/strings/string_number_conversions.h"
+#include "base/strings/stringprintf.h"
#include "build/build_config.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/gfx/color_palette.h"
@@ -347,4 +349,17 @@ SkColor DeriveDefaultIconColor(SkColor text_color) {
static_cast<int>(0.8f * SkColorGetA(text_color)));
}
+std::string 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(%s,%s)", SkColorToRgbString(color).c_str(),
+ base::DoubleToString(SkColorGetA(color) / 255.0).c_str());
+}
+
+std::string SkColorToRgbString(SkColor color) {
+ return base::StringPrintf("%d,%d,%d", SkColorGetR(color), SkColorGetG(color),
+ SkColorGetB(color));
+}
+
} // namespace color_utils
« no previous file with comments | « ui/gfx/color_utils.h ('k') | ui/gfx/color_utils_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698