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

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

Issue 2714633003: Adds more metadata to the about:webapks page (Closed)
Patch Set: 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/webapks_handler.cc
diff --git a/chrome/browser/ui/webui/webapks_handler.cc b/chrome/browser/ui/webui/webapks_handler.cc
index 69d98c8cafda9393b7085fddbb48472075d876d6..3ea215a759942b3820ec067c91cb0f4786042062 100644
--- a/chrome/browser/ui/webui/webapks_handler.cc
+++ b/chrome/browser/ui/webui/webapks_handler.cc
@@ -4,10 +4,14 @@
#include "chrome/browser/ui/webui/webapks_handler.h"
+#include <string>
+
#include "base/callback_forward.h"
+#include "base/strings/stringprintf.h"
#include "base/values.h"
#include "chrome/browser/android/shortcut_helper.h"
#include "content/public/browser/web_ui.h"
+#include "content/public/common/manifest_util.h"
WebApksHandler::WebApksHandler() : weak_ptr_factory_(this) {}
@@ -26,6 +30,20 @@ void WebApksHandler::HandleRequestWebApksInfo(const base::ListValue* args) {
&WebApksHandler::OnWebApkInfoRetrieved, weak_ptr_factory_.GetWeakPtr()));
}
+// Converts a color from the format specified in content::Manifest to a CSS
+// string.
+std::string ColorToString(int64_t color) {
+ if (color == content::Manifest::kInvalidOrMissingColor)
+ return "";
+
+ SkColor sk_color = reinterpret_cast<uint32_t&>(color);
+ int r = SkColorGetR(sk_color);
+ int g = SkColorGetG(sk_color);
+ int b = SkColorGetB(sk_color);
+ double a = SkColorGetA(sk_color) / 255.0;
+ return base::StringPrintf("rgba(%d,%d,%d,%.2f)", r, g, b, a);
+}
Dan Beam 2017/02/24 18:36:16 can this share code with https://cs.chromium.org/
gonzalon 2017/02/24 22:30:52 Yes, we probably can. https://cs.chromium.org/chro
Dan Beam 2017/02/24 22:33:52 i think they both share chrome/browser/ui/webui as
+
void WebApksHandler::OnWebApkInfoRetrieved(
const std::vector<WebApkInfo>& webapks_list) {
if (!IsJavascriptAllowed())
@@ -33,10 +51,23 @@ void WebApksHandler::OnWebApkInfoRetrieved(
base::ListValue list;
for (const auto& webapk_info : webapks_list) {
std::unique_ptr<base::DictionaryValue> result(new base::DictionaryValue());
+ result->SetString("name", webapk_info.name);
result->SetString("shortName", webapk_info.short_name);
result->SetString("packageName", webapk_info.package_name);
result->SetInteger("shellApkVersion", webapk_info.shell_apk_version);
result->SetInteger("versionCode", webapk_info.version_code);
+ result->SetString("uri", webapk_info.uri);
+ result->SetString("scope", webapk_info.scope);
+ result->SetString("manifestUrl", webapk_info.manifest_url);
+ result->SetString("manifestStartUrl", webapk_info.manifest_start_url);
+ result->SetString("displayMode",
+ content::WebDisplayModeToString(webapk_info.display));
+ result->SetString(
+ "orientation",
+ content::WebScreenOrientationLockTypeToString(webapk_info.orientation));
+ result->SetString("themeColor", ColorToString(webapk_info.theme_color));
+ result->SetString("backgroundColor",
+ ColorToString(webapk_info.background_color));
list.Append(std::move(result));
}

Powered by Google App Engine
This is Rietveld 408576698