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

Side by Side Diff: chrome/browser/chromeos/system/ash_system_tray_delegate.cc

Issue 14139003: Chrome OS multi-profiles backend and UI. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: move IsMultiProfilesEnabled() out of cros Created 7 years, 8 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) 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
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
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
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 some UI messages why no more users could be added
535 // to this session. http://crbug.com/230863
536 // We limit list of logged in users to 3 due to memory constraints.
537 // TODO(nkostylev): Adjust this limitation based on device capabilites.
538 // http://crbug.com/230865
539 if (UserManager::Get()->GetLoggedInUsers().size() >= 3)
540 return;
541
542 // Check whether there're regular users on the list that are not
543 // currently logged in.
544 const UserList& users = UserManager::Get()->GetUsers();
545 bool has_regular_not_logged_in_users = false;
546 for (UserList::const_iterator it = users.begin(); it != users.end(); ++it) {
547 const User* user = (*it);
548 if (user->GetType() == User::USER_TYPE_REGULAR &&
549 !user->is_logged_in()) {
550 has_regular_not_logged_in_users = true;
551 break;
552 }
553 }
554
555 // Launch sign in screen to add another user to current session.
556 if (has_regular_not_logged_in_users) {
557 ash::Shell::GetInstance()->
558 desktop_background_controller()->MoveDesktopToLockedContainer();
559 ShowLoginWizard(std::string(), gfx::Size());
560 }
561 }
562
509 virtual void ShutDown() OVERRIDE { 563 virtual void ShutDown() OVERRIDE {
510 ash::Shell::GetInstance()->session_state_controller()->RequestShutdown(); 564 ash::Shell::GetInstance()->session_state_controller()->RequestShutdown();
511 } 565 }
512 566
513 virtual void SignOut() OVERRIDE { 567 virtual void SignOut() OVERRIDE {
514 chrome::AttemptUserExit(); 568 chrome::AttemptUserExit();
515 } 569 }
516 570
517 virtual void RequestLockScreen() OVERRIDE { 571 virtual void RequestLockScreen() OVERRIDE {
518 // TODO(antrim) : additional logging for crbug/173178 572 // TODO(antrim) : additional logging for crbug/173178
(...skipping 1009 matching lines...) Expand 10 before | Expand all | Expand 10 after
1528 DISALLOW_COPY_AND_ASSIGN(SystemTrayDelegate); 1582 DISALLOW_COPY_AND_ASSIGN(SystemTrayDelegate);
1529 }; 1583 };
1530 1584
1531 } // namespace 1585 } // namespace
1532 1586
1533 ash::SystemTrayDelegate* CreateSystemTrayDelegate() { 1587 ash::SystemTrayDelegate* CreateSystemTrayDelegate() {
1534 return new chromeos::SystemTrayDelegate(); 1588 return new chromeos::SystemTrayDelegate();
1535 } 1589 }
1536 1590
1537 } // namespace chromeos 1591 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/user_manager_impl.cc ('k') | chrome/browser/resources/chromeos/login/display_manager.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698