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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 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/webapks_handler.h"
6
7 #include "base/callback_forward.h"
8 #include "chrome/browser/android/shortcut_helper.h"
9 #include "content/public/browser/web_ui.h"
10
11 WebApksHandler::WebApksHandler() : weak_ptr_factory_(this) {}
12
13 WebApksHandler::~WebApksHandler() {}
14
15 void WebApksHandler::RegisterMessages() {
16 web_ui()->RegisterMessageCallback("requestWebApksInfo",
17 base::Bind(&WebApksHandler::HandleRequestWebApksInfo,
18 base::Unretained(this)));
19 }
20
21 void WebApksHandler::HandleRequestWebApksInfo(const base::ListValue* args) {
22 // The WebApkInfoCallback will delete itself after it is done.
pkotwicz 2017/01/20 16:57:17 Nit: Delete the comment. I think that commenting
gonzalon 2017/01/20 19:27:01 Done.
23 ShortcutHelper::ListWebApks(base::Bind(
24 &WebApksHandler::OnWebApkInfoReceived, weak_ptr_factory_.GetWeakPtr()));
25 }
26
27 void WebApksHandler::OnWebApkInfoReceived(
28 std::vector<const WebApkInfo> webapks_list) {
29 base::ListValue list;
30 for (size_t i = 0; i < webapks_list.size(); ++i) {
31 const WebApkInfo webapk_info = webapks_list[i];
32 std::unique_ptr<base::DictionaryValue> result(new base::DictionaryValue());
33 result->SetString("shortName", webapk_info.short_name);
34 result->SetString("packageName", webapk_info.package_name);
35 result->SetInteger("shellApkVersion", webapk_info.shell_apk_version);
36 result->SetInteger("versionCode", webapk_info.version_code);
37 list.Append(std::move(result));
38 }
39
40 web_ui()->CallJavascriptFunctionUnsafe("returnWebApksInfo", list);
41 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698