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

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

Issue 2920001: EULA screen implemented.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 5 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) 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 "app/l10n_util.h" 14 #include "app/l10n_util.h"
15 #include "base/command_line.h" 15 #include "base/command_line.h"
16 #include "base/logging.h" // For NOTREACHED. 16 #include "base/logging.h" // For NOTREACHED.
17 #include "chrome/browser/browser_process.h" 17 #include "chrome/browser/browser_process.h"
18 #include "chrome/browser/chromeos/cros/cros_library.h" 18 #include "chrome/browser/chromeos/cros/cros_library.h"
19 #include "chrome/browser/chromeos/cros/login_library.h" 19 #include "chrome/browser/chromeos/cros/login_library.h"
20 #include "chrome/browser/chromeos/cros/system_library.h" 20 #include "chrome/browser/chromeos/cros/system_library.h"
21 #include "chrome/browser/chromeos/customization_document.h" 21 #include "chrome/browser/chromeos/customization_document.h"
22 #include "chrome/browser/chromeos/input_method/input_method_util.h" 22 #include "chrome/browser/chromeos/input_method/input_method_util.h"
23 #include "chrome/browser/chromeos/login/account_screen.h" 23 #include "chrome/browser/chromeos/login/account_screen.h"
24 #include "chrome/browser/chromeos/login/background_view.h" 24 #include "chrome/browser/chromeos/login/background_view.h"
25 #include "chrome/browser/chromeos/login/eula_view.h"
25 #include "chrome/browser/chromeos/login/existing_user_controller.h" 26 #include "chrome/browser/chromeos/login/existing_user_controller.h"
26 #include "chrome/browser/chromeos/login/helper.h" 27 #include "chrome/browser/chromeos/login/helper.h"
27 #include "chrome/browser/chromeos/login/language_switch_menu.h" 28 #include "chrome/browser/chromeos/login/language_switch_menu.h"
28 #include "chrome/browser/chromeos/login/login_screen.h" 29 #include "chrome/browser/chromeos/login/login_screen.h"
29 #include "chrome/browser/chromeos/login/login_utils.h" 30 #include "chrome/browser/chromeos/login/login_utils.h"
30 #include "chrome/browser/chromeos/login/network_screen.h" 31 #include "chrome/browser/chromeos/login/network_screen.h"
31 #include "chrome/browser/chromeos/login/registration_screen.h" 32 #include "chrome/browser/chromeos/login/registration_screen.h"
32 #include "chrome/browser/chromeos/login/rounded_rect_painter.h" 33 #include "chrome/browser/chromeos/login/rounded_rect_painter.h"
33 #include "chrome/browser/chromeos/login/update_screen.h" 34 #include "chrome/browser/chromeos/login/update_screen.h"
34 #include "chrome/browser/chromeos/login/user_image_screen.h" 35 #include "chrome/browser/chromeos/login/user_image_screen.h"
35 #include "chrome/browser/chromeos/login/user_manager.h" 36 #include "chrome/browser/chromeos/login/user_manager.h"
36 #include "chrome/browser/chromeos/wm_ipc.h" 37 #include "chrome/browser/chromeos/wm_ipc.h"
37 #include "chrome/browser/pref_service.h" 38 #include "chrome/browser/pref_service.h"
38 #include "chrome/browser/profile_manager.h" 39 #include "chrome/browser/profile_manager.h"
39 #include "chrome/common/chrome_switches.h" 40 #include "chrome/common/chrome_switches.h"
40 #include "chrome/common/notification_service.h" 41 #include "chrome/common/notification_service.h"
41 #include "third_party/cros/chromeos_wm_ipc_enums.h" 42 #include "third_party/cros/chromeos_wm_ipc_enums.h"
43 #include "unicode/timezone.h"
42 #include "views/accelerator.h" 44 #include "views/accelerator.h"
43 #include "views/painter.h" 45 #include "views/painter.h"
44 #include "views/view.h" 46 #include "views/view.h"
45 #include "views/widget/widget_gtk.h" 47 #include "views/widget/widget_gtk.h"
46 #include "unicode/timezone.h"
47 48
48 namespace { 49 namespace {
49 50
50 // A boolean pref of the OOBE complete flag. 51 // A boolean pref of the OOBE complete flag.
51 const wchar_t kOobeComplete[] = L"OobeComplete"; 52 const wchar_t kOobeComplete[] = L"OobeComplete";
52 53
53 // Default size of the OOBE screen. 54 // Default size of the OOBE screen.
54 const int kWizardScreenWidth = 700; 55 const int kWizardScreenWidth = 700;
55 const int kWizardScreenHeight = 416; 56 const int kWizardScreenHeight = 416;
56 57
57 // RootView of the Widget WizardController creates. Contains the contents of the 58 // RootView of the Widget WizardController creates. Contains the contents of the
58 // WizardController. 59 // WizardController.
59 class ContentView : public views::View { 60 class ContentView : public views::View {
60 public: 61 public:
61 ContentView(int window_x, int window_y, int screen_w, int screen_h) 62 ContentView(int window_x, int window_y, int screen_w, int screen_h)
62 : window_x_(window_x), 63 : window_x_(window_x),
63 window_y_(window_y), 64 window_y_(window_y),
64 screen_w_(screen_w), 65 screen_w_(screen_w),
65 screen_h_(screen_h), 66 screen_h_(screen_h),
66 accel_account_screen_(views::Accelerator(base::VKEY_A, 67 accel_account_screen_(views::Accelerator(base::VKEY_A,
67 false, true, true)), 68 false, true, true)),
68 accel_login_screen_(views::Accelerator(base::VKEY_L, 69 accel_login_screen_(views::Accelerator(base::VKEY_L,
69 false, true, true)), 70 false, true, true)),
70 accel_network_screen_(views::Accelerator(base::VKEY_N, 71 accel_network_screen_(views::Accelerator(base::VKEY_N,
71 false, true, true)), 72 false, true, true)),
72 accel_update_screen_(views::Accelerator(base::VKEY_U, 73 accel_update_screen_(views::Accelerator(base::VKEY_U,
73 false, true, true)), 74 false, true, true)),
74 accel_image_screen_(views::Accelerator(base::VKEY_I, 75 accel_image_screen_(views::Accelerator(base::VKEY_I,
76 false, true, true)),
77 accel_eula_screen_(views::Accelerator(base::VKEY_E,
75 false, true, true)) { 78 false, true, true)) {
76 AddAccelerator(accel_account_screen_); 79 AddAccelerator(accel_account_screen_);
77 AddAccelerator(accel_login_screen_); 80 AddAccelerator(accel_login_screen_);
78 AddAccelerator(accel_network_screen_); 81 AddAccelerator(accel_network_screen_);
79 AddAccelerator(accel_update_screen_); 82 AddAccelerator(accel_update_screen_);
80 AddAccelerator(accel_image_screen_); 83 AddAccelerator(accel_image_screen_);
84 AddAccelerator(accel_eula_screen_);
81 } 85 }
82 86
83 ~ContentView() { 87 ~ContentView() {
84 NotificationService::current()->Notify( 88 NotificationService::current()->Notify(
85 NotificationType::WIZARD_CONTENT_VIEW_DESTROYED, 89 NotificationType::WIZARD_CONTENT_VIEW_DESTROYED,
86 NotificationService::AllSources(), 90 NotificationService::AllSources(),
87 NotificationService::NoDetails()); 91 NotificationService::NoDetails());
88 } 92 }
89 93
90 bool AcceleratorPressed(const views::Accelerator& accel) { 94 bool AcceleratorPressed(const views::Accelerator& accel) {
91 WizardController* controller = WizardController::default_controller(); 95 WizardController* controller = WizardController::default_controller();
92 if (!controller) 96 if (!controller)
93 return false; 97 return false;
94 98
95 if (accel == accel_account_screen_) { 99 if (accel == accel_account_screen_) {
96 controller->ShowAccountScreen(); 100 controller->ShowAccountScreen();
97 } else if (accel == accel_login_screen_) { 101 } else if (accel == accel_login_screen_) {
98 controller->ShowLoginScreen(); 102 controller->ShowLoginScreen();
99 } else if (accel == accel_network_screen_) { 103 } else if (accel == accel_network_screen_) {
100 controller->ShowNetworkScreen(); 104 controller->ShowNetworkScreen();
101 } else if (accel == accel_update_screen_) { 105 } else if (accel == accel_update_screen_) {
102 controller->ShowUpdateScreen(); 106 controller->ShowUpdateScreen();
103 } else if (accel == accel_image_screen_) { 107 } else if (accel == accel_image_screen_) {
104 controller->ShowUserImageScreen(); 108 controller->ShowUserImageScreen();
109 } else if (accel == accel_eula_screen_) {
110 controller->ShowEulaScreen();
105 } else { 111 } else {
106 return false; 112 return false;
107 } 113 }
108 114
109 return true; 115 return true;
110 } 116 }
111 117
112 void PaintBackground(gfx::Canvas* canvas) { 118 void PaintBackground(gfx::Canvas* canvas) {
113 if (painter_.get()) { 119 if (painter_.get()) {
114 // TODO(sky): nuke this once new login manager is in place. This needs to 120 // TODO(sky): nuke this once new login manager is in place. This needs to
(...skipping 18 matching lines...) Expand all
133 const int window_x_; 139 const int window_x_;
134 const int window_y_; 140 const int window_y_;
135 const int screen_w_; 141 const int screen_w_;
136 const int screen_h_; 142 const int screen_h_;
137 143
138 views::Accelerator accel_account_screen_; 144 views::Accelerator accel_account_screen_;
139 views::Accelerator accel_login_screen_; 145 views::Accelerator accel_login_screen_;
140 views::Accelerator accel_network_screen_; 146 views::Accelerator accel_network_screen_;
141 views::Accelerator accel_update_screen_; 147 views::Accelerator accel_update_screen_;
142 views::Accelerator accel_image_screen_; 148 views::Accelerator accel_image_screen_;
149 views::Accelerator accel_eula_screen_;
143 150
144 DISALLOW_COPY_AND_ASSIGN(ContentView); 151 DISALLOW_COPY_AND_ASSIGN(ContentView);
145 }; 152 };
146 153
147 void DeleteWizardControllerAndLaunchBrowser(WizardController* controller) { 154 void DeleteWizardControllerAndLaunchBrowser(WizardController* controller) {
148 delete controller; 155 delete controller;
149 // Launch browser after controller is deleted and its windows are closed. 156 // Launch browser after controller is deleted and its windows are closed.
150 chromeos::LoginUtils::Get()->EnableBrowserLaunch(true); 157 chromeos::LoginUtils::Get()->EnableBrowserLaunch(true);
151 ChromeThread::PostTask( 158 ChromeThread::PostTask(
152 ChromeThread::UI, 159 ChromeThread::UI,
153 FROM_HERE, 160 FROM_HERE,
154 NewRunnableFunction(&chromeos::LoginUtils::DoBrowserLaunch, 161 NewRunnableFunction(&chromeos::LoginUtils::DoBrowserLaunch,
155 ProfileManager::GetDefaultProfile())); 162 ProfileManager::GetDefaultProfile()));
156 } 163 }
157 164
158 } // namespace 165 } // namespace
159 166
160 const char WizardController::kNetworkScreenName[] = "network"; 167 const char WizardController::kNetworkScreenName[] = "network";
161 const char WizardController::kLoginScreenName[] = "login"; 168 const char WizardController::kLoginScreenName[] = "login";
162 const char WizardController::kAccountScreenName[] = "account"; 169 const char WizardController::kAccountScreenName[] = "account";
163 const char WizardController::kUpdateScreenName[] = "update"; 170 const char WizardController::kUpdateScreenName[] = "update";
164 const char WizardController::kUserImageScreenName[] = "image"; 171 const char WizardController::kUserImageScreenName[] = "image";
172 const char WizardController::kEulaScreenName[] = "eula";
165 const char WizardController::kRegistrationScreenName[] = "register"; 173 const char WizardController::kRegistrationScreenName[] = "register";
166 174
167 // Passing this parameter as a "first screen" initiates full OOBE flow. 175 // Passing this parameter as a "first screen" initiates full OOBE flow.
168 const char WizardController::kOutOfBoxScreenName[] = "oobe"; 176 const char WizardController::kOutOfBoxScreenName[] = "oobe";
169 177
170 // Special test value that commands not to create any window yet. 178 // Special test value that commands not to create any window yet.
171 const char WizardController::kTestNoScreenName[] = "test:nowindow"; 179 const char WizardController::kTestNoScreenName[] = "test:nowindow";
172 180
173 // Initialize default controller. 181 // Initialize default controller.
174 // static 182 // static
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 update_screen_.reset(new chromeos::UpdateScreen(this)); 295 update_screen_.reset(new chromeos::UpdateScreen(this));
288 return update_screen_.get(); 296 return update_screen_.get();
289 } 297 }
290 298
291 chromeos::UserImageScreen* WizardController::GetUserImageScreen() { 299 chromeos::UserImageScreen* WizardController::GetUserImageScreen() {
292 if (!user_image_screen_.get()) 300 if (!user_image_screen_.get())
293 user_image_screen_.reset(new chromeos::UserImageScreen(this)); 301 user_image_screen_.reset(new chromeos::UserImageScreen(this));
294 return user_image_screen_.get(); 302 return user_image_screen_.get();
295 } 303 }
296 304
305 chromeos::EulaScreen* WizardController::GetEulaScreen() {
306 if (!eula_screen_.get())
307 eula_screen_.reset(new chromeos::EulaScreen(this));
308 return eula_screen_.get();
309 }
310
297 chromeos::RegistrationScreen* WizardController::GetRegistrationScreen() { 311 chromeos::RegistrationScreen* WizardController::GetRegistrationScreen() {
298 if (!registration_screen_.get()) 312 if (!registration_screen_.get())
299 registration_screen_.reset(new chromeos::RegistrationScreen(this)); 313 registration_screen_.reset(new chromeos::RegistrationScreen(this));
300 return registration_screen_.get(); 314 return registration_screen_.get();
301 } 315 }
302 316
303 void WizardController::ShowNetworkScreen() { 317 void WizardController::ShowNetworkScreen() {
304 SetStatusAreaVisible(false); 318 SetStatusAreaVisible(false);
305 SetCurrentScreen(GetNetworkScreen()); 319 SetCurrentScreen(GetNetworkScreen());
306 } 320 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 void WizardController::ShowUpdateScreen() { 353 void WizardController::ShowUpdateScreen() {
340 SetStatusAreaVisible(true); 354 SetStatusAreaVisible(true);
341 SetCurrentScreen(GetUpdateScreen()); 355 SetCurrentScreen(GetUpdateScreen());
342 } 356 }
343 357
344 void WizardController::ShowUserImageScreen() { 358 void WizardController::ShowUserImageScreen() {
345 SetStatusAreaVisible(true); 359 SetStatusAreaVisible(true);
346 SetCurrentScreen(GetUserImageScreen()); 360 SetCurrentScreen(GetUserImageScreen());
347 } 361 }
348 362
363 void WizardController::ShowEulaScreen() {
364 SetStatusAreaVisible(false);
365 SetCurrentScreen(GetEulaScreen());
366 }
367
349 void WizardController::ShowRegistrationScreen() { 368 void WizardController::ShowRegistrationScreen() {
350 SetStatusAreaVisible(true); 369 SetStatusAreaVisible(true);
351 SetCurrentScreen(GetRegistrationScreen()); 370 SetCurrentScreen(GetRegistrationScreen());
352 } 371 }
353 372
354 void WizardController::SetStatusAreaVisible(bool visible) { 373 void WizardController::SetStatusAreaVisible(bool visible) {
355 // When ExistingUserController passes background ownership 374 // When ExistingUserController passes background ownership
356 // to WizardController it happens after screen is shown. 375 // to WizardController it happens after screen is shown.
357 if (background_view_) { 376 if (background_view_) {
358 background_view_->SetStatusAreaVisible(visible); 377 background_view_->SetStatusAreaVisible(visible);
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 } 444 }
426 } 445 }
427 } 446 }
428 447
429 void WizardController::OnConnectionFailed() { 448 void WizardController::OnConnectionFailed() {
430 // TODO(dpolukhin): show error message after login screen is displayed. 449 // TODO(dpolukhin): show error message after login screen is displayed.
431 ShowLoginScreen(); 450 ShowLoginScreen();
432 } 451 }
433 452
434 void WizardController::OnUpdateCompleted() { 453 void WizardController::OnUpdateCompleted() {
454 ShowEulaScreen();
455 }
456
457 void WizardController::OnEulaAccepted() {
435 MarkOobeCompleted(); 458 MarkOobeCompleted();
436 ShowLoginScreen(); 459 ShowLoginScreen();
437 } 460 }
438 461
439 void WizardController::OnUpdateErrorCheckingForUpdate() { 462 void WizardController::OnUpdateErrorCheckingForUpdate() {
440 MarkOobeCompleted();
441 // TODO(nkostylev): Update should be required during OOBE. 463 // TODO(nkostylev): Update should be required during OOBE.
442 // We do not want to block users from being able to proceed to the login 464 // We do not want to block users from being able to proceed to the login
443 // screen if there is any error checking for an update. 465 // screen if there is any error checking for an update.
444 // They could use "browse without sign-in" feature to set up the network to be 466 // They could use "browse without sign-in" feature to set up the network to be
445 // able to perform the update later. 467 // able to perform the update later.
446 ShowLoginScreen(); 468 ShowEulaScreen();
447 } 469 }
448 470
449 void WizardController::OnUpdateErrorUpdating() { 471 void WizardController::OnUpdateErrorUpdating() {
450 // If there was an error while getting or applying the update, 472 // If there was an error while getting or applying the update,
451 // return to network selection screen. 473 // return to network selection screen.
452 // TODO(nkostylev): Show message to the user explaining update error. 474 // TODO(nkostylev): Show message to the user explaining update error.
453 // TODO(nkostylev): Update should be required during OOBE. 475 // TODO(nkostylev): Update should be required during OOBE.
454 // Temporary fix, need to migrate to new API. http://crosbug.com/4321 476 // Temporary fix, need to migrate to new API. http://crosbug.com/4321
455 MarkOobeCompleted(); 477 ShowEulaScreen();
456 ShowLoginScreen();
457 } 478 }
458 479
459 void WizardController::OnUserImageSelected() { 480 void WizardController::OnUserImageSelected() {
460 // We're on the stack, so don't try and delete us now. 481 // We're on the stack, so don't try and delete us now.
461 // We should launch browser only after we delete the controller and close 482 // We should launch browser only after we delete the controller and close
462 // its windows. 483 // its windows.
463 ChromeThread::PostTask( 484 ChromeThread::PostTask(
464 ChromeThread::UI, 485 ChromeThread::UI,
465 FROM_HERE, 486 FROM_HERE,
466 NewRunnableFunction(&DeleteWizardControllerAndLaunchBrowser, 487 NewRunnableFunction(&DeleteWizardControllerAndLaunchBrowser,
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 // This flag is passed if we're running under automation test. 522 // This flag is passed if we're running under automation test.
502 is_test_mode_ = true; 523 is_test_mode_ = true;
503 ShowLoginScreen(); 524 ShowLoginScreen();
504 } else if (first_screen_name == kAccountScreenName) { 525 } else if (first_screen_name == kAccountScreenName) {
505 ShowAccountScreen(); 526 ShowAccountScreen();
506 } else if (first_screen_name == kUpdateScreenName) { 527 } else if (first_screen_name == kUpdateScreenName) {
507 ShowUpdateScreen(); 528 ShowUpdateScreen();
508 GetUpdateScreen()->StartUpdate(); 529 GetUpdateScreen()->StartUpdate();
509 } else if (first_screen_name == kUserImageScreenName) { 530 } else if (first_screen_name == kUserImageScreenName) {
510 ShowUserImageScreen(); 531 ShowUserImageScreen();
532 } else if (first_screen_name == kEulaScreenName) {
533 ShowEulaScreen();
511 } else if (first_screen_name == kRegistrationScreenName) { 534 } else if (first_screen_name == kRegistrationScreenName) {
512 ShowRegistrationScreen(); 535 ShowRegistrationScreen();
513 } else if (first_screen_name != kTestNoScreenName) { 536 } else if (first_screen_name != kTestNoScreenName) {
514 if (is_out_of_box_) { 537 if (is_out_of_box_) {
515 ShowNetworkScreen(); 538 ShowNetworkScreen();
516 } else { 539 } else {
517 ShowLoginScreen(); 540 ShowLoginScreen();
518 } 541 }
519 } 542 }
520 } 543 }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
563 break; 586 break;
564 case UPDATE_ERROR_UPDATING: 587 case UPDATE_ERROR_UPDATING:
565 OnUpdateErrorUpdating(); 588 OnUpdateErrorUpdating();
566 break; 589 break;
567 case USER_IMAGE_SELECTED: 590 case USER_IMAGE_SELECTED:
568 OnUserImageSelected(); 591 OnUserImageSelected();
569 break; 592 break;
570 case USER_IMAGE_SKIPPED: 593 case USER_IMAGE_SKIPPED:
571 OnUserImageSkipped(); 594 OnUserImageSkipped();
572 break; 595 break;
596 case EULA_ACCEPTED:
597 OnEulaAccepted();
598 break;
573 default: 599 default:
574 NOTREACHED(); 600 NOTREACHED();
575 } 601 }
576 } 602 }
577 603
578 /////////////////////////////////////////////////////////////////////////////// 604 ///////////////////////////////////////////////////////////////////////////////
579 // WizardController, WizardScreen overrides: 605 // WizardController, WizardScreen overrides:
580 views::View* WizardController::GetWizardView() { 606 views::View* WizardController::GetWizardView() {
581 return contents_; 607 return contents_;
582 } 608 }
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
662 if (!oobe_complete) 688 if (!oobe_complete)
663 controller->SetCustomization(customization.release()); 689 controller->SetCustomization(customization.release());
664 controller->ShowBackground(screen_bounds); 690 controller->ShowBackground(screen_bounds);
665 controller->Init(first_screen_name, screen_bounds); 691 controller->Init(first_screen_name, screen_bounds);
666 controller->Show(); 692 controller->Show();
667 if (chromeos::CrosLibrary::Get()->EnsureLoaded()) 693 if (chromeos::CrosLibrary::Get()->EnsureLoaded())
668 chromeos::CrosLibrary::Get()->GetLoginLibrary()->EmitLoginPromptReady(); 694 chromeos::CrosLibrary::Get()->GetLoginLibrary()->EmitLoginPromptReady();
669 } 695 }
670 696
671 } // namespace browser 697 } // namespace browser
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/wizard_controller.h ('k') | chrome/browser/chromeos/login/wizard_controller_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698