OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <gdk/gdk.h> | 7 #include <gdk/gdk.h> |
8 #include <signal.h> | 8 #include <signal.h> |
9 #include <sys/types.h> | 9 #include <sys/types.h> |
10 | 10 |
11 #include <string> | 11 #include <string> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
15 #include "base/file_util.h" | 15 #include "base/file_util.h" |
16 #include "base/logging.h" | 16 #include "base/logging.h" |
17 #include "base/threading/thread_restrictions.h" | |
17 #include "chrome/browser/browser_process.h" | 18 #include "chrome/browser/browser_process.h" |
18 #include "chrome/browser/chromeos/cros/cros_library.h" | 19 #include "chrome/browser/chromeos/cros/cros_library.h" |
19 #include "chrome/browser/chromeos/cros/cryptohome_library.h" | 20 #include "chrome/browser/chromeos/cros/cryptohome_library.h" |
20 #include "chrome/browser/chromeos/cros/input_method_library.h" | 21 #include "chrome/browser/chromeos/cros/input_method_library.h" |
21 #include "chrome/browser/chromeos/cros/login_library.h" | 22 #include "chrome/browser/chromeos/cros/login_library.h" |
22 #include "chrome/browser/chromeos/cros/system_library.h" | 23 #include "chrome/browser/chromeos/cros/system_library.h" |
23 #include "chrome/browser/chromeos/customization_document.h" | 24 #include "chrome/browser/chromeos/customization_document.h" |
24 #include "chrome/browser/chromeos/input_method/input_method_util.h" | 25 #include "chrome/browser/chromeos/input_method/input_method_util.h" |
25 #include "chrome/browser/chromeos/language_preferences.h" | 26 #include "chrome/browser/chromeos/language_preferences.h" |
26 #include "chrome/browser/chromeos/login/account_screen.h" | 27 #include "chrome/browser/chromeos/login/account_screen.h" |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
185 // Launch browser after controller is deleted and its windows are closed. | 186 // Launch browser after controller is deleted and its windows are closed. |
186 chromeos::LoginUtils::Get()->EnableBrowserLaunch(true); | 187 chromeos::LoginUtils::Get()->EnableBrowserLaunch(true); |
187 BrowserThread::PostTask( | 188 BrowserThread::PostTask( |
188 BrowserThread::UI, | 189 BrowserThread::UI, |
189 FROM_HERE, | 190 FROM_HERE, |
190 NewRunnableFunction(&chromeos::LoginUtils::DoBrowserLaunch, | 191 NewRunnableFunction(&chromeos::LoginUtils::DoBrowserLaunch, |
191 ProfileManager::GetDefaultProfile())); | 192 ProfileManager::GetDefaultProfile())); |
192 } | 193 } |
193 | 194 |
194 const chromeos::StartupCustomizationDocument* LoadStartupManifest() { | 195 const chromeos::StartupCustomizationDocument* LoadStartupManifest() { |
195 // Load partner customization startup manifest if it is available. | 196 // Loading manifest causes us to do blocking IO on UI thread. |
197 // Temporarily allow it until we fix http://crosbug.com/11103 | |
198 base::ThreadRestrictions::ScopedAllowIO allow_io; | |
196 FilePath startup_manifest_path(kStartupCustomizationManifestPath); | 199 FilePath startup_manifest_path(kStartupCustomizationManifestPath); |
197 if (file_util::PathExists(startup_manifest_path)) { | 200 if (file_util::PathExists(startup_manifest_path)) { |
198 scoped_ptr<chromeos::StartupCustomizationDocument> customization( | 201 scoped_ptr<chromeos::StartupCustomizationDocument> customization( |
199 new chromeos::StartupCustomizationDocument()); | 202 new chromeos::StartupCustomizationDocument()); |
200 bool manifest_loaded = customization->LoadManifestFromFile( | 203 bool manifest_loaded = customization->LoadManifestFromFile( |
201 startup_manifest_path); | 204 startup_manifest_path); |
202 if (manifest_loaded) { | 205 if (manifest_loaded) { |
203 VLOG(1) << "Startup manifest loaded successfully"; | 206 VLOG(1) << "Startup manifest loaded successfully"; |
204 return customization.release(); | 207 return customization.release(); |
205 } | 208 } |
(...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
821 SaveBoolPreferenceForced(kEulaAccepted, true); | 824 SaveBoolPreferenceForced(kEulaAccepted, true); |
822 } | 825 } |
823 | 826 |
824 // static | 827 // static |
825 void WizardController::MarkOobeCompleted() { | 828 void WizardController::MarkOobeCompleted() { |
826 SaveBoolPreferenceForced(kOobeComplete, true); | 829 SaveBoolPreferenceForced(kOobeComplete, true); |
827 } | 830 } |
828 | 831 |
829 // static | 832 // static |
830 bool WizardController::IsDeviceRegistered() { | 833 bool WizardController::IsDeviceRegistered() { |
834 // Checking for flag file causes us to do blocking IO on UI thread. | |
835 // Temporarily allow it until we fix http://crbug.com/70131 | |
836 base::ThreadRestrictions::ScopedAllowIO allow_io; | |
831 FilePath oobe_complete_flag_file_path(kOobeCompleteFlagFilePath); | 837 FilePath oobe_complete_flag_file_path(kOobeCompleteFlagFilePath); |
832 return file_util::PathExists(oobe_complete_flag_file_path); | 838 return file_util::PathExists(oobe_complete_flag_file_path); |
833 } | 839 } |
834 | 840 |
835 // static | 841 // static |
836 bool WizardController::IsRegisterScreenDefined() { | 842 bool WizardController::IsRegisterScreenDefined() { |
837 const chromeos::StartupCustomizationDocument* manifest = NULL; | 843 const chromeos::StartupCustomizationDocument* manifest = NULL; |
838 // This method will be called from ExistingUserController too | 844 // This method will be called from ExistingUserController too |
839 // when Wizard instance doesn't exist. | 845 // when Wizard instance doesn't exist. |
840 if (default_controller()) | 846 if (default_controller()) |
841 manifest = default_controller()->GetCustomization(); | 847 manifest = default_controller()->GetCustomization(); |
842 else | 848 else |
843 manifest = LoadStartupManifest(); | 849 manifest = LoadStartupManifest(); |
844 return IsRegistrationScreenValid(manifest); | 850 return IsRegistrationScreenValid(manifest); |
845 } | 851 } |
846 | 852 |
847 // static | 853 // static |
848 void WizardController::MarkDeviceRegistered() { | 854 void WizardController::MarkDeviceRegistered() { |
855 // Creating flag file causes us to do blocking IO on UI thread. | |
856 // Temporarily allow it until we fix http://crbug.com/70131 | |
857 base::ThreadRestrictions::ScopedAllowIO allow_io; | |
849 // Create flag file for boot-time init scripts. | 858 // Create flag file for boot-time init scripts. |
850 FilePath oobe_complete_path(kOobeCompleteFlagFilePath); | 859 FilePath oobe_complete_path(kOobeCompleteFlagFilePath); |
851 FILE* oobe_flag_file = file_util::OpenFile(oobe_complete_path, "w+b"); | 860 FILE* oobe_flag_file = file_util::OpenFile(oobe_complete_path, "w+b"); |
852 DCHECK(oobe_flag_file != NULL) << kOobeCompleteFlagFilePath; | 861 DCHECK(oobe_flag_file != NULL) << kOobeCompleteFlagFilePath; |
853 if (oobe_flag_file != NULL) | 862 if (oobe_flag_file != NULL) |
854 file_util::CloseFile(oobe_flag_file); | 863 file_util::CloseFile(oobe_flag_file); |
855 } | 864 } |
856 | 865 |
857 /////////////////////////////////////////////////////////////////////////////// | 866 /////////////////////////////////////////////////////////////////////////////// |
858 // WizardController, chromeos::ScreenObserver overrides: | 867 // WizardController, chromeos::ScreenObserver overrides: |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1002 // chromeos::LanguageSwitchMenu::SwitchLanguage here before | 1011 // chromeos::LanguageSwitchMenu::SwitchLanguage here before |
1003 // EmitLoginPromptReady. | 1012 // EmitLoginPromptReady. |
1004 const std::string current_locale = | 1013 const std::string current_locale = |
1005 g_browser_process->local_state()->GetString( | 1014 g_browser_process->local_state()->GetString( |
1006 prefs::kApplicationLocale); | 1015 prefs::kApplicationLocale); |
1007 VLOG(1) << "Current locale: " << current_locale; | 1016 VLOG(1) << "Current locale: " << current_locale; |
1008 if (current_locale.empty()) { | 1017 if (current_locale.empty()) { |
1009 locale = controller->GetCustomization()->initial_locale(); | 1018 locale = controller->GetCustomization()->initial_locale(); |
1010 VLOG(1) << "Initial locale: " << locale; | 1019 VLOG(1) << "Initial locale: " << locale; |
1011 if (!locale.empty()) { | 1020 if (!locale.empty()) { |
1012 const std::string loaded_locale = | 1021 { |
Dmitry Polukhin
2011/01/24 11:32:02
You are already in scope "if () {". There is no ne
Nikita (slow)
2011/01/24 12:55:33
Done.
| |
1013 ResourceBundle::ReloadSharedInstance(locale); | 1022 // Reloading resource bundle causes us to do blocking IO on UI thread. |
1014 CHECK(!loaded_locale.empty()) << "Locale could not be found for " | 1023 // Temporarily allow it until we fix http://crosbug.com/11102 |
1015 << locale; | 1024 base::ThreadRestrictions::ScopedAllowIO allow_io; |
1025 const std::string loaded_locale = | |
1026 ResourceBundle::ReloadSharedInstance(locale); | |
1027 CHECK(!loaded_locale.empty()) << "Locale could not be found for " | |
1028 << locale; | |
1029 } | |
1016 } | 1030 } |
1017 } | 1031 } |
1018 } | 1032 } |
1019 | 1033 |
1020 controller->ShowBackground(screen_bounds); | 1034 controller->ShowBackground(screen_bounds); |
1021 controller->Init(first_screen_name, screen_bounds); | 1035 controller->Init(first_screen_name, screen_bounds); |
1022 controller->Show(); | 1036 controller->Show(); |
1023 | 1037 |
1024 chromeos::LoginUtils::Get()->PrewarmAuthentication(); | 1038 chromeos::LoginUtils::Get()->PrewarmAuthentication(); |
1025 if (chromeos::CrosLibrary::Get()->EnsureLoaded()) | 1039 if (chromeos::CrosLibrary::Get()->EnsureLoaded()) |
(...skipping 11 matching lines...) Expand all Loading... | |
1037 // user has changed to during OOBE. | 1051 // user has changed to during OOBE. |
1038 if (!timezone_name.empty()) { | 1052 if (!timezone_name.empty()) { |
1039 icu::TimeZone* timezone = icu::TimeZone::createTimeZone( | 1053 icu::TimeZone* timezone = icu::TimeZone::createTimeZone( |
1040 icu::UnicodeString::fromUTF8(timezone_name)); | 1054 icu::UnicodeString::fromUTF8(timezone_name)); |
1041 chromeos::CrosLibrary::Get()->GetSystemLibrary()->SetTimezone(timezone); | 1055 chromeos::CrosLibrary::Get()->GetSystemLibrary()->SetTimezone(timezone); |
1042 } | 1056 } |
1043 } | 1057 } |
1044 } | 1058 } |
1045 | 1059 |
1046 } // namespace browser | 1060 } // namespace browser |
OLD | NEW |