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

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

Issue 6893052: Make customization documents singletons. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nit Created 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/base_login_display_host.h" 5 #include "chrome/browser/chromeos/login/base_login_display_host.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/threading/thread_restrictions.h" 9 #include "base/threading/thread_restrictions.h"
10 #include "chrome/browser/browser_process.h" 10 #include "chrome/browser/browser_process.h"
11 #include "chrome/browser/chromeos/cros/cros_library.h" 11 #include "chrome/browser/chromeos/cros/cros_library.h"
12 #include "chrome/browser/chromeos/cros/input_method_library.h" 12 #include "chrome/browser/chromeos/cros/input_method_library.h"
13 #include "chrome/browser/chromeos/cros/login_library.h" 13 #include "chrome/browser/chromeos/cros/login_library.h"
14 #include "chrome/browser/chromeos/customization_document.h"
14 #include "chrome/browser/chromeos/input_method/input_method_util.h" 15 #include "chrome/browser/chromeos/input_method/input_method_util.h"
15 #include "chrome/browser/chromeos/language_preferences.h" 16 #include "chrome/browser/chromeos/language_preferences.h"
16 #include "chrome/browser/chromeos/login/apply_services_customization.h"
17 #include "chrome/browser/chromeos/login/existing_user_controller.h" 17 #include "chrome/browser/chromeos/login/existing_user_controller.h"
18 #include "chrome/browser/chromeos/login/helper.h" 18 #include "chrome/browser/chromeos/login/helper.h"
19 #include "chrome/browser/chromeos/login/language_switch_menu.h" 19 #include "chrome/browser/chromeos/login/language_switch_menu.h"
20 #include "chrome/browser/chromeos/login/login_utils.h" 20 #include "chrome/browser/chromeos/login/login_utils.h"
21 #include "chrome/browser/chromeos/login/user_manager.h" 21 #include "chrome/browser/chromeos/login/user_manager.h"
22 #include "chrome/browser/chromeos/login/views_login_display_host.h" 22 #include "chrome/browser/chromeos/login/views_login_display_host.h"
23 #include "chrome/browser/chromeos/login/wizard_controller.h" 23 #include "chrome/browser/chromeos/login/wizard_controller.h"
24 #include "chrome/browser/chromeos/system_access.h" 24 #include "chrome/browser/chromeos/system_access.h"
25 #include "chrome/browser/chromeos/wm_ipc.h" 25 #include "chrome/browser/chromeos/wm_ipc.h"
26 #include "chrome/browser/prefs/pref_service.h" 26 #include "chrome/browser/prefs/pref_service.h"
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 } 107 }
108 108
109 // LoginDisplayHost implementation --------------------------------------------- 109 // LoginDisplayHost implementation ---------------------------------------------
110 110
111 void BaseLoginDisplayHost::OnSessionStart() { 111 void BaseLoginDisplayHost::OnSessionStart() {
112 MessageLoop::current()->DeleteSoon(FROM_HERE, this); 112 MessageLoop::current()->DeleteSoon(FROM_HERE, this);
113 } 113 }
114 114
115 void BaseLoginDisplayHost::StartWizard( 115 void BaseLoginDisplayHost::StartWizard(
116 const std::string& first_screen_name, 116 const std::string& first_screen_name,
117 const chromeos::StartupCustomizationDocument* manifest,
118 const GURL& start_url) { 117 const GURL& start_url) {
119 DVLOG(1) << "Starting wizard, first_screen_name: " << first_screen_name; 118 DVLOG(1) << "Starting wizard, first_screen_name: " << first_screen_name;
120 // Create and show the wizard. 119 // Create and show the wizard.
121 wizard_controller_.reset(); // Only one controller in a time. 120 wizard_controller_.reset(); // Only one controller in a time.
122 wizard_controller_.reset(new WizardController(this, background_bounds_)); 121 wizard_controller_.reset(new WizardController(this, background_bounds_));
123 wizard_controller_->SetCustomization(manifest);
124 wizard_controller_->set_start_url(start_url); 122 wizard_controller_->set_start_url(start_url);
125 ShowBackground(); 123 ShowBackground();
126 if (!WizardController::IsDeviceRegistered()) 124 if (!WizardController::IsDeviceRegistered())
127 SetOobeProgressBarVisible(true); 125 SetOobeProgressBarVisible(true);
128 wizard_controller_->Init(first_screen_name); 126 wizard_controller_->Init(first_screen_name);
129 } 127 }
130 128
131 void BaseLoginDisplayHost::StartSignInScreen() { 129 void BaseLoginDisplayHost::StartSignInScreen() {
132 DVLOG(1) << "Starting sign in screen"; 130 DVLOG(1) << "Starting sign in screen";
133 std::vector<chromeos::UserManager::User> users = 131 std::vector<chromeos::UserManager::User> users =
134 chromeos::UserManager::Get()->GetUsers(); 132 chromeos::UserManager::Get()->GetUsers();
135 133
136 // Fix for users who updated device and thus never passed register screen. 134 // Fix for users who updated device and thus never passed register screen.
137 // If we already have users, we assume that it is not a second part of 135 // If we already have users, we assume that it is not a second part of
138 // OOBE. See http://crosbug.com/6289 136 // OOBE. See http://crosbug.com/6289
139 if (!WizardController::IsDeviceRegistered() && !users.empty()) { 137 if (!WizardController::IsDeviceRegistered() && !users.empty()) {
140 VLOG(1) << "Mark device registered because there are remembered users: " 138 VLOG(1) << "Mark device registered because there are remembered users: "
141 << users.size(); 139 << users.size();
142 WizardController::MarkDeviceRegistered(); 140 WizardController::MarkDeviceRegistered();
143 } 141 }
144 142
145 sign_in_controller_.reset(); // Only one controller in a time. 143 sign_in_controller_.reset(); // Only one controller in a time.
146 sign_in_controller_.reset(new chromeos::ExistingUserController(this)); 144 sign_in_controller_.reset(new chromeos::ExistingUserController(this));
147 ShowBackground(); 145 ShowBackground();
148 SetShutdownButtonEnabled(true); 146 SetShutdownButtonEnabled(true);
149 sign_in_controller_->Init(users); 147 sign_in_controller_->Init(users);
150 148
151 // Initiate services customization. 149 // Initiate services customization.
Nikita (slow) 2011/04/27 13:57:07 Nit: should say "Initiate service customization ma
Dmitry Polukhin 2011/04/27 14:56:15 Done.
152 chromeos::ApplyServicesCustomization::StartIfNeeded(); 150 if (!ServicesCustomizationDocument::WasApplied())
151 ServicesCustomizationDocument::GetInstance()->StartFetching();
153 } 152 }
154 153
155 // BaseLoginDisplayHost -------------------------------------------------------- 154 // BaseLoginDisplayHost --------------------------------------------------------
156 155
157 void BaseLoginDisplayHost::Observe(NotificationType type, 156 void BaseLoginDisplayHost::Observe(NotificationType type,
158 const NotificationSource& source, 157 const NotificationSource& source,
159 const NotificationDetails& details) { 158 const NotificationDetails& details) {
160 CHECK(type == NotificationType::APP_TERMINATING); 159 CHECK(type == NotificationType::APP_TERMINATING);
161 160
162 MessageLoop::current()->DeleteSoon(FROM_HERE, this); 161 MessageLoop::current()->DeleteSoon(FROM_HERE, this);
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 chromeos::LoginDisplayHost* display_host = 217 chromeos::LoginDisplayHost* display_host =
219 new chromeos::ViewsLoginDisplayHost(screen_bounds); 218 new chromeos::ViewsLoginDisplayHost(screen_bounds);
220 #endif 219 #endif
221 if (show_login_screen && chromeos::CrosLibrary::Get()->EnsureLoaded()) { 220 if (show_login_screen && chromeos::CrosLibrary::Get()->EnsureLoaded()) {
222 display_host->StartSignInScreen(); 221 display_host->StartSignInScreen();
223 return; 222 return;
224 } 223 }
225 224
226 // Load startup manifest. 225 // Load startup manifest.
227 const chromeos::StartupCustomizationDocument* startup_manifest = 226 const chromeos::StartupCustomizationDocument* startup_manifest =
228 chromeos::LoadStartupManifest(); 227 chromeos::StartupCustomizationDocument::GetInstance();
229 228
230 std::string locale; 229 std::string locale;
231 if (startup_manifest) { 230 if (startup_manifest->IsReady()) {
232 // Switch to initial locale if specified by customization 231 // Switch to initial locale if specified by customization
233 // and has not been set yet. We cannot call 232 // and has not been set yet. We cannot call
234 // chromeos::LanguageSwitchMenu::SwitchLanguage here before 233 // chromeos::LanguageSwitchMenu::SwitchLanguage here before
235 // EmitLoginPromptReady. 234 // EmitLoginPromptReady.
236 PrefService* prefs = g_browser_process->local_state(); 235 PrefService* prefs = g_browser_process->local_state();
237 const std::string current_locale = 236 const std::string current_locale =
238 prefs->GetString(prefs::kApplicationLocale); 237 prefs->GetString(prefs::kApplicationLocale);
239 VLOG(1) << "Current locale: " << current_locale; 238 VLOG(1) << "Current locale: " << current_locale;
240 if (current_locale.empty()) { 239 if (current_locale.empty()) {
241 locale = startup_manifest->initial_locale(); 240 locale = startup_manifest->initial_locale();
(...skipping 22 matching lines...) Expand all
264 ResourceBundle::ReloadSharedInstance(locale); 263 ResourceBundle::ReloadSharedInstance(locale);
265 CHECK(!loaded_locale.empty()) << "Locale could not be found for " 264 CHECK(!loaded_locale.empty()) << "Locale could not be found for "
266 << locale; 265 << locale;
267 // Set the application locale here so that the language switch 266 // Set the application locale here so that the language switch
268 // menu works properly with the newly loaded locale. 267 // menu works properly with the newly loaded locale.
269 g_browser_process->SetApplicationLocale(loaded_locale); 268 g_browser_process->SetApplicationLocale(loaded_locale);
270 } 269 }
271 } 270 }
272 } 271 }
273 272
274 display_host->StartWizard(first_screen_name, startup_manifest, GURL()); 273 display_host->StartWizard(first_screen_name, GURL());
275 274
276 chromeos::LoginUtils::Get()->PrewarmAuthentication(); 275 chromeos::LoginUtils::Get()->PrewarmAuthentication();
277 if (chromeos::CrosLibrary::Get()->EnsureLoaded()) 276 if (chromeos::CrosLibrary::Get()->EnsureLoaded())
278 chromeos::CrosLibrary::Get()->GetLoginLibrary()->EmitLoginPromptReady(); 277 chromeos::CrosLibrary::Get()->GetLoginLibrary()->EmitLoginPromptReady();
279 278
280 if (startup_manifest) { 279 if (startup_manifest->IsReady()) {
281 // Set initial timezone if specified by customization. 280 // Set initial timezone if specified by customization.
282 const std::string timezone_name = startup_manifest->initial_timezone(); 281 const std::string timezone_name = startup_manifest->initial_timezone();
283 VLOG(1) << "Initial time zone: " << timezone_name; 282 VLOG(1) << "Initial time zone: " << timezone_name;
284 // Apply locale customizations only once so preserve whatever locale 283 // Apply locale customizations only once so preserve whatever locale
285 // user has changed to during OOBE. 284 // user has changed to during OOBE.
286 if (!timezone_name.empty()) { 285 if (!timezone_name.empty()) {
287 icu::TimeZone* timezone = icu::TimeZone::createTimeZone( 286 icu::TimeZone* timezone = icu::TimeZone::createTimeZone(
288 icu::UnicodeString::fromUTF8(timezone_name)); 287 icu::UnicodeString::fromUTF8(timezone_name));
289 CHECK(timezone) << "Timezone could not be set for " << timezone_name; 288 CHECK(timezone) << "Timezone could not be set for " << timezone_name;
290 chromeos::SystemAccess::GetInstance()->SetTimezone(*timezone); 289 chromeos::SystemAccess::GetInstance()->SetTimezone(*timezone);
291 } 290 }
292 } 291 }
293 } 292 }
294 293
295 } // namespace browser 294 } // namespace browser
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698