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

Side by Side Diff: chrome/browser/ui/webui/webapks_handler.cc

Issue 2629573004: Add a chrome://webapks page. (Closed)
Patch Set: Add a chrome://webapks page. 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 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 "base/values.h"
9 #include "chrome/browser/android/shortcut_helper.h"
10 #include "content/public/browser/web_ui.h"
11
12 WebApksHandler::WebApksHandler() : weak_ptr_factory_(this) {}
13
14 WebApksHandler::~WebApksHandler() {}
15
16 void WebApksHandler::RegisterMessages() {
17 web_ui()->RegisterMessageCallback(
18 "requestWebApksInfo",
19 base::Bind(&WebApksHandler::HandleRequestWebApksInfo,
20 base::Unretained(this)));
21 }
22
23 void WebApksHandler::HandleRequestWebApksInfo(const base::ListValue* args) {
24 AllowJavascript();
25 ShortcutHelper::RetrieveWebApks(base::Bind(
26 &WebApksHandler::OnWebApkInfoRetrieved, weak_ptr_factory_.GetWeakPtr()));
27 }
28
29 void WebApksHandler::OnWebApkInfoRetrieved(
30 const std::vector<WebApkInfo>& webapks_list) {
31 if (!IsJavascriptAllowed())
32 return;
33 base::ListValue list;
34 for (const auto& webapk_info : webapks_list) {
35 std::unique_ptr<base::DictionaryValue> result(new base::DictionaryValue());
36 result->SetString("shortName", webapk_info.short_name);
37 result->SetString("packageName", webapk_info.package_name);
38 result->SetInteger("shellApkVersion", webapk_info.shell_apk_version);
39 result->SetInteger("versionCode", webapk_info.version_code);
40 list.Append(std::move(result));
41 }
42
43 CallJavascriptFunction("returnWebApksInfo", list);
44 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698