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

Side by Side Diff: chrome/browser/chromeos/login/wizard_controller.cc

Issue 9704064: chromeos: Do not check /home/chronos/.oobe_complete on Linux desktop (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: polish Created 8 years, 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/chromeos/login/wizard_controller.h" 5 #include "chrome/browser/chromeos/login/wizard_controller.h"
6 6
7 #include <signal.h> 7 #include <signal.h>
8 #include <stdlib.h>
8 #include <sys/types.h> 9 #include <sys/types.h>
9 10
10 #include <string> 11 #include <string>
11 #include <vector> 12 #include <vector>
12 13
13 #include "base/bind.h" 14 #include "base/bind.h"
14 #include "base/command_line.h" 15 #include "base/command_line.h"
15 #include "base/file_util.h" 16 #include "base/file_util.h"
16 #include "base/logging.h" 17 #include "base/logging.h"
17 #include "base/metrics/histogram.h" 18 #include "base/metrics/histogram.h"
(...skipping 11 matching lines...) Expand all
29 #include "chrome/browser/chromeos/login/helper.h" 30 #include "chrome/browser/chromeos/login/helper.h"
30 #include "chrome/browser/chromeos/login/html_page_screen.h" 31 #include "chrome/browser/chromeos/login/html_page_screen.h"
31 #include "chrome/browser/chromeos/login/login_display_host.h" 32 #include "chrome/browser/chromeos/login/login_display_host.h"
32 #include "chrome/browser/chromeos/login/login_utils.h" 33 #include "chrome/browser/chromeos/login/login_utils.h"
33 #include "chrome/browser/chromeos/login/network_screen.h" 34 #include "chrome/browser/chromeos/login/network_screen.h"
34 #include "chrome/browser/chromeos/login/oobe_display.h" 35 #include "chrome/browser/chromeos/login/oobe_display.h"
35 #include "chrome/browser/chromeos/login/registration_screen.h" 36 #include "chrome/browser/chromeos/login/registration_screen.h"
36 #include "chrome/browser/chromeos/login/update_screen.h" 37 #include "chrome/browser/chromeos/login/update_screen.h"
37 #include "chrome/browser/chromeos/login/user_image_screen.h" 38 #include "chrome/browser/chromeos/login/user_image_screen.h"
38 #include "chrome/browser/chromeos/login/user_manager.h" 39 #include "chrome/browser/chromeos/login/user_manager.h"
40 #include "chrome/browser/chromeos/system/runtime_environment.h"
39 #include "chrome/browser/prefs/pref_service.h" 41 #include "chrome/browser/prefs/pref_service.h"
40 #include "chrome/browser/profiles/profile_manager.h" 42 #include "chrome/browser/profiles/profile_manager.h"
41 #include "chrome/browser/ui/options/options_util.h" 43 #include "chrome/browser/ui/options/options_util.h"
42 #include "chrome/common/chrome_notification_types.h" 44 #include "chrome/common/chrome_notification_types.h"
43 #include "chrome/common/pref_names.h" 45 #include "chrome/common/pref_names.h"
44 #include "content/public/browser/notification_service.h" 46 #include "content/public/browser/notification_service.h"
45 #include "content/public/browser/notification_types.h" 47 #include "content/public/browser/notification_types.h"
46 #include "ui/base/accelerators/accelerator.h" 48 #include "ui/base/accelerators/accelerator.h"
47 #include "ui/base/l10n/l10n_util.h" 49 #include "ui/base/l10n/l10n_util.h"
48 50
(...skipping 10 matching lines...) Expand all
59 61
60 // A string pref with initial locale set in VPD or manifest. 62 // A string pref with initial locale set in VPD or manifest.
61 const char kInitialLocale[] = "intl.initial_locale"; 63 const char kInitialLocale[] = "intl.initial_locale";
62 64
63 // A boolean pref of the OOBE complete flag (first OOBE part before login). 65 // A boolean pref of the OOBE complete flag (first OOBE part before login).
64 const char kOobeComplete[] = "OobeComplete"; 66 const char kOobeComplete[] = "OobeComplete";
65 67
66 // A boolean pref of the device registered flag (second part after first login). 68 // A boolean pref of the device registered flag (second part after first login).
67 const char kDeviceRegistered[] = "DeviceRegistered"; 69 const char kDeviceRegistered[] = "DeviceRegistered";
68 70
69 // Path to flag file indicating that both parts of OOBE were completed.
70 const char kOobeCompleteFlagFilePath[] = "/home/chronos/.oobe_completed";
71
72 // Time in seconds that we wait for the device to reboot. 71 // Time in seconds that we wait for the device to reboot.
73 // If reboot didn't happen, ask user to reboot device manually. 72 // If reboot didn't happen, ask user to reboot device manually.
74 const int kWaitForRebootTimeSec = 3; 73 const int kWaitForRebootTimeSec = 3;
75 74
76 // Interval in ms which is used for smooth screen showing. 75 // Interval in ms which is used for smooth screen showing.
77 static int kShowDelayMs = 400; 76 static int kShowDelayMs = 400;
78 77
79 // Saves boolean "Local State" preference and forces its persistence to disk. 78 // Saves boolean "Local State" preference and forces its persistence to disk.
80 void SaveBoolPreferenceForced(const char* pref_name, bool value) { 79 void SaveBoolPreferenceForced(const char* pref_name, bool value) {
81 PrefService* prefs = g_browser_process->local_state(); 80 PrefService* prefs = g_browser_process->local_state();
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after
579 // static 578 // static
580 void WizardController::MarkEulaAccepted() { 579 void WizardController::MarkEulaAccepted() {
581 SaveBoolPreferenceForced(kEulaAccepted, true); 580 SaveBoolPreferenceForced(kEulaAccepted, true);
582 } 581 }
583 582
584 // static 583 // static
585 void WizardController::MarkOobeCompleted() { 584 void WizardController::MarkOobeCompleted() {
586 SaveBoolPreferenceForced(kOobeComplete, true); 585 SaveBoolPreferenceForced(kOobeComplete, true);
587 } 586 }
588 587
588 // Returns the path to flag file indicating that both parts of OOBE were
589 // completed.
590 // On chrome device, returns /home/chronos/.oobe_completed.
591 // On Linux desktop, returns $HOME/.oobe_completed.
592 static FilePath GetOobeCompleteFlagPath() {
593 // The constant is defined here so it won't be referenced directly.
594 const char kOobeCompleteFlagFilePath[] = "/home/chronos/.oobe_completed";
595
596 if (system::runtime_environment::IsRunningOnChromeOS()) {
597 return FilePath(kOobeCompleteFlagFilePath);
598 } else {
599 const char* home = getenv("HOME");
600 // Unlikely but if HOME is not defined, use the current directory.
601 if (!home)
602 home = "";
603 return FilePath(home).AppendASCII(".oobe_completed");
604 }
605 }
606
589 static void CreateOobeCompleteFlagFile() { 607 static void CreateOobeCompleteFlagFile() {
590 // Create flag file for boot-time init scripts. 608 // Create flag file for boot-time init scripts.
591 FilePath oobe_complete_path(kOobeCompleteFlagFilePath); 609 FilePath oobe_complete_path = GetOobeCompleteFlagPath();
592 if (!file_util::PathExists(oobe_complete_path)) { 610 if (!file_util::PathExists(oobe_complete_path)) {
593 FILE* oobe_flag_file = file_util::OpenFile(oobe_complete_path, "w+b"); 611 FILE* oobe_flag_file = file_util::OpenFile(oobe_complete_path, "w+b");
594 if (oobe_flag_file == NULL) 612 if (oobe_flag_file == NULL)
595 DLOG(WARNING) << kOobeCompleteFlagFilePath << " doesn't exist."; 613 DLOG(WARNING) << oobe_complete_path.value() << " doesn't exist.";
596 else 614 else
597 file_util::CloseFile(oobe_flag_file); 615 file_util::CloseFile(oobe_flag_file);
598 } 616 }
599 } 617 }
600 618
601 // static 619 // static
602 bool WizardController::IsDeviceRegistered() { 620 bool WizardController::IsDeviceRegistered() {
603 int value = g_browser_process->local_state()->GetInteger(kDeviceRegistered); 621 int value = g_browser_process->local_state()->GetInteger(kDeviceRegistered);
604 if (value > 0) { 622 if (value > 0) {
605 // Recreate flag file in case it was lost. 623 // Recreate flag file in case it was lost.
606 BrowserThread::PostTask( 624 BrowserThread::PostTask(
607 BrowserThread::FILE, 625 BrowserThread::FILE,
608 FROM_HERE, 626 FROM_HERE,
609 base::Bind(&CreateOobeCompleteFlagFile)); 627 base::Bind(&CreateOobeCompleteFlagFile));
610 return true; 628 return true;
611 } else if (value == 0) { 629 } else if (value == 0) {
612 return false; 630 return false;
613 } else { 631 } else {
614 // Pref is not set. For compatibility check flag file. It causes blocking 632 // Pref is not set. For compatibility check flag file. It causes blocking
615 // IO on UI thread. But it's required for update from old versions. 633 // IO on UI thread. But it's required for update from old versions.
616 base::ThreadRestrictions::ScopedAllowIO allow_io; 634 base::ThreadRestrictions::ScopedAllowIO allow_io;
617 FilePath oobe_complete_flag_file_path(kOobeCompleteFlagFilePath); 635 FilePath oobe_complete_flag_file_path = GetOobeCompleteFlagPath();
636 DVLOG(1) << "Checking " << oobe_complete_flag_file_path.value();
618 bool file_exists = file_util::PathExists(oobe_complete_flag_file_path); 637 bool file_exists = file_util::PathExists(oobe_complete_flag_file_path);
619 SaveIntegerPreferenceForced(kDeviceRegistered, file_exists ? 1 : 0); 638 SaveIntegerPreferenceForced(kDeviceRegistered, file_exists ? 1 : 0);
620 return file_exists; 639 return file_exists;
621 } 640 }
622 } 641 }
623 642
624 // static 643 // static
625 void WizardController::MarkDeviceRegistered() { 644 void WizardController::MarkDeviceRegistered() {
626 SaveIntegerPreferenceForced(kDeviceRegistered, 1); 645 SaveIntegerPreferenceForced(kDeviceRegistered, 1);
627 BrowserThread::PostTask( 646 BrowserThread::PostTask(
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
720 739
721 bool WizardController::usage_statistics_reporting() const { 740 bool WizardController::usage_statistics_reporting() const {
722 return usage_statistics_reporting_; 741 return usage_statistics_reporting_;
723 } 742 }
724 743
725 void WizardController::SetZeroDelays() { 744 void WizardController::SetZeroDelays() {
726 kShowDelayMs = 0; 745 kShowDelayMs = 0;
727 } 746 }
728 747
729 } // namespace chromeos 748 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698