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

Side by Side 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, 9 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/ui/webui/color_utils.h"
6
7 #include "base/strings/string_number_conversions.h"
8 #include "base/strings/stringprintf.h"
9 #include "content/public/common/manifest.h"
10
11 std::string ColorUtils::ColorToString(int64_t color) {
12 if (color == content::Manifest::kInvalidOrMissingColor) {
13 return "";
14 }
15 return SkColorToRGBAString(reinterpret_cast<uint32_t&>(color));
16 }
17
18 std::string ColorUtils::SkColorToRGBAString(SkColor color) {
19 // We convert the alpha using DoubleToString because StringPrintf will use
20 // locale specific formatters (e.g., use , instead of . in German).
21 return base::StringPrintf(
22 "rgba(%d,%d,%d,%s)", SkColorGetR(color), SkColorGetG(color),
23 SkColorGetB(color),
24 base::DoubleToString(SkColorGetA(color) / 255.0).c_str());
25 }
26
27 std::string ColorUtils::SkColorToRGBComponents(SkColor color) {
28 return base::StringPrintf("%d,%d,%d", SkColorGetR(color), SkColorGetG(color),
29 SkColorGetB(color));
30 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698