Commit 07a2c773 authored by satorux@chromium.org's avatar satorux@chromium.org

chromeos: Do not check /home/chronos/.oobe_complete on Linux desktop

Unless your user name is chronos.

BUG=chromium-os:27859
TEST=manually with --vmodule=wizard_controller=1

Review URL: https://chromiumcodereview.appspot.com/9704064

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@126972 0039d316-1c4b-4281-b951-d872f2087c98
parent fe28550d
......@@ -5,6 +5,7 @@
#include "chrome/browser/chromeos/login/wizard_controller.h"
#include <signal.h>
#include <stdlib.h>
#include <sys/types.h>
#include <string>
......@@ -36,6 +37,7 @@
#include "chrome/browser/chromeos/login/update_screen.h"
#include "chrome/browser/chromeos/login/user_image_screen.h"
#include "chrome/browser/chromeos/login/user_manager.h"
#include "chrome/browser/chromeos/system/runtime_environment.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/options/options_util.h"
......@@ -66,9 +68,6 @@ const char kOobeComplete[] = "OobeComplete";
// A boolean pref of the device registered flag (second part after first login).
const char kDeviceRegistered[] = "DeviceRegistered";
// Path to flag file indicating that both parts of OOBE were completed.
const char kOobeCompleteFlagFilePath[] = "/home/chronos/.oobe_completed";
// Time in seconds that we wait for the device to reboot.
// If reboot didn't happen, ask user to reboot device manually.
const int kWaitForRebootTimeSec = 3;
......@@ -586,13 +585,32 @@ void WizardController::MarkOobeCompleted() {
SaveBoolPreferenceForced(kOobeComplete, true);
}
// Returns the path to flag file indicating that both parts of OOBE were
// completed.
// On chrome device, returns /home/chronos/.oobe_completed.
// On Linux desktop, returns $HOME/.oobe_completed.
static FilePath GetOobeCompleteFlagPath() {
// The constant is defined here so it won't be referenced directly.
const char kOobeCompleteFlagFilePath[] = "/home/chronos/.oobe_completed";
if (system::runtime_environment::IsRunningOnChromeOS()) {
return FilePath(kOobeCompleteFlagFilePath);
} else {
const char* home = getenv("HOME");
// Unlikely but if HOME is not defined, use the current directory.
if (!home)
home = "";
return FilePath(home).AppendASCII(".oobe_completed");
}
}
static void CreateOobeCompleteFlagFile() {
// Create flag file for boot-time init scripts.
FilePath oobe_complete_path(kOobeCompleteFlagFilePath);
FilePath oobe_complete_path = GetOobeCompleteFlagPath();
if (!file_util::PathExists(oobe_complete_path)) {
FILE* oobe_flag_file = file_util::OpenFile(oobe_complete_path, "w+b");
if (oobe_flag_file == NULL)
DLOG(WARNING) << kOobeCompleteFlagFilePath << " doesn't exist.";
DLOG(WARNING) << oobe_complete_path.value() << " doesn't exist.";
else
file_util::CloseFile(oobe_flag_file);
}
......@@ -614,7 +632,8 @@ bool WizardController::IsDeviceRegistered() {
// Pref is not set. For compatibility check flag file. It causes blocking
// IO on UI thread. But it's required for update from old versions.
base::ThreadRestrictions::ScopedAllowIO allow_io;
FilePath oobe_complete_flag_file_path(kOobeCompleteFlagFilePath);
FilePath oobe_complete_flag_file_path = GetOobeCompleteFlagPath();
DVLOG(1) << "Checking " << oobe_complete_flag_file_path.value();
bool file_exists = file_util::PathExists(oobe_complete_flag_file_path);
SaveIntegerPreferenceForced(kDeviceRegistered, file_exists ? 1 : 0);
return file_exists;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment