Chromium Code Reviews| Index: chrome/browser/ui/webui/settings/about_handler.cc |
| diff --git a/chrome/browser/ui/webui/settings/about_handler.cc b/chrome/browser/ui/webui/settings/about_handler.cc |
| index 660d07d2810ee9326643d8727a97b7397b0a0c6f..ec71a5cd234f5fc577994cf56171bdb23b18171d 100644 |
| --- a/chrome/browser/ui/webui/settings/about_handler.cc |
| +++ b/chrome/browser/ui/webui/settings/about_handler.cc |
| @@ -19,6 +19,7 @@ |
| #include "base/macros.h" |
| #include "base/memory/ptr_util.h" |
| #include "base/strings/string16.h" |
| +#include "base/strings/string_number_conversions.h" |
| #include "base/strings/string_util.h" |
| #include "base/strings/utf_string_conversions.h" |
| #include "base/task_scheduler/post_task.h" |
| @@ -239,6 +240,9 @@ std::string UpdateStatusToString(VersionUpdater::Status status) { |
| case VersionUpdater::DISABLED_BY_ADMIN: |
| status_str = "disabled_by_admin"; |
| break; |
| + case VersionUpdater::NEED_PERMISSION_TO_UPDATE: |
| + status_str = "need_permission_to_update"; |
| + break; |
| } |
| return status_str; |
| @@ -302,7 +306,6 @@ AboutHandler* AboutHandler::Create(content::WebUIDataSource* html_source, |
| base::ASCIIToUTF16(chrome::kChromeUIOSCreditsURL)); |
| html_source->AddString("aboutProductOsLicense", os_license); |
| html_source->AddBoolean("aboutEnterpriseManaged", IsEnterpriseManaged()); |
| - |
|
xiyuan
2017/05/11 20:37:25
nit: please restore
weidongg
2017/05/11 23:50:45
Done.
|
| base::Time build_time = base::SysInfo::GetLsbReleaseTime(); |
| base::string16 build_date = base::TimeFormatFriendlyDate(build_time); |
| html_source->AddString("aboutBuildDate", build_date); |
| @@ -340,7 +343,10 @@ void AboutHandler::RegisterMessages() { |
| web_ui()->RegisterMessageCallback( |
| "requestUpdate", |
| base::Bind(&AboutHandler::HandleRequestUpdate, base::Unretained(this))); |
| - |
| + web_ui()->RegisterMessageCallback( |
| + "requestUpdateOverCellular", |
| + base::Bind(&AboutHandler::HandleRequestUpdateOverCellular, |
| + base::Unretained(this))); |
| web_ui()->RegisterMessageCallback( |
| "getVersionInfo", |
| base::Bind(&AboutHandler::HandleGetVersionInfo, base::Unretained(this))); |
| @@ -544,6 +550,21 @@ void AboutHandler::HandleRequestUpdate(const base::ListValue* args) { |
| RequestUpdate(); |
| } |
| +void AboutHandler::HandleRequestUpdateOverCellular( |
| + const base::ListValue* args) { |
| + CHECK_EQ(2U, args->GetSize()); |
| + |
| + std::string target_version; |
| + std::string target_size_string; |
| + int64_t target_size; |
| + |
| + CHECK(args->GetString(0, &target_version)); |
| + CHECK(args->GetString(1, &target_size_string)); |
| + CHECK(base::StringToInt64(target_size_string, &target_size)); |
| + |
| + RequestUpdateOverCellular(target_version, target_size); |
| +} |
| + |
| #endif // defined(OS_CHROMEOS) |
| void AboutHandler::RequestUpdate() { |
| @@ -556,8 +577,17 @@ void AboutHandler::RequestUpdate() { |
| #endif // OS_MACOSX |
| } |
| +void AboutHandler::RequestUpdateOverCellular(std::string& target_version, |
| + int64_t target_size) { |
| + version_updater_->SetUpdateOverCellularTarget( |
| + base::Bind(&AboutHandler::SetUpdateStatus, base::Unretained(this)), |
|
xiyuan
2017/05/11 20:37:25
Use weak_factory_.GetWeakPtr() instead of base::Un
stevenjb
2017/05/11 21:03:45
Technically we don't need a weak_ptr here (and don
weidongg
2017/05/11 23:50:45
Should I leave it unchanged?
|
| + target_version, target_size); |
| +} |
| + |
| void AboutHandler::SetUpdateStatus(VersionUpdater::Status status, |
| int progress, |
| + const std::string& version, |
| + const int64_t size, |
| const base::string16& message) { |
| // Only UPDATING state should have progress set. |
| DCHECK(status == VersionUpdater::UPDATING || progress == 0); |
| @@ -566,7 +596,9 @@ void AboutHandler::SetUpdateStatus(VersionUpdater::Status status, |
| event->SetString("status", UpdateStatusToString(status)); |
| event->SetString("message", message); |
| event->SetInteger("progress", progress); |
| - |
| + event->SetString("version", version); |
| + // DictionaryValue does not support int64_t, so convert to string. |
| + event->SetString("size", base::Int64ToString(size)); |
| #if defined(OS_CHROMEOS) |
| if (status == VersionUpdater::FAILED_OFFLINE || |
| status == VersionUpdater::FAILED_CONNECTION_TYPE_DISALLOWED) { |