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

Unified Diff: chrome/browser/ui/webui/settings/about_handler.cc

Issue 2873193002: Make update over cellular an option for user (Closed)
Patch Set: Put code in CHROME_OS wrapper to fix trybot error Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/webui/settings/about_handler.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..2ee8ce7b1a1b8390b67e5c374ea4e9fbc9f2123f 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,28 @@ 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);
+}
+
+void AboutHandler::RequestUpdateOverCellular(const std::string& target_version,
+ int64_t target_size) {
+ version_updater_->SetUpdateOverCellularTarget(
+ base::Bind(&AboutHandler::SetUpdateStatus, base::Unretained(this)),
+ target_version, target_size);
+}
+
#endif // defined(OS_CHROMEOS)
void AboutHandler::RequestUpdate() {
@@ -558,6 +587,8 @@ void AboutHandler::RequestUpdate() {
void AboutHandler::SetUpdateStatus(VersionUpdater::Status status,
int progress,
+ const std::string& version,
+ 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) {
« no previous file with comments | « chrome/browser/ui/webui/settings/about_handler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698