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..06b999734cf4e75142ed54cdf10dabdf9a0b8cf3 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; |
| @@ -340,7 +344,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 +551,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 +578,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)), |
| + target_version, target_size); |
|
stevenjb
2017/05/12 18:28:54
If AboutHandler::SetUpdateStatus never runs then u
weidongg
2017/05/12 20:31:57
We could run the callback if SetUpdateOverCellular
stevenjb
2017/05/12 20:50:16
That would be fine also, although maybe a little b
|
| +} |
| + |
| 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 +597,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) { |