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

Unified Diff: chrome/browser/ui/webui/chromeos/login/reset_screen_handler.cc

Issue 292973005: Flag-file added for rollback reset option. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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/chromeos/login/reset_screen_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/chromeos/login/reset_screen_handler.cc
diff --git a/chrome/browser/ui/webui/chromeos/login/reset_screen_handler.cc b/chrome/browser/ui/webui/chromeos/login/reset_screen_handler.cc
index 5e929095c25845510f586b4c8308b4dc99626fed..c2c597e742e239dca1d0caecd8c1244212a5dd79 100644
--- a/chrome/browser/ui/webui/chromeos/login/reset_screen_handler.cc
+++ b/chrome/browser/ui/webui/chromeos/login/reset_screen_handler.cc
@@ -6,7 +6,13 @@
#include <string>
+#include "base/bind.h"
+#include "base/bind_helpers.h"
+#include "base/callback.h"
#include "base/command_line.h"
+#include "base/file_util.h"
+#include "base/files/file_path.h"
+#include "base/memory/scoped_ptr.h"
#include "base/metrics/histogram.h"
#include "base/prefs/pref_service.h"
#include "base/values.h"
@@ -20,6 +26,7 @@
#include "chromeos/dbus/power_manager_client.h"
#include "chromeos/dbus/session_manager_client.h"
#include "chromeos/dbus/update_engine_client.h"
+#include "content/public/browser/browser_thread.h"
#include "grit/browser_resources.h"
#include "grit/chromium_strings.h"
#include "grit/generated_resources.h"
@@ -34,6 +41,13 @@ const char kResetScreen[] = "reset";
const int kErrorUIStateRollback = 7;
+static const char kRollbackFlagFile[] = "/tmp/enable_rollback_ui.flag";
Nikita (slow) 2014/05/22 09:51:32 nit: /tmp/.enable_rollback_ui
merkulova 2014/05/22 11:22:02 Done.
+
+void CheckRollbackFlagFileExists(bool *file_exists) {
+ DCHECK(content::BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread());
+ *file_exists = base::PathExists(base::FilePath(kRollbackFlagFile));
+}
+
} // namespace
namespace chromeos {
@@ -94,6 +108,10 @@ void ResetScreenHandler::Show() {
return;
}
+ ChooseAndApplyShowScenario();
+}
+
+void ResetScreenHandler::ChooseAndApplyShowScenario() {
PrefService* prefs = g_browser_process->local_state();
restart_required_ = !CommandLine::ForCurrentProcess()->HasSwitch(
switches::kFirstExecAfterBoot);
@@ -101,12 +119,34 @@ void ResetScreenHandler::Show() {
rollback_available_ = false;
if (!restart_required_) // First exec after boot.
reboot_was_requested_ = prefs->GetBoolean(prefs::kFactoryResetRequested);
- if (!CommandLine::ForCurrentProcess()->HasSwitch(
+
+ // Check Rollback flag-file.
+ scoped_ptr<bool> file_exists(new bool(false));
+ base::Closure checkfile_closure = base::Bind(
+ &CheckRollbackFlagFileExists,
+ base::Unretained(file_exists.get()));
+ base::Closure on_check_done = base::Bind(
+ &ResetScreenHandler::OnRollbackFlagFileCheckDone,
+ weak_ptr_factory_.GetWeakPtr(),
+ base::Passed(file_exists.Pass()));
+ if (!content::BrowserThread::PostBlockingPoolTaskAndReply(
+ FROM_HERE,
Nikita (slow) 2014/05/22 09:51:32 nit: 4 spaces indent
merkulova 2014/05/22 11:22:02 Done.
+ checkfile_closure,
+ on_check_done)) {
+ LOG(WARNING) << "Failed to check flag file for Rollback reset option";
+ on_check_done.Run();
+ }
+}
+
+void ResetScreenHandler::OnRollbackFlagFileCheckDone(
+ scoped_ptr<bool> file_exists) {
+ if (!file_exists && !CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableRollbackOption)) {
rollback_available_ = false;
ShowWithParams();
} else if (!restart_required_ && reboot_was_requested_) {
// First exec after boot.
+ PrefService* prefs = g_browser_process->local_state();
rollback_available_ = prefs->GetBoolean(prefs::kRollbackRequested);
ShowWithParams();
} else {
@@ -116,6 +156,7 @@ void ResetScreenHandler::Show() {
}
}
+
Nikita (slow) 2014/05/22 09:51:32 nit: drop extra empty line
merkulova 2014/05/22 11:22:02 Done.
void ResetScreenHandler::Hide() {
DBusThreadManager::Get()->GetUpdateEngineClient()->RemoveObserver(this);
}
« no previous file with comments | « chrome/browser/ui/webui/chromeos/login/reset_screen_handler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698