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

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

Issue 3201003: Fixed error message bubbles according to the latest mocks (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Comments resolved Created 10 years, 4 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
OLDNEW
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/new_user_view.h" 5 #include "chrome/browser/chromeos/login/new_user_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>
11 #include <vector> 11 #include <vector>
12 12
13 #include "app/l10n_util.h" 13 #include "app/l10n_util.h"
14 #include "app/resource_bundle.h" 14 #include "app/resource_bundle.h"
15 #include "base/callback.h" 15 #include "base/callback.h"
16 #include "base/command_line.h" 16 #include "base/command_line.h"
17 #include "base/keyboard_codes.h" 17 #include "base/keyboard_codes.h"
18 #include "base/logging.h" 18 #include "base/logging.h"
19 #include "base/message_loop.h" 19 #include "base/message_loop.h"
20 #include "base/process_util.h" 20 #include "base/process_util.h"
21 #include "base/utf_string_conversions.h" 21 #include "base/utf_string_conversions.h"
22 #include "base/string_util.h" 22 #include "base/string_util.h"
23 #include "chrome/browser/chromeos/cros/cros_library.h" 23 #include "chrome/browser/chromeos/cros/cros_library.h"
24 #include "chrome/browser/chromeos/login/helper.h" 24 #include "chrome/browser/chromeos/login/helper.h"
25 #include "chrome/browser/chromeos/login/rounded_rect_painter.h" 25 #include "chrome/browser/chromeos/login/rounded_rect_painter.h"
26 #include "chrome/browser/google_util.h"
27 #include "grit/generated_resources.h" 26 #include "grit/generated_resources.h"
28 #include "views/controls/button/native_button.h" 27 #include "views/controls/button/native_button.h"
29 #include "views/controls/label.h" 28 #include "views/controls/label.h"
30 #include "views/controls/throbber.h" 29 #include "views/controls/throbber.h"
31 #include "views/widget/widget_gtk.h" 30 #include "views/widget/widget_gtk.h"
32 31
33 using views::Label; 32 using views::Label;
34 using views::Textfield; 33 using views::Textfield;
35 using views::View; 34 using views::View;
36 using views::WidgetGtk; 35 using views::WidgetGtk;
37 36
38 namespace { 37 namespace {
39 38
40 // NOTE: When adding new controls check RecreateNativeControls() 39 // NOTE: When adding new controls check RecreateNativeControls()
41 // that |sign_in_button_| is added with correct index. 40 // that |sign_in_button_| is added with correct index.
42 const int kSignInButtonFocusOrderIndex = 3; 41 const int kSignInButtonFocusOrderIndex = 3;
43 const int kTextfieldWidth = 286; 42 const int kTextfieldWidth = 286;
44 const int kRowPad = 7; 43 const int kRowPad = 7;
45 const int kColumnPad = 7; 44 const int kColumnPad = 7;
46 const int kLanguagesMenuWidth = 200; 45 const int kLanguagesMenuWidth = 200;
47 const int kLanguagesMenuHeight = 30; 46 const int kLanguagesMenuHeight = 30;
48 const SkColor kErrorColor = 0xFF8F384F; 47 const SkColor kErrorColor = 0xFF8F384F;
49 const char kDefaultDomain[] = "@gmail.com"; 48 const char kDefaultDomain[] = "@gmail.com";
50 49
51 const char kAccountRecoveryHelpUrl[] =
52 "http://www.google.com/support/accounts/bin/answer.py?answer=48598";
53
54 // Textfield that adds domain to the entered username if focus is lost and 50 // Textfield that adds domain to the entered username if focus is lost and
55 // username doesn't have full domain. 51 // username doesn't have full domain.
56 class UsernameField : public views::Textfield { 52 class UsernameField : public views::Textfield {
57 public: 53 public:
58 UsernameField() {} 54 UsernameField() {}
59 55
60 // views::Textfield overrides: 56 // views::Textfield overrides:
61 virtual void WillLoseFocus() { 57 virtual void WillLoseFocus() {
62 if (!text().empty()) { 58 if (!text().empty()) {
63 std::string username = UTF16ToUTF8(text()); 59 std::string username = UTF16ToUTF8(text());
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 } 341 }
346 342
347 void NewUserView::LinkActivated(views::Link* source, int event_flags) { 343 void NewUserView::LinkActivated(views::Link* source, int event_flags) {
348 if (source == create_account_link_) { 344 if (source == create_account_link_) {
349 delegate_->OnCreateAccount(); 345 delegate_->OnCreateAccount();
350 } else if (source == browse_without_signin_link_) { 346 } else if (source == browse_without_signin_link_) {
351 delegate_->OnLoginOffTheRecord(); 347 delegate_->OnLoginOffTheRecord();
352 } else if (source == cant_access_account_link_) { 348 } else if (source == cant_access_account_link_) {
353 // TODO(nkostylev): Display offline help when network is not connected. 349 // TODO(nkostylev): Display offline help when network is not connected.
354 // http://crosbug.com/3874 350 // http://crosbug.com/3874
355 delegate_->AddStartUrl( 351 delegate_->AddStartUrl(GetAccountRecoveryHelpUrl());
356 google_util::AppendGoogleLocaleParam(GURL(kAccountRecoveryHelpUrl)));
357 delegate_->OnLoginOffTheRecord(); 352 delegate_->OnLoginOffTheRecord();
358 } 353 }
359 } 354 }
360 355
361 void NewUserView::ClearAndEnablePassword() { 356 void NewUserView::ClearAndEnablePassword() {
362 login_in_process_ = false; 357 login_in_process_ = false;
363 EnableInputControls(true); 358 EnableInputControls(true);
364 SetPassword(std::string()); 359 SetPassword(std::string());
365 password_field_->RequestFocus(); 360 password_field_->RequestFocus();
366 throbber_->Stop(); 361 throbber_->Stop();
367 } 362 }
368 363
369 void NewUserView::ClearAndEnableFields() { 364 void NewUserView::ClearAndEnableFields() {
370 login_in_process_ = false; 365 login_in_process_ = false;
371 EnableInputControls(true); 366 EnableInputControls(true);
372 SetUsername(std::string()); 367 SetUsername(std::string());
373 SetPassword(std::string()); 368 SetPassword(std::string());
374 username_field_->RequestFocus(); 369 username_field_->RequestFocus();
375 throbber_->Stop(); 370 throbber_->Stop();
376 } 371 }
377 372
378 gfx::Rect NewUserView::GetPasswordBounds() const { 373 gfx::Rect NewUserView::GetPasswordBounds() const {
379 gfx::Rect screen_bounds(password_field_->bounds()); 374 return password_field_->GetScreenBounds();
380 gfx::Point origin(screen_bounds.origin()); 375 }
381 views::View::ConvertPointToScreen(password_field_->GetParent(), &origin); 376
382 screen_bounds.set_origin(origin); 377 gfx::Rect NewUserView::GetUsernameBounds() const {
383 return screen_bounds; 378 return username_field_->GetScreenBounds();
384 } 379 }
385 380
386 void NewUserView::StopThrobber() { 381 void NewUserView::StopThrobber() {
387 throbber_->Stop(); 382 throbber_->Stop();
388 } 383 }
389 384
390 bool NewUserView::HandleKeystroke(views::Textfield* s, 385 bool NewUserView::HandleKeystroke(views::Textfield* s,
391 const views::Textfield::Keystroke& keystroke) { 386 const views::Textfield::Keystroke& keystroke) {
392 if (!CrosLibrary::Get()->EnsureLoaded() || login_in_process_) 387 if (!CrosLibrary::Get()->EnsureLoaded() || login_in_process_)
393 return false; 388 return false;
(...skipping 25 matching lines...) Expand all
419 browse_without_signin_link_->SetEnabled(enabled); 414 browse_without_signin_link_->SetEnabled(enabled);
420 } 415 }
421 416
422 void NewUserView::InitLink(views::Link** link) { 417 void NewUserView::InitLink(views::Link** link) {
423 *link = new views::Link(std::wstring()); 418 *link = new views::Link(std::wstring());
424 (*link)->SetController(this); 419 (*link)->SetController(this);
425 AddChildView(*link); 420 AddChildView(*link);
426 } 421 }
427 422
428 } // namespace chromeos 423 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/new_user_view.h ('k') | chrome/browser/chromeos/login/screen_locker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698