| 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));
|
| +}
|
|
|