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

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

Issue 1142005: Mocks for all libcros elements (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 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
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/login_manager_view.h" 5 #include "chrome/browser/chromeos/login/login_manager_view.h"
6 6
7 #include <signal.h> 7 #include <signal.h>
8 #include <sys/types.h> 8 #include <sys/types.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 // Restore previously logged in user. 150 // Restore previously logged in user.
151 std::vector<UserManager::User> users = UserManager::Get()->GetUsers(); 151 std::vector<UserManager::User> users = UserManager::Get()->GetUsers();
152 if (users.size() > 0) { 152 if (users.size() > 0) {
153 username_field_->SetText(UTF8ToUTF16(users[0].email())); 153 username_field_->SetText(UTF8ToUTF16(users[0].email()));
154 } 154 }
155 RequestFocus(); 155 RequestFocus();
156 156
157 // Controller to handle events from textfields 157 // Controller to handle events from textfields
158 username_field_->SetController(this); 158 username_field_->SetController(this);
159 password_field_->SetController(this); 159 password_field_->SetController(this);
160 if (CrosLibrary::EnsureLoaded()) { 160 if (CrosLibrary::Get()->EnsureLoaded()) {
161 loader_.GetVersion( 161 loader_.GetVersion(
162 &consumer_, NewCallback(this, &LoginManagerView::OnOSVersion)); 162 &consumer_, NewCallback(this, &LoginManagerView::OnOSVersion));
163 } else if (!kStubOutLogin) { 163 } else if (!kStubOutLogin) {
164 error_label_->SetText( 164 error_label_->SetText(
165 ASCIIToWide(CrosLibrary::load_error_string())); 165 ASCIIToWide(CrosLibrary::Get()->load_error_string()));
166 username_field_->SetReadOnly(true); 166 username_field_->SetReadOnly(true);
167 password_field_->SetReadOnly(true); 167 password_field_->SetReadOnly(true);
168 } 168 }
169 } 169 }
170 170
171 void LoginManagerView::UpdateLocalizedStrings() { 171 void LoginManagerView::UpdateLocalizedStrings() {
172 title_label_->SetText(l10n_util::GetString(IDS_LOGIN_TITLE)); 172 title_label_->SetText(l10n_util::GetString(IDS_LOGIN_TITLE));
173 username_label_->SetText(l10n_util::GetString(IDS_LOGIN_USERNAME)); 173 username_label_->SetText(l10n_util::GetString(IDS_LOGIN_USERNAME));
174 password_label_->SetText(l10n_util::GetString(IDS_LOGIN_PASSWORD)); 174 password_label_->SetText(l10n_util::GetString(IDS_LOGIN_PASSWORD));
175 sign_in_button_->SetLabel(l10n_util::GetString(IDS_LOGIN_BUTTON)); 175 sign_in_button_->SetLabel(l10n_util::GetString(IDS_LOGIN_BUTTON));
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 views::Button* sender, const views::Event& event) { 309 views::Button* sender, const views::Event& event) {
310 if (sender == sign_in_button_) { 310 if (sender == sign_in_button_) {
311 Login(); 311 Login();
312 } else { 312 } else {
313 observer_->OnExit(ScreenObserver::LOGIN_CREATE_ACCOUNT); 313 observer_->OnExit(ScreenObserver::LOGIN_CREATE_ACCOUNT);
314 } 314 }
315 } 315 }
316 316
317 void LoginManagerView::OnLoginFailure(const std::string error) { 317 void LoginManagerView::OnLoginFailure(const std::string error) {
318 LOG(INFO) << "LoginManagerView: OnLoginFailure() " << error; 318 LOG(INFO) << "LoginManagerView: OnLoginFailure() " << error;
319 NetworkLibrary* network = NetworkLibrary::Get(); 319 NetworkLibrary* network = CrosLibrary::Get()->GetNetworkLibrary();
320 320
321 // Send notification of failure 321 // Send notification of failure
322 AuthenticationNotificationDetails details(false); 322 AuthenticationNotificationDetails details(false);
323 NotificationService::current()->Notify( 323 NotificationService::current()->Notify(
324 NotificationType::LOGIN_AUTHENTICATION, Source<LoginManagerView>(this), 324 NotificationType::LOGIN_AUTHENTICATION, Source<LoginManagerView>(this),
325 Details<AuthenticationNotificationDetails>(&details)); 325 Details<AuthenticationNotificationDetails>(&details));
326 326
327 // Check networking after trying to login in case user is 327 // Check networking after trying to login in case user is
328 // cached locally or the local admin account. 328 // cached locally or the local admin account.
329 if (!network || !CrosLibrary::EnsureLoaded()) 329 if (!network || !CrosLibrary::Get()->EnsureLoaded())
330 ShowError(IDS_LOGIN_ERROR_NO_NETWORK_LIBRARY); 330 ShowError(IDS_LOGIN_ERROR_NO_NETWORK_LIBRARY);
331 else if (!network->Connected()) 331 else if (!network->Connected())
332 ShowError(IDS_LOGIN_ERROR_NETWORK_NOT_CONNECTED); 332 ShowError(IDS_LOGIN_ERROR_NETWORK_NOT_CONNECTED);
333 else 333 else
334 ShowError(IDS_LOGIN_ERROR_AUTHENTICATING); 334 ShowError(IDS_LOGIN_ERROR_AUTHENTICATING);
335 // TODO(someone): get |error| onto the UI somehow? 335 // TODO(someone): get |error| onto the UI somehow?
336 } 336 }
337 337
338 void LoginManagerView::OnLoginSuccess(const std::string username, 338 void LoginManagerView::OnLoginSuccess(const std::string username,
339 std::vector<std::string> cookies) { 339 std::vector<std::string> cookies) {
340 // TODO(cmasone): something sensible if errors occur. 340 // TODO(cmasone): something sensible if errors occur.
341 if (observer_) { 341 if (observer_) {
342 observer_->OnExit(ScreenObserver::LOGIN_SIGN_IN_SELECTED); 342 observer_->OnExit(ScreenObserver::LOGIN_SIGN_IN_SELECTED);
343 } 343 }
344 login_utils::CompleteLogin(username, cookies); 344 login_utils::CompleteLogin(username, cookies);
345 } 345 }
346 346
347 void LoginManagerView::ShowError(int error_id) { 347 void LoginManagerView::ShowError(int error_id) {
348 error_id_ = error_id; 348 error_id_ = error_id;
349 error_label_->SetText((error_id_ == -1) 349 error_label_->SetText((error_id_ == -1)
350 ? std::wstring() 350 ? std::wstring()
351 : l10n_util::GetString(error_id_)); 351 : l10n_util::GetString(error_id_));
352 } 352 }
353 353
354 bool LoginManagerView::HandleKeystroke(views::Textfield* s, 354 bool LoginManagerView::HandleKeystroke(views::Textfield* s,
355 const views::Textfield::Keystroke& keystroke) { 355 const views::Textfield::Keystroke& keystroke) {
356 if (!kStubOutLogin && !CrosLibrary::EnsureLoaded()) 356 if (!kStubOutLogin && !CrosLibrary::Get()->EnsureLoaded())
357 return false; 357 return false;
358 358
359 if (keystroke.GetKeyboardCode() == base::VKEY_TAB) { 359 if (keystroke.GetKeyboardCode() == base::VKEY_TAB) {
360 if (username_field_->text().length() != 0) { 360 if (username_field_->text().length() != 0) {
361 std::string username = UTF16ToUTF8(username_field_->text()); 361 std::string username = UTF16ToUTF8(username_field_->text());
362 362
363 if (username.find('@') == std::string::npos) { 363 if (username.find('@') == std::string::npos) {
364 username += kDefaultDomain; 364 username += kDefaultDomain;
365 username_field_->SetText(UTF8ToUTF16(username)); 365 username_field_->SetText(UTF8ToUTF16(username));
366 } 366 }
(...skipping 14 matching lines...) Expand all
381 return false; 381 return false;
382 } 382 }
383 383
384 void LoginManagerView::OnOSVersion( 384 void LoginManagerView::OnOSVersion(
385 VersionLoader::Handle handle, 385 VersionLoader::Handle handle,
386 std::string version) { 386 std::string version) {
387 os_version_label_->SetText(ASCIIToWide(version)); 387 os_version_label_->SetText(ASCIIToWide(version));
388 } 388 }
389 389
390 } // namespace chromeos 390 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698