Chromium Code Reviews| OLD | NEW | 
|---|---|
| (Empty) | |
| 1 // 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.
 
 | |
| 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 <stddef.h> | |
| 8 | |
| 9 #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.
 
 | |
| 10 #include "base/strings/string_util.h" | |
| 11 #include "base/strings/stringprintf.h" | |
| 12 #include "base/strings/utf_string_conversions.h" | |
| 13 #include "chrome/browser/android/webapps/webapp_registry.h" | |
| 14 #include "chrome/browser/profiles/profile.h" | |
| 15 #include "chrome/grit/generated_resources.h" | |
| 16 #include "components/strings/grit/components_strings.h" | |
| 17 #include "components/webapks_ui/webapks_ui_constants.h" | |
| 18 #include "content/public/browser/browser_thread.h" | |
| 19 #include "content/public/browser/web_ui.h" | |
| 20 #include "content/public/common/content_constants.h" | |
| 21 #include "ppapi/features/features.h" | |
| 22 #include "ui/base/l10n/l10n_util.h" | |
| 23 | |
| 24 WebAPKsHandler::WebAPKsHandler() : weak_ptr_factory_(this) {} | |
| 25 | |
| 26 WebAPKsHandler::~WebAPKsHandler() {} | |
| 27 | |
| 28 void WebAPKsHandler::RegisterMessages() { | |
| 29 web_ui()->RegisterMessageCallback( | |
| 30 webapks_ui::kRequestWebAPKsInfo, | |
| 31 base::Bind(&WebAPKsHandler::HandleRequestWebAPKsInfo, | |
| 32 base::Unretained(this))); | |
| 33 } | |
| 34 | |
| 35 void WebAPKsHandler::HandleRequestWebAPKsInfo(const base::ListValue* args) { | |
| 36 base::RepeatingCallback<void(std::string, std::string, int, int)> callback = | |
| 37 base::BindRepeating(&WebAPKsHandler::OnWebApkInfoReceived, | |
| 38 weak_ptr_factory_.GetWeakPtr()); | |
| 39 std::unique_ptr<WebappRegistry> webapp_registry_(new WebappRegistry()); | |
| 40 webapp_registry_->ListWebAPKs(callback); | |
| 41 } | |
| 42 | |
| 43 void WebAPKsHandler::OnWebApkInfoReceived(std::string name, | |
| 44 std::string package_name, | |
| 45 int shell_apk_version, | |
| 46 int version_code) { | |
| 47 base::StringValue name_value(name); | |
| 48 base::StringValue package_name_value(package_name); | |
| 49 base::FundamentalValue shell_apk_version_value(shell_apk_version); | |
| 50 base::FundamentalValue version_code_value(version_code); | |
| 51 web_ui()->CallJavascriptFunctionUnsafe( | |
| 52 webapks_ui::kReturnWebAPKsInfo, name_value, package_name_value, | |
| 53 shell_apk_version_value, version_code_value); | |
| 54 } | |
| OLD | NEW |