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

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

Issue 2629573004: Add a chrome://webapks page. (Closed)
Patch Set: Adds an about:webapks page with information about all installed Web APKs on the device Created 3 years, 11 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
new file mode 100644
index 0000000000000000000000000000000000000000..65f0f860bdf1d4f81b0bd8243d6102f1c9687cf6
--- /dev/null
+++ b/chrome/browser/ui/webui/webapks_handler.cc
@@ -0,0 +1,54 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
hartmanng 2017/01/13 15:40:21 s/(c) 2012/2017/
gonzalon 2017/01/13 20:24:39 Done.
+// 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/webapks_handler.h"
+
+#include <stddef.h>
+
+#include "base/callback_forward.h"
hartmanng 2017/01/13 15:40:21 this seems like a lot of includes for a small file
gonzalon 2017/01/13 20:24:39 Done.
+#include "base/strings/string_util.h"
+#include "base/strings/stringprintf.h"
+#include "base/strings/utf_string_conversions.h"
+#include "chrome/browser/android/webapps/webapp_registry.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/grit/generated_resources.h"
+#include "components/strings/grit/components_strings.h"
+#include "components/webapks_ui/webapks_ui_constants.h"
+#include "content/public/browser/browser_thread.h"
+#include "content/public/browser/web_ui.h"
+#include "content/public/common/content_constants.h"
+#include "ppapi/features/features.h"
+#include "ui/base/l10n/l10n_util.h"
+
+WebAPKsHandler::WebAPKsHandler() : weak_ptr_factory_(this) {}
+
+WebAPKsHandler::~WebAPKsHandler() {}
+
+void WebAPKsHandler::RegisterMessages() {
+ web_ui()->RegisterMessageCallback(
+ webapks_ui::kRequestWebAPKsInfo,
+ base::Bind(&WebAPKsHandler::HandleRequestWebAPKsInfo,
+ base::Unretained(this)));
+}
+
+void WebAPKsHandler::HandleRequestWebAPKsInfo(const base::ListValue* args) {
+ base::RepeatingCallback<void(std::string, std::string, int, int)> callback =
+ base::BindRepeating(&WebAPKsHandler::OnWebApkInfoReceived,
+ weak_ptr_factory_.GetWeakPtr());
+ std::unique_ptr<WebappRegistry> webapp_registry_(new WebappRegistry());
+ webapp_registry_->ListWebAPKs(callback);
+}
+
+void WebAPKsHandler::OnWebApkInfoReceived(std::string name,
+ std::string package_name,
+ int shell_apk_version,
+ int version_code) {
+ base::StringValue name_value(name);
+ base::StringValue package_name_value(package_name);
+ base::FundamentalValue shell_apk_version_value(shell_apk_version);
+ base::FundamentalValue version_code_value(version_code);
+ web_ui()->CallJavascriptFunctionUnsafe(
+ webapks_ui::kReturnWebAPKsInfo, name_value, package_name_value,
+ shell_apk_version_value, version_code_value);
+}

Powered by Google App Engine
This is Rietveld 408576698