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

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

Issue 2795603002: Add an update warning for downloading over mobile data (Closed)
Patch Set: Ignore this as I uploaded a new CL 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') | chromeos/dbus/update_engine_client.h » ('j') | 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 a4ff8df6894a7f894dc57db5f104e6429c105fcd..7806a8a248964b69784ebde6110472e0361aee6e 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());
-
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)));
@@ -545,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() {
@@ -557,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);
+}
+
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);
@@ -567,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') | chromeos/dbus/update_engine_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698