OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/system/ash_system_tray_delegate.h" | 5 #include "chrome/browser/chromeos/system/ash_system_tray_delegate.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "ash/ash_switches.h" | 12 #include "ash/ash_switches.h" |
13 #include "ash/desktop_background/desktop_background_controller.h" | |
13 #include "ash/shell.h" | 14 #include "ash/shell.h" |
14 #include "ash/shell_delegate.h" | 15 #include "ash/shell_delegate.h" |
15 #include "ash/shell_window_ids.h" | 16 #include "ash/shell_window_ids.h" |
16 #include "ash/system/audio/audio_observer.h" | 17 #include "ash/system/audio/audio_observer.h" |
17 #include "ash/system/bluetooth/bluetooth_observer.h" | 18 #include "ash/system/bluetooth/bluetooth_observer.h" |
18 #include "ash/system/brightness/brightness_observer.h" | 19 #include "ash/system/brightness/brightness_observer.h" |
19 #include "ash/system/chromeos/network/network_observer.h" | 20 #include "ash/system/chromeos/network/network_observer.h" |
20 #include "ash/system/chromeos/network/network_tray_delegate.h" | 21 #include "ash/system/chromeos/network/network_tray_delegate.h" |
21 #include "ash/system/date/clock_observer.h" | 22 #include "ash/system/date/clock_observer.h" |
22 #include "ash/system/drive/drive_observer.h" | 23 #include "ash/system/drive/drive_observer.h" |
(...skipping 26 matching lines...) Expand all Loading... | |
49 #include "chrome/browser/chromeos/cros/cros_library.h" | 50 #include "chrome/browser/chromeos/cros/cros_library.h" |
50 #include "chrome/browser/chromeos/cros/network_library.h" | 51 #include "chrome/browser/chromeos/cros/network_library.h" |
51 #include "chrome/browser/chromeos/drive/drive_system_service.h" | 52 #include "chrome/browser/chromeos/drive/drive_system_service.h" |
52 #include "chrome/browser/chromeos/input_method/input_method_configuration.h" | 53 #include "chrome/browser/chromeos/input_method/input_method_configuration.h" |
53 #include "chrome/browser/chromeos/input_method/input_method_manager.h" | 54 #include "chrome/browser/chromeos/input_method/input_method_manager.h" |
54 #include "chrome/browser/chromeos/input_method/input_method_util.h" | 55 #include "chrome/browser/chromeos/input_method/input_method_util.h" |
55 #include "chrome/browser/chromeos/kiosk_mode/kiosk_mode_settings.h" | 56 #include "chrome/browser/chromeos/kiosk_mode/kiosk_mode_settings.h" |
56 #include "chrome/browser/chromeos/login/base_login_display_host.h" | 57 #include "chrome/browser/chromeos/login/base_login_display_host.h" |
57 #include "chrome/browser/chromeos/login/help_app_launcher.h" | 58 #include "chrome/browser/chromeos/login/help_app_launcher.h" |
58 #include "chrome/browser/chromeos/login/login_display_host.h" | 59 #include "chrome/browser/chromeos/login/login_display_host.h" |
60 #include "chrome/browser/chromeos/login/login_wizard.h" | |
59 #include "chrome/browser/chromeos/login/user.h" | 61 #include "chrome/browser/chromeos/login/user.h" |
60 #include "chrome/browser/chromeos/login/user_manager.h" | 62 #include "chrome/browser/chromeos/login/user_manager.h" |
61 #include "chrome/browser/chromeos/login/wizard_controller.h" | 63 #include "chrome/browser/chromeos/login/wizard_controller.h" |
62 #include "chrome/browser/chromeos/mobile_config.h" | 64 #include "chrome/browser/chromeos/mobile_config.h" |
63 #include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h" | 65 #include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h" |
64 #include "chrome/browser/chromeos/status/data_promo_notification.h" | 66 #include "chrome/browser/chromeos/status/data_promo_notification.h" |
65 #include "chrome/browser/chromeos/status/network_menu.h" | 67 #include "chrome/browser/chromeos/status/network_menu.h" |
66 #include "chrome/browser/chromeos/status/network_menu_icon.h" | 68 #include "chrome/browser/chromeos/status/network_menu_icon.h" |
67 #include "chrome/browser/chromeos/system/timezone_settings.h" | 69 #include "chrome/browser/chromeos/system/timezone_settings.h" |
68 #include "chrome/browser/chromeos/system_key_event_listener.h" | 70 #include "chrome/browser/chromeos/system_key_event_listener.h" |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
361 policy_manager->core()->store()->RemoveObserver(this); | 363 policy_manager->core()->store()->RemoveObserver(this); |
362 } | 364 } |
363 | 365 |
364 // Overridden from ash::SystemTrayDelegate: | 366 // Overridden from ash::SystemTrayDelegate: |
365 virtual bool GetTrayVisibilityOnStartup() OVERRIDE { | 367 virtual bool GetTrayVisibilityOnStartup() OVERRIDE { |
366 // In case of OOBE / sign in screen tray will be shown later. | 368 // In case of OOBE / sign in screen tray will be shown later. |
367 return UserManager::Get()->IsUserLoggedIn(); | 369 return UserManager::Get()->IsUserLoggedIn(); |
368 } | 370 } |
369 | 371 |
370 virtual const string16 GetUserDisplayName() const OVERRIDE { | 372 virtual const string16 GetUserDisplayName() const OVERRIDE { |
371 return UserManager::Get()->GetLoggedInUser()->GetDisplayName(); | 373 return UserManager::Get()->GetActiveUser()->GetDisplayName(); |
372 } | 374 } |
373 | 375 |
374 virtual const std::string GetUserEmail() const OVERRIDE { | 376 virtual const std::string GetUserEmail() const OVERRIDE { |
375 return UserManager::Get()->GetLoggedInUser()->display_email(); | 377 return UserManager::Get()->GetActiveUser()->display_email(); |
376 } | 378 } |
377 | 379 |
378 virtual const gfx::ImageSkia& GetUserImage() const OVERRIDE { | 380 virtual const gfx::ImageSkia& GetUserImage() const OVERRIDE { |
379 return UserManager::Get()->GetLoggedInUser()->image(); | 381 return UserManager::Get()->GetActiveUser()->image(); |
380 } | 382 } |
381 | 383 |
382 virtual ash::user::LoginStatus GetUserLoginStatus() const OVERRIDE { | 384 virtual ash::user::LoginStatus GetUserLoginStatus() const OVERRIDE { |
383 UserManager* manager = UserManager::Get(); | 385 UserManager* manager = UserManager::Get(); |
384 // At new user image screen manager->IsUserLoggedIn() would return true | 386 // At new user image screen manager->IsUserLoggedIn() would return true |
385 // but there's no browser session available yet so use SessionStarted(). | 387 // but there's no browser session available yet so use SessionStarted(). |
386 if (!manager->IsSessionStarted()) | 388 if (!manager->IsSessionStarted()) |
387 return ash::user::LOGGED_IN_NONE; | 389 return ash::user::LOGGED_IN_NONE; |
388 if (screen_locked_) | 390 if (screen_locked_) |
389 return ash::user::LOGGED_IN_LOCKED; | 391 return ash::user::LOGGED_IN_LOCKED; |
390 if (manager->IsCurrentUserOwner()) | 392 if (manager->IsCurrentUserOwner()) |
391 return ash::user::LOGGED_IN_OWNER; | 393 return ash::user::LOGGED_IN_OWNER; |
392 if (manager->IsLoggedInAsGuest()) | 394 if (manager->IsLoggedInAsGuest()) |
393 return ash::user::LOGGED_IN_GUEST; | 395 return ash::user::LOGGED_IN_GUEST; |
394 if (manager->IsLoggedInAsDemoUser()) | 396 if (manager->IsLoggedInAsDemoUser()) |
395 return ash::user::LOGGED_IN_RETAIL_MODE; | 397 return ash::user::LOGGED_IN_RETAIL_MODE; |
396 if (manager->IsLoggedInAsPublicAccount()) | 398 if (manager->IsLoggedInAsPublicAccount()) |
397 return ash::user::LOGGED_IN_PUBLIC; | 399 return ash::user::LOGGED_IN_PUBLIC; |
398 return ash::user::LOGGED_IN_USER; | 400 return ash::user::LOGGED_IN_USER; |
399 } | 401 } |
400 | 402 |
401 virtual bool IsOobeCompleted() const OVERRIDE { | 403 virtual bool IsOobeCompleted() const OVERRIDE { |
402 return WizardController::IsOobeCompleted(); | 404 return WizardController::IsOobeCompleted(); |
403 } | 405 } |
404 | 406 |
407 virtual void GetLoggedInUsers(ash::UserEmailList* users) OVERRIDE { | |
408 const UserList& logged_in_users = UserManager::Get()->GetLoggedInUsers(); | |
409 for (UserList::const_iterator it = logged_in_users.begin(); | |
410 it != logged_in_users.end(); ++it) { | |
411 const User* user = (*it); | |
412 users->push_back(user->email()); | |
413 } | |
414 } | |
415 | |
416 virtual void SwitchActiveUser(const std::string& email) OVERRIDE { | |
417 UserManager::Get()->SwitchActiveUser(email); | |
418 } | |
419 | |
405 virtual void ChangeProfilePicture() OVERRIDE { | 420 virtual void ChangeProfilePicture() OVERRIDE { |
406 content::RecordAction( | 421 content::RecordAction( |
407 content::UserMetricsAction("OpenChangeProfilePictureDialog")); | 422 content::UserMetricsAction("OpenChangeProfilePictureDialog")); |
408 chrome::ShowSettingsSubPage(GetAppropriateBrowser(), | 423 chrome::ShowSettingsSubPage(GetAppropriateBrowser(), |
409 chrome::kChangeProfilePictureSubPage); | 424 chrome::kChangeProfilePictureSubPage); |
410 } | 425 } |
411 | 426 |
412 virtual const std::string GetEnterpriseDomain() const OVERRIDE { | 427 virtual const std::string GetEnterpriseDomain() const OVERRIDE { |
413 return enterprise_domain_; | 428 return enterprise_domain_; |
414 } | 429 } |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
499 new chromeos::HelpAppLauncher( | 514 new chromeos::HelpAppLauncher( |
500 GetNativeWindowByStatus(GetUserLoginStatus()))); | 515 GetNativeWindowByStatus(GetUserLoginStatus()))); |
501 help_app->ShowHelpTopic(chromeos::HelpAppLauncher::HELP_ENTERPRISE); | 516 help_app->ShowHelpTopic(chromeos::HelpAppLauncher::HELP_ENTERPRISE); |
502 } else { | 517 } else { |
503 GURL url(google_util::StringAppendGoogleLocaleParam( | 518 GURL url(google_util::StringAppendGoogleLocaleParam( |
504 chrome::kLearnMoreEnterpriseURL)); | 519 chrome::kLearnMoreEnterpriseURL)); |
505 chrome::ShowSingletonTab(GetAppropriateBrowser(), url); | 520 chrome::ShowSingletonTab(GetAppropriateBrowser(), url); |
506 } | 521 } |
507 } | 522 } |
508 | 523 |
524 virtual void ShowUserLogin() OVERRIDE { | |
525 if (!ash::Shell::GetInstance()->delegate()->IsMultiProfilesEnabled()) | |
526 return; | |
527 | |
528 // Only regular users could add other users to current session. | |
529 if (UserManager::Get()->GetActiveUser()->GetType() != | |
530 User::USER_TYPE_REGULAR) { | |
531 return; | |
532 } | |
533 | |
534 // TODO(nkostylev): Show optional intro dialog about this feature. | |
535 | |
536 // TODO(nkostylev): Show some UI messages why no more users could be added | |
537 // to this session. | |
538 // We limit list of logged in users to 3 due to memory constraints. | |
539 // TODO(nkostylev): Adjust this limitation based on device capabilites. | |
540 if (UserManager::Get()->GetLoggedInUsers().size() >= 3) | |
541 return; | |
542 | |
543 // Check whether there're regular users on the list that are not | |
544 // currently logged in. | |
545 const UserList& users = UserManager::Get()->GetUsers(); | |
546 bool has_regular_not_logged_in_users = false; | |
547 for (UserList::const_iterator it = users.begin(); it != users.end(); ++it) { | |
548 const User* user = (*it); | |
549 if (user->GetType() == User::USER_TYPE_REGULAR && | |
550 !user->is_logged_in()) { | |
551 has_regular_not_logged_in_users = true; | |
552 break; | |
553 } | |
554 } | |
555 | |
556 // Launch sign in screen to add another user to current session. | |
557 if (has_regular_not_logged_in_users) { | |
558 ash::Shell::GetInstance()-> | |
559 desktop_background_controller()->MoveDesktopToLockedContainer(); | |
Dmitry Polukhin
2013/04/11 13:34:15
Will it handle multiple monitors? I.e. it looks li
Nikita (slow)
2013/04/12 15:41:25
Yes, this method is multi-monitor aware and is alr
| |
560 gfx::Size size(0, 0); | |
561 ShowLoginWizard(std::string(), size); | |
562 } | |
563 } | |
564 | |
509 virtual void ShutDown() OVERRIDE { | 565 virtual void ShutDown() OVERRIDE { |
510 ash::Shell::GetInstance()->session_state_controller()->RequestShutdown(); | 566 ash::Shell::GetInstance()->session_state_controller()->RequestShutdown(); |
511 } | 567 } |
512 | 568 |
513 virtual void SignOut() OVERRIDE { | 569 virtual void SignOut() OVERRIDE { |
514 chrome::AttemptUserExit(); | 570 chrome::AttemptUserExit(); |
515 } | 571 } |
516 | 572 |
517 virtual void RequestLockScreen() OVERRIDE { | 573 virtual void RequestLockScreen() OVERRIDE { |
518 // TODO(antrim) : additional logging for crbug/173178 | 574 // TODO(antrim) : additional logging for crbug/173178 |
(...skipping 1009 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1528 DISALLOW_COPY_AND_ASSIGN(SystemTrayDelegate); | 1584 DISALLOW_COPY_AND_ASSIGN(SystemTrayDelegate); |
1529 }; | 1585 }; |
1530 | 1586 |
1531 } // namespace | 1587 } // namespace |
1532 | 1588 |
1533 ash::SystemTrayDelegate* CreateSystemTrayDelegate() { | 1589 ash::SystemTrayDelegate* CreateSystemTrayDelegate() { |
1534 return new chromeos::SystemTrayDelegate(); | 1590 return new chromeos::SystemTrayDelegate(); |
1535 } | 1591 } |
1536 | 1592 |
1537 } // namespace chromeos | 1593 } // namespace chromeos |
OLD | NEW |