From fdf74bff8ca4b5b63e8af67e34d195a004a73300 Mon Sep 17 00:00:00 2001 From: "oshima@chromium.org" Date: Wed, 30 Apr 2014 21:24:02 +0000 Subject: CleanUp: Introduce UserInfo. Move session_state stuff to ash/session. BUG=None R=nkostylev@chromium.org TBR=sky@chromium.org Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=267158 Review URL: https://codereview.chromium.org/253063002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@267337 0039d316-1c4b-4281-b951-d872f2087c98 --- ash/accelerators/accelerator_controller.cc | 4 +- .../nested_dispatcher_controller_unittest.cc | 2 +- ash/ash.gyp | 15 +- ash/desktop_background/desktop_background_view.cc | 2 +- ash/frame/custom_frame_view_ash.cc | 2 +- ash/frame/frame_util.cc | 9 +- ash/root_window_controller.cc | 2 +- ash/root_window_controller_unittest.cc | 2 +- ash/session/session_state_delegate.h | 140 +++++++++++++++++++ ash/session/session_state_delegate_stub.cc | 137 ++++++++++++++++++ ash/session/session_state_delegate_stub.h | 58 ++++++++ ash/session/session_state_observer.cc | 25 ++++ ash/session/session_state_observer.h | 46 ++++++ ash/session/user_info.h | 45 ++++++ ash/session_state_delegate.h | 155 --------------------- ash/session_state_delegate_stub.cc | 122 ---------------- ash/session_state_delegate_stub.h | 65 --------- ash/session_state_observer.cc | 24 ---- ash/session_state_observer.h | 46 ------ ash/shelf/shelf_layout_manager.cc | 2 +- ash/shelf/shelf_layout_manager.h | 2 +- ash/shelf/shelf_layout_manager_unittest.cc | 2 +- ash/shelf/shelf_widget.cc | 2 +- ash/shell.cc | 2 +- ash/shell/app_list.cc | 2 +- ash/shell/lock_view.cc | 2 +- ash/shell/shell_delegate_impl.cc | 4 +- ash/shell/window_type_launcher.cc | 2 +- ash/shell_unittest.cc | 2 +- ash/system/chromeos/network/network_connect.cc | 2 +- ash/system/chromeos/power/power_event_observer.cc | 2 +- .../session/logout_confirmation_controller.cc | 2 +- ash/system/date/date_default_view.cc | 2 +- ash/system/tray/default_system_tray_delegate.cc | 2 +- ash/system/user/accounts_detailed_view.cc | 14 +- ash/system/user/config.cc | 2 +- ash/system/user/login_status.cc | 2 +- ash/system/user/tray_user.cc | 5 +- ash/system/user/tray_user.h | 2 +- ash/system/user/tray_user_separator.cc | 2 +- ash/system/user/tray_user_unittest.cc | 7 +- ash/system/user/user_card_view.cc | 20 +-- ash/system/user/user_view.cc | 5 +- ash/system/user/user_view.h | 2 +- ash/test/test_session_state_delegate.cc | 107 +++++++++----- ash/test/test_session_state_delegate.h | 28 ++-- ash/test/test_shell_delegate.cc | 2 +- ash/test/test_system_tray_delegate.cc | 2 +- ash/wm/event_client_impl.cc | 2 +- ash/wm/gestures/shelf_gesture_handler.cc | 2 +- ash/wm/lock_state_controller_unittest.cc | 2 +- ash/wm/mru_window_tracker.cc | 2 +- ash/wm/overview/window_selector_controller.cc | 2 +- ash/wm/power_button_controller.cc | 2 +- ash/wm/stacking_controller.cc | 2 +- ash/wm/system_modal_container_layout_manager.cc | 2 +- ...stem_modal_container_layout_manager_unittest.cc | 2 +- ash/wm/workspace/workspace_layout_manager.cc | 2 +- .../workspace/workspace_layout_manager_unittest.cc | 2 +- .../accessibility/accessibility_manager.cc | 2 +- .../chromeos/accessibility/accessibility_manager.h | 2 +- .../accessibility/magnification_manager.cc | 2 +- .../chromeos/dbus/printer_service_provider.cc | 2 +- .../chromeos/extensions/first_run_private_api.cc | 4 +- .../file_manager/file_manager_browsertest.cc | 2 +- .../chromeos/login/session_login_browsertest.cc | 2 +- chrome/browser/chromeos/login/user.cc | 17 +++ chrome/browser/chromeos/login/user.h | 21 ++- .../login/user_adding_screen_browsertest.cc | 2 +- .../login/user_image_manager_browsertest.cc | 32 ++--- .../chromeos/login/user_image_manager_impl.cc | 2 +- .../chromeos/memory/oom_priority_manager.cc | 2 +- .../policy/device_local_account_browsertest.cc | 2 +- .../chromeos/profiles/profile_list_chromeos.cc | 2 +- chrome/browser/idle_chromeos.cc | 2 +- .../message_center_settings_controller.cc | 12 +- .../chrome_launcher_controller_unittest.cc | 16 ++- .../multi_user/multi_user_context_menu_chromeos.cc | 23 +-- ..._user_notification_blocker_chromeos_unittest.cc | 14 +- .../ui/ash/multi_user/multi_user_window_manager.cc | 10 +- .../multi_user_window_manager_chromeos.cc | 2 +- .../multi_user_window_manager_chromeos.h | 2 +- .../multi_user_window_manager_chromeos_unittest.cc | 19 ++- .../ui/ash/session_state_delegate_chromeos.cc | 37 +---- .../ui/ash/session_state_delegate_chromeos.h | 14 +- .../browser/ui/ash/session_state_delegate_views.cc | 73 ++++++---- .../browser/ui/ash/session_state_delegate_views.h | 14 +- .../ui/ash/system_tray_delegate_chromeos.cc | 4 +- .../browser/ui/ash/system_tray_delegate_chromeos.h | 2 +- chrome/browser/ui/browser_command_controller.cc | 2 +- .../ash/chrome_browser_main_extra_parts_ash.cc | 2 +- chrome/browser/ui/views/frame/browser_frame.cc | 2 +- .../ui/views/frame/system_menu_model_builder.cc | 15 +- .../chromeos/change_picture_options_handler.cc | 4 +- .../chromeos/core_chromeos_options_handler.cc | 2 +- 95 files changed, 820 insertions(+), 702 deletions(-) create mode 100644 ash/session/session_state_delegate.h create mode 100644 ash/session/session_state_delegate_stub.cc create mode 100644 ash/session/session_state_delegate_stub.h create mode 100644 ash/session/session_state_observer.cc create mode 100644 ash/session/session_state_observer.h create mode 100644 ash/session/user_info.h delete mode 100644 ash/session_state_delegate.h delete mode 100644 ash/session_state_delegate_stub.cc delete mode 100644 ash/session_state_delegate_stub.h delete mode 100644 ash/session_state_observer.cc delete mode 100644 ash/session_state_observer.h diff --git a/ash/accelerators/accelerator_controller.cc b/ash/accelerators/accelerator_controller.cc index 7d70bc7..51f780c 100644 --- a/ash/accelerators/accelerator_controller.cc +++ b/ash/accelerators/accelerator_controller.cc @@ -28,7 +28,7 @@ #include "ash/root_window_controller.h" #include "ash/rotator/screen_rotation.h" #include "ash/screenshot_delegate.h" -#include "ash/session_state_delegate.h" +#include "ash/session/session_state_delegate.h" #include "ash/shelf/shelf.h" #include "ash/shelf/shelf_delegate.h" #include "ash/shelf/shelf_model.h" @@ -71,7 +71,7 @@ #include "ui/views/widget/widget.h" #if defined(OS_CHROMEOS) -#include "ash/session_state_delegate.h" +#include "ash/session/session_state_delegate.h" #include "ash/system/chromeos/keyboard_brightness_controller.h" #include "base/sys_info.h" #include "chromeos/ime/ime_keyboard.h" diff --git a/ash/accelerators/nested_dispatcher_controller_unittest.cc b/ash/accelerators/nested_dispatcher_controller_unittest.cc index 20e399c..e5aef88 100644 --- a/ash/accelerators/nested_dispatcher_controller_unittest.cc +++ b/ash/accelerators/nested_dispatcher_controller_unittest.cc @@ -3,7 +3,7 @@ // found in the LICENSE file. #include "ash/accelerators/accelerator_controller.h" -#include "ash/session_state_delegate.h" +#include "ash/session/session_state_delegate.h" #include "ash/shell.h" #include "ash/shell_window_ids.h" #include "ash/test/ash_test_base.h" diff --git a/ash/ash.gyp b/ash/ash.gyp index 4934087..f6555c3 100644 --- a/ash/ash.gyp +++ b/ash/ash.gyp @@ -240,9 +240,10 @@ 'screen_util.cc', 'screen_util.h', 'screenshot_delegate.h', - 'session_state_delegate.h', - 'session_state_observer.cc', - 'session_state_observer.h', + 'session/session_state_delegate.h', + 'session/session_state_observer.cc', + 'session/session_state_observer.h', + 'session/user_info.h', 'shelf/app_list_button.cc', 'shelf/app_list_button.h', 'shelf/app_list_shelf_item_delegate.cc', @@ -940,8 +941,8 @@ 'root_window_controller_unittest.cc', 'screen_util_unittest.cc', 'screensaver/screensaver_view_unittest.cc', - 'session_state_delegate_stub.cc', - 'session_state_delegate_stub.h', + 'session/session_state_delegate_stub.cc', + 'session/session_state_delegate_stub.h', 'shelf/scoped_observer_with_duplicated_sources_unittest.cc', 'shelf/shelf_layout_manager_unittest.cc', 'shelf/shelf_model_unittest.cc', @@ -1136,8 +1137,8 @@ 'ash_with_content', ], 'sources': [ - 'session_state_delegate_stub.cc', - 'session_state_delegate_stub.h', + 'session/session_state_delegate_stub.cc', + 'session/session_state_delegate_stub.h', 'shell/app_list.cc', 'shell/bubble.cc', 'shell/content_client/shell_browser_main_parts.cc', diff --git a/ash/desktop_background/desktop_background_view.cc b/ash/desktop_background/desktop_background_view.cc index 1250279..d0e850c 100644 --- a/ash/desktop_background/desktop_background_view.cc +++ b/ash/desktop_background/desktop_background_view.cc @@ -12,7 +12,7 @@ #include "ash/desktop_background/user_wallpaper_delegate.h" #include "ash/display/display_manager.h" #include "ash/root_window_controller.h" -#include "ash/session_state_delegate.h" +#include "ash/session/session_state_delegate.h" #include "ash/shell.h" #include "ash/shell_window_ids.h" #include "ash/wm/window_animations.h" diff --git a/ash/frame/custom_frame_view_ash.cc b/ash/frame/custom_frame_view_ash.cc index c9029ec..8ab7e23 100644 --- a/ash/frame/custom_frame_view_ash.cc +++ b/ash/frame/custom_frame_view_ash.cc @@ -12,7 +12,7 @@ #include "ash/frame/frame_border_hit_test_controller.h" #include "ash/frame/frame_util.h" #include "ash/frame/header_painter.h" -#include "ash/session_state_delegate.h" +#include "ash/session/session_state_delegate.h" #include "ash/shell.h" #include "ash/shell_observer.h" #include "ash/wm/immersive_fullscreen_controller.h" diff --git a/ash/frame/frame_util.cc b/ash/frame/frame_util.cc index bfa8c33..fd26783 100644 --- a/ash/frame/frame_util.cc +++ b/ash/frame/frame_util.cc @@ -4,7 +4,8 @@ #include "ash/frame/frame_util.h" -#include "ash/session_state_delegate.h" +#include "ash/session/session_state_delegate.h" +#include "ash/session/user_info.h" #include "ash/shell.h" #include "grit/ash_resources.h" #include "ui/base/resource/resource_bundle.h" @@ -20,8 +21,10 @@ gfx::Image GetAvatarImageForContext(content::BrowserContext* context) { static const gfx::ImageSkia* holder_mask = ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( IDR_AVATAR_HOLDER_MASK); - gfx::ImageSkia user_image = - Shell::GetInstance()->session_state_delegate()->GetUserImage(context); + gfx::ImageSkia user_image = Shell::GetInstance() + ->session_state_delegate() + ->GetUserInfo(context) + ->GetImage(); gfx::ImageSkia resized = gfx::ImageSkiaOperations::CreateResizedImage( user_image, skia::ImageOperations::RESIZE_BEST, holder->size()); gfx::ImageSkia masked = diff --git a/ash/root_window_controller.cc b/ash/root_window_controller.cc index ba38e14..010ef0e 100644 --- a/ash/root_window_controller.cc +++ b/ash/root_window_controller.cc @@ -17,7 +17,7 @@ #include "ash/high_contrast/high_contrast_controller.h" #include "ash/host/ash_window_tree_host.h" #include "ash/root_window_settings.h" -#include "ash/session_state_delegate.h" +#include "ash/session/session_state_delegate.h" #include "ash/shelf/shelf_layout_manager.h" #include "ash/shelf/shelf_types.h" #include "ash/shelf/shelf_widget.h" diff --git a/ash/root_window_controller_unittest.cc b/ash/root_window_controller_unittest.cc index 6592dac..3edd2801 100644 --- a/ash/root_window_controller_unittest.cc +++ b/ash/root_window_controller_unittest.cc @@ -4,7 +4,7 @@ #include "ash/root_window_controller.h" -#include "ash/session_state_delegate.h" +#include "ash/session/session_state_delegate.h" #include "ash/shelf/shelf_layout_manager.h" #include "ash/shell.h" #include "ash/shell_window_ids.h" diff --git a/ash/session/session_state_delegate.h b/ash/session/session_state_delegate.h new file mode 100644 index 0000000..78777a0 --- /dev/null +++ b/ash/session/session_state_delegate.h @@ -0,0 +1,140 @@ +// Copyright (c) 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef ASH_SESSION_SESSION_STATE_DELEGATE_H_ +#define ASH_SESSION_SESSION_STATE_DELEGATE_H_ + +#include +#include + +#include "ash/ash_export.h" +#include "base/strings/string16.h" + +namespace aura { +class Window; +} // namespace aura + +namespace content { +class BrowserContext; +} + +namespace gfx { +class ImageSkia; +} // namespace gfx + +namespace ash { + +class SessionStateObserver; +class UserInfo; + +// The index for the multi-profile item to use. The list is always LRU sorted +// So that the index #0 is the currently active user. +typedef int MultiProfileIndex; + +// A list of user_id. +typedef std::vector UserIdList; + +// Delegate for checking and modifying the session state. +// TODO(oshima): Replace MultiProfileIndex with BrowsreContext, bacause +// GetUserXXX are useful for non multi profile scenario in ash_shell. +class ASH_EXPORT SessionStateDelegate { + public: + // Defines the cycle direction for |CycleActiveUser|. + enum CycleUser { + CYCLE_TO_NEXT_USER = 0, // Cycle to the next user. + CYCLE_TO_PREVIOUS_USER, // Cycle to the previous user. + }; + + // Defines session state i.e. whether session is running or not and + // whether user session is blocked by things like multi-profile login. + enum SessionState { + // When primary user login UI is shown i.e. after boot or sign out, + // no active user session exists yet. + SESSION_STATE_LOGIN_PRIMARY = 0, + + // Inside user session (including lock screen), + // no login UI (primary or multi-profiles) is shown. + SESSION_STATE_ACTIVE, + + // When secondary user login UI is shown i.e. other users are + // already logged in and is currently adding another user to the session. + SESSION_STATE_LOGIN_SECONDARY, + }; + + virtual ~SessionStateDelegate() {}; + + // Returns the browser context for the user given by |index|. + virtual content::BrowserContext* GetBrowserContextByIndex( + MultiProfileIndex index) = 0; + + // Returns the browser context associated with the window. + virtual content::BrowserContext* GetBrowserContextForWindow( + aura::Window* window) = 0; + + // Returns the maximum possible number of logged in users. + virtual int GetMaximumNumberOfLoggedInUsers() const = 0; + + // Returns the number of signed in users. If 0 is returned, there is either + // no session in progress or no active user. + virtual int NumberOfLoggedInUsers() const = 0; + + // Returns |true| if the session has been fully started for the active user. + // When a user becomes active, the profile and browser UI are not immediately + // available. Only once this method starts returning |true| is the browser + // startup complete and both profile and UI are fully available. + virtual bool IsActiveUserSessionStarted() const = 0; + + // Returns true if the screen can be locked. + virtual bool CanLockScreen() const = 0; + + // Returns true if the screen is currently locked. + virtual bool IsScreenLocked() const = 0; + + // Returns true if the screen should be locked when the system is about to + // suspend. + virtual bool ShouldLockScreenBeforeSuspending() const = 0; + + // Locks the screen. The locking happens asynchronously. + virtual void LockScreen() = 0; + + // Unlocks the screen. + virtual void UnlockScreen() = 0; + + // Returns |true| if user session blocked by some overlying UI. It can be + // login screen, lock screen or screen for adding users into multi-profile + // session. + virtual bool IsUserSessionBlocked() const = 0; + + // Returns current session state. + virtual SessionState GetSessionState() const = 0; + + // TODO(oshima): consolidate these two GetUserInfo. + + // Gets the user info for the user with the given |index|. + // Note that |index| can at maximum be |NumberOfLoggedInUsers() - 1|. + virtual const UserInfo* GetUserInfo(MultiProfileIndex index) const = 0; + + // Gets the avatar image for the user associated with the |context|. + virtual const UserInfo* GetUserInfo( + content::BrowserContext* context) const = 0; + + // Whether or not the window's title should show the avatar. + virtual bool ShouldShowAvatar(aura::Window* window) const = 0; + + // Switches to another active user with |user_id| + // (if that user has already signed in). + virtual void SwitchActiveUser(const std::string& user_id) = 0; + + // Switches the active user to the next or previous user, with the same + // ordering as GetLoggedInUsers. + virtual void CycleActiveUser(CycleUser cycle_user) = 0; + + // Adds or removes sessions state observer. + virtual void AddSessionStateObserver(SessionStateObserver* observer) = 0; + virtual void RemoveSessionStateObserver(SessionStateObserver* observer) = 0; +}; + +} // namespace ash + +#endif // ASH_SESSION_SESSION_STATE_DELEGATE_H_ diff --git a/ash/session/session_state_delegate_stub.cc b/ash/session/session_state_delegate_stub.cc new file mode 100644 index 0000000..05bca13 --- /dev/null +++ b/ash/session/session_state_delegate_stub.cc @@ -0,0 +1,137 @@ +// Copyright (c) 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "ash/session/session_state_delegate_stub.h" + +#include "ash/session/user_info.h" +#include "ash/shell.h" +#include "ash/shell/example_factory.h" +#include "ash/shell_delegate.h" +#include "base/strings/string16.h" +#include "base/strings/utf_string_conversions.h" +#include "ui/gfx/image/image_skia.h" + +namespace ash { +namespace { + +class UserInfoStub : public UserInfo { + public: + UserInfoStub() {} + virtual ~UserInfoStub() {} + + // UserInfo: + virtual base::string16 GetDisplayName() const OVERRIDE { + return base::UTF8ToUTF16("stub-user"); + } + virtual base::string16 GetGivenName() const OVERRIDE { + return base::UTF8ToUTF16("Stub"); + } + virtual std::string GetEmail() const OVERRIDE { + return "stub-user@domain.com"; + } + virtual std::string GetUserID() const OVERRIDE { return GetEmail(); } + virtual const gfx::ImageSkia& GetImage() const OVERRIDE { + return user_image_; + } + + private: + gfx::ImageSkia user_image_; + + DISALLOW_COPY_AND_ASSIGN(UserInfoStub); +}; + +} // namespace + +SessionStateDelegateStub::SessionStateDelegateStub() + : screen_locked_(false), user_info_(new UserInfoStub()) { +} + +SessionStateDelegateStub::~SessionStateDelegateStub() { +} + +content::BrowserContext* SessionStateDelegateStub::GetBrowserContextByIndex( + MultiProfileIndex index) { + return Shell::GetInstance()->delegate()->GetActiveBrowserContext(); +} + +content::BrowserContext* SessionStateDelegateStub::GetBrowserContextForWindow( + aura::Window* window) { + return Shell::GetInstance()->delegate()->GetActiveBrowserContext(); +} + +int SessionStateDelegateStub::GetMaximumNumberOfLoggedInUsers() const { + return 3; +} + +int SessionStateDelegateStub::NumberOfLoggedInUsers() const { + return 1; +} + +bool SessionStateDelegateStub::IsActiveUserSessionStarted() const { + return true; +} + +bool SessionStateDelegateStub::CanLockScreen() const { + return true; +} + +bool SessionStateDelegateStub::IsScreenLocked() const { + return screen_locked_; +} + +bool SessionStateDelegateStub::ShouldLockScreenBeforeSuspending() const { + return false; +} + +void SessionStateDelegateStub::LockScreen() { + shell::CreateLockScreen(); + screen_locked_ = true; + Shell::GetInstance()->UpdateShelfVisibility(); +} + +void SessionStateDelegateStub::UnlockScreen() { + screen_locked_ = false; + Shell::GetInstance()->UpdateShelfVisibility(); +} + +bool SessionStateDelegateStub::IsUserSessionBlocked() const { + return !IsActiveUserSessionStarted() || IsScreenLocked(); +} + +SessionStateDelegate::SessionState SessionStateDelegateStub::GetSessionState() + const { + // Assume that if session is not active we're at login. + return IsActiveUserSessionStarted() ? SESSION_STATE_ACTIVE + : SESSION_STATE_LOGIN_PRIMARY; +} + +const UserInfo* SessionStateDelegateStub::GetUserInfo( + MultiProfileIndex index) const { + return user_info_.get(); +} + +const UserInfo* SessionStateDelegateStub::GetUserInfo( + content::BrowserContext* context) const { + return user_info_.get(); +} + +bool SessionStateDelegateStub::ShouldShowAvatar(aura::Window* window) const { + return !user_info_->GetImage().isNull(); +} + +void SessionStateDelegateStub::SwitchActiveUser(const std::string& user_id) { +} + +void SessionStateDelegateStub::CycleActiveUser(CycleUser cycle_user) { +} + +void SessionStateDelegateStub::AddSessionStateObserver( + ash::SessionStateObserver* observer) { +} + +void SessionStateDelegateStub::RemoveSessionStateObserver( + ash::SessionStateObserver* observer) { +} + +} // namespace ash diff --git a/ash/session/session_state_delegate_stub.h b/ash/session/session_state_delegate_stub.h new file mode 100644 index 0000000..5ce9cf3 --- /dev/null +++ b/ash/session/session_state_delegate_stub.h @@ -0,0 +1,58 @@ +// Copyright (c) 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef ASH_SESSION_SESSION_STATE_DELEGATE_STUB_H_ +#define ASH_SESSION_SESSION_STATE_DELEGATE_STUB_H_ + +#include "ash/session/session_state_delegate.h" +#include "base/basictypes.h" +#include "base/compiler_specific.h" +#include "base/memory/scoped_ptr.h" + +namespace ash { + +// Stub implementation of SessionStateDelegate for testing. +class SessionStateDelegateStub : public SessionStateDelegate { + public: + SessionStateDelegateStub(); + virtual ~SessionStateDelegateStub(); + + // SessionStateDelegate: + virtual content::BrowserContext* GetBrowserContextByIndex( + MultiProfileIndex index) OVERRIDE; + virtual content::BrowserContext* GetBrowserContextForWindow( + aura::Window* window) OVERRIDE; + virtual int GetMaximumNumberOfLoggedInUsers() const OVERRIDE; + virtual int NumberOfLoggedInUsers() const OVERRIDE; + virtual bool IsActiveUserSessionStarted() const OVERRIDE; + virtual bool CanLockScreen() const OVERRIDE; + virtual bool IsScreenLocked() const OVERRIDE; + virtual bool ShouldLockScreenBeforeSuspending() const OVERRIDE; + virtual void LockScreen() OVERRIDE; + virtual void UnlockScreen() OVERRIDE; + virtual bool IsUserSessionBlocked() const OVERRIDE; + virtual SessionState GetSessionState() const OVERRIDE; + virtual const UserInfo* GetUserInfo(MultiProfileIndex index) const OVERRIDE; + virtual const UserInfo* GetUserInfo( + content::BrowserContext* context) const OVERRIDE; + virtual bool ShouldShowAvatar(aura::Window* window) const OVERRIDE; + virtual void SwitchActiveUser(const std::string& user_id) OVERRIDE; + virtual void CycleActiveUser(CycleUser cycle_user) OVERRIDE; + virtual void AddSessionStateObserver( + ash::SessionStateObserver* observer) OVERRIDE; + virtual void RemoveSessionStateObserver( + ash::SessionStateObserver* observer) OVERRIDE; + + private: + bool screen_locked_; + + // A pseudo user info. + scoped_ptr user_info_; + + DISALLOW_COPY_AND_ASSIGN(SessionStateDelegateStub); +}; + +} // namespace ash + +#endif // ASH_SESSION_SESSION_STATE_DELEGATE_STUB_H_ diff --git a/ash/session/session_state_observer.cc b/ash/session/session_state_observer.cc new file mode 100644 index 0000000..48c994e --- /dev/null +++ b/ash/session/session_state_observer.cc @@ -0,0 +1,25 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "ash/session/session_state_observer.h" + +#include "ash/session/session_state_delegate.h" +#include "ash/shell.h" + +namespace ash { + +ScopedSessionStateObserver::ScopedSessionStateObserver( + ash::SessionStateObserver* observer) + : observer_(observer) { + ash::Shell::GetInstance()->session_state_delegate()->AddSessionStateObserver( + observer_); +} + +ScopedSessionStateObserver::~ScopedSessionStateObserver() { + ash::Shell::GetInstance() + ->session_state_delegate() + ->RemoveSessionStateObserver(observer_); +} + +} // namespace ash diff --git a/ash/session/session_state_observer.h b/ash/session/session_state_observer.h new file mode 100644 index 0000000..36fad83 --- /dev/null +++ b/ash/session/session_state_observer.h @@ -0,0 +1,46 @@ +// Copyright (c) 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef ASH_SESSION_SESSION_STATE_OBSERVER_H_ +#define ASH_SESSION_SESSION_STATE_OBSERVER_H_ + +#include + +#include "ash/ash_export.h" +#include "ash/session/session_state_delegate.h" +#include "base/basictypes.h" + +namespace ash { + +class ASH_EXPORT SessionStateObserver { + public: + // Called when active user has changed. + virtual void ActiveUserChanged(const std::string& user_id) {} + + // Called when another user gets added to the existing session. + virtual void UserAddedToSession(const std::string& user_id) {} + + // Called when session state is changed. + virtual void SessionStateChanged(SessionStateDelegate::SessionState state) {} + + protected: + virtual ~SessionStateObserver() {} +}; + +// A class to attach / detach an object as a session state observer with a +// scoped pointer. +class ASH_EXPORT ScopedSessionStateObserver { + public: + explicit ScopedSessionStateObserver(ash::SessionStateObserver* observer); + virtual ~ScopedSessionStateObserver(); + + private: + ash::SessionStateObserver* observer_; + + DISALLOW_COPY_AND_ASSIGN(ScopedSessionStateObserver); +}; + +} // namespace ash + +#endif // ASH_SESSION_SESSION_STATE_OBSERVER_H_ diff --git a/ash/session/user_info.h b/ash/session/user_info.h new file mode 100644 index 0000000..59a4cf4 --- /dev/null +++ b/ash/session/user_info.h @@ -0,0 +1,45 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef ASH_SESSION_USER_INFO_H_ +#define ASH_SESSION_USER_INFO_H_ + +#include + +#include "ash/ash_export.h" +#include "base/strings/string16.h" + +namespace gfx { +class ImageSkia; +} + +namespace ash { + +// A class that represents user related info. +class ASH_EXPORT UserInfo { + public: + virtual ~UserInfo() {} + + // Gets the display name for the user. + virtual base::string16 GetDisplayName() const = 0; + + // Gets the given name of the user. + virtual base::string16 GetGivenName() const = 0; + + // Gets the display email address for the user. + // The display email address might contains some periods in the email name + // as well as capitalized letters. For example: "Foo.Bar@mock.com". + virtual std::string GetEmail() const = 0; + + // Gets the user id (sanitized email address) for the user. + // The function would return something like "foobar@mock.com". + virtual std::string GetUserID() const = 0; + + // Gets the avatar image for the user. + virtual const gfx::ImageSkia& GetImage() const = 0; +}; + +} // namespace ash + +#endif // ASH_SESSION_USER_INFO_H_ diff --git a/ash/session_state_delegate.h b/ash/session_state_delegate.h deleted file mode 100644 index dcbd7f9..0000000 --- a/ash/session_state_delegate.h +++ /dev/null @@ -1,155 +0,0 @@ -// Copyright (c) 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef ASH_SESSION_STATE_DELEGATE_H_ -#define ASH_SESSION_STATE_DELEGATE_H_ - -#include -#include - -#include "ash/ash_export.h" -#include "base/strings/string16.h" - -namespace aura { -class Window; -} // namespace aura - -namespace content { -class BrowserContext; -} - -namespace gfx { -class ImageSkia; -} // namespace gfx - -namespace ash { - -class SessionStateObserver; - -// The index for the multi-profile item to use. The list is always LRU sorted -// So that the index #0 is the currently active user. -typedef int MultiProfileIndex; - -// A list of user_id. -typedef std::vector UserIdList; - -// Delegate for checking and modifying the session state. -// TODO(oshima): Replace MultiProfileIndex with BrowsreContext, bacause -// GetUserXXX are useful for non multi profile scenario in ash_shell. -class ASH_EXPORT SessionStateDelegate { - public: - // Defines the cycle direction for |CycleActiveUser|. - enum CycleUser { - CYCLE_TO_NEXT_USER = 0, // Cycle to the next user. - CYCLE_TO_PREVIOUS_USER, // Cycle to the previous user. - }; - - // Defines session state i.e. whether session is running or not and - // whether user session is blocked by things like multi-profile login. - enum SessionState { - // When primary user login UI is shown i.e. after boot or sign out, - // no active user session exists yet. - SESSION_STATE_LOGIN_PRIMARY = 0, - - // Inside user session (including lock screen), - // no login UI (primary or multi-profiles) is shown. - SESSION_STATE_ACTIVE, - - // When secondary user login UI is shown i.e. other users are - // already logged in and is currently adding another user to the session. - SESSION_STATE_LOGIN_SECONDARY, - }; - - virtual ~SessionStateDelegate() {}; - - // Returns the browser context for the user given by |index|. - virtual content::BrowserContext* GetBrowserContextByIndex( - MultiProfileIndex index) = 0; - - // Returns the browser context associated with the window. - virtual content::BrowserContext* GetBrowserContextForWindow( - aura::Window* window) = 0; - - // Returns the maximum possible number of logged in users. - virtual int GetMaximumNumberOfLoggedInUsers() const = 0; - - // Returns the number of signed in users. If 0 is returned, there is either - // no session in progress or no active user. - virtual int NumberOfLoggedInUsers() const = 0; - - // Returns |true| if the session has been fully started for the active user. - // When a user becomes active, the profile and browser UI are not immediately - // available. Only once this method starts returning |true| is the browser - // startup complete and both profile and UI are fully available. - virtual bool IsActiveUserSessionStarted() const = 0; - - // Returns true if the screen can be locked. - virtual bool CanLockScreen() const = 0; - - // Returns true if the screen is currently locked. - virtual bool IsScreenLocked() const = 0; - - // Returns true if the screen should be locked when the system is about to - // suspend. - virtual bool ShouldLockScreenBeforeSuspending() const = 0; - - // Locks the screen. The locking happens asynchronously. - virtual void LockScreen() = 0; - - // Unlocks the screen. - virtual void UnlockScreen() = 0; - - // Returns |true| if user session blocked by some overlying UI. It can be - // login screen, lock screen or screen for adding users into multi-profile - // session. - virtual bool IsUserSessionBlocked() const = 0; - - // Returns current session state. - virtual SessionState GetSessionState() const = 0; - - // Gets the displayed name for the user with the given |index|. - // Note that |index| can at maximum be |NumberOfLoggedInUsers() - 1|. - virtual const base::string16 GetUserDisplayName( - MultiProfileIndex index) const = 0; - - // Gets the given name of the user with |index|. An empty string can be - // returned if the given name of the user is unknown. - // Note that |index| can at maximum be |NumberOfLoggedInUsers() - 1|. - virtual const base::string16 GetUserGivenName( - MultiProfileIndex index) const = 0; - - // Gets the display email address for the user with the given |index|. - // The display email address might contains some periods in the email name - // as well as capitalized letters. For example: "Foo.Bar@mock.com". - // Note that |index| can at maximum be |NumberOfLoggedInUsers() - 1|. - virtual const std::string GetUserEmail(MultiProfileIndex index) const = 0; - - // Gets the user id (sanitized email address) for the user with the given - // |index|. The function would return something like "foobar@mock.com". - // Note that |index| can at maximum be |NumberOfLoggedInUsers() - 1|. - virtual const std::string GetUserID(MultiProfileIndex index) const = 0; - - // Gets the avatar image for the user associated with the |context|. - virtual const gfx::ImageSkia& GetUserImage( - content::BrowserContext* context) const = 0; - - // Whether or not the window's title should show the avatar. - virtual bool ShouldShowAvatar(aura::Window* window) = 0; - - // Switches to another active user with |user_id| - // (if that user has already signed in). - virtual void SwitchActiveUser(const std::string& user_id) = 0; - - // Switches the active user to the next or previous user, with the same - // ordering as GetLoggedInUsers. - virtual void CycleActiveUser(CycleUser cycle_user) = 0; - - // Adds or removes sessions state observer. - virtual void AddSessionStateObserver(SessionStateObserver* observer) = 0; - virtual void RemoveSessionStateObserver(SessionStateObserver* observer) = 0; -}; - -} // namespace ash - -#endif // ASH_SESSION_STATE_DELEGATE_H_ diff --git a/ash/session_state_delegate_stub.cc b/ash/session_state_delegate_stub.cc deleted file mode 100644 index ba1058b..0000000 --- a/ash/session_state_delegate_stub.cc +++ /dev/null @@ -1,122 +0,0 @@ -// Copyright (c) 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "ash/session_state_delegate_stub.h" - -#include "ash/shell.h" -#include "ash/shell/example_factory.h" -#include "ash/shell_delegate.h" -#include "base/strings/string16.h" -#include "base/strings/utf_string_conversions.h" - -namespace ash { - -SessionStateDelegateStub::SessionStateDelegateStub() : screen_locked_(false) { -} - -SessionStateDelegateStub::~SessionStateDelegateStub() { -} - -content::BrowserContext* -SessionStateDelegateStub::GetBrowserContextByIndex( - MultiProfileIndex index) { - return Shell::GetInstance()->delegate()->GetActiveBrowserContext(); -} - -content::BrowserContext* -SessionStateDelegateStub::GetBrowserContextForWindow( - aura::Window* window) { - return Shell::GetInstance()->delegate()->GetActiveBrowserContext(); -} - -int SessionStateDelegateStub::GetMaximumNumberOfLoggedInUsers() const { - return 3; -} - -int SessionStateDelegateStub::NumberOfLoggedInUsers() const { - return 1; -} - -bool SessionStateDelegateStub::IsActiveUserSessionStarted() const { - return true; -} - -bool SessionStateDelegateStub::CanLockScreen() const { - return true; -} - -bool SessionStateDelegateStub::IsScreenLocked() const { - return screen_locked_; -} - -bool SessionStateDelegateStub::ShouldLockScreenBeforeSuspending() const { - return false; -} - -void SessionStateDelegateStub::LockScreen() { - shell::CreateLockScreen(); - screen_locked_ = true; - Shell::GetInstance()->UpdateShelfVisibility(); -} - -void SessionStateDelegateStub::UnlockScreen() { - screen_locked_ = false; - Shell::GetInstance()->UpdateShelfVisibility(); -} - -bool SessionStateDelegateStub::IsUserSessionBlocked() const { - return !IsActiveUserSessionStarted() || IsScreenLocked(); -} - -SessionStateDelegate::SessionState SessionStateDelegateStub::GetSessionState() - const { - // Assume that if session is not active we're at login. - return IsActiveUserSessionStarted() ? - SESSION_STATE_ACTIVE : SESSION_STATE_LOGIN_PRIMARY; -} - -const base::string16 SessionStateDelegateStub::GetUserDisplayName( - MultiProfileIndex index) const { - return base::UTF8ToUTF16("stub-user"); -} - -const base::string16 SessionStateDelegateStub::GetUserGivenName( - MultiProfileIndex index) const { - return base::UTF8ToUTF16("Stub"); -} - -const std::string SessionStateDelegateStub::GetUserEmail( - MultiProfileIndex index) const { - return "stub-user@domain.com"; -} - -const std::string SessionStateDelegateStub::GetUserID( - MultiProfileIndex index) const { - return GetUserEmail(index); -} - -const gfx::ImageSkia& SessionStateDelegateStub::GetUserImage( - content::BrowserContext* context) const { - return user_image_; -} - -bool SessionStateDelegateStub::ShouldShowAvatar(aura::Window* window) { - return !user_image_.isNull(); -} - -void SessionStateDelegateStub::SwitchActiveUser(const std::string& user_id) { -} - -void SessionStateDelegateStub::CycleActiveUser(CycleUser cycle_user) { -} - -void SessionStateDelegateStub::AddSessionStateObserver( - ash::SessionStateObserver* observer) { -} - -void SessionStateDelegateStub::RemoveSessionStateObserver( - ash::SessionStateObserver* observer) { -} - -} // namespace ash diff --git a/ash/session_state_delegate_stub.h b/ash/session_state_delegate_stub.h deleted file mode 100644 index 5145fb8..0000000 --- a/ash/session_state_delegate_stub.h +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright (c) 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef ASH_SESSION_STATE_DELEGATE_STUB_H_ -#define ASH_SESSION_STATE_DELEGATE_STUB_H_ - -#include "ash/session_state_delegate.h" -#include "base/basictypes.h" -#include "base/compiler_specific.h" -#include "ui/gfx/image/image_skia.h" - -namespace ash { - -// Stub implementation of SessionStateDelegate for testing. -class SessionStateDelegateStub : public SessionStateDelegate { - public: - SessionStateDelegateStub(); - virtual ~SessionStateDelegateStub(); - - // SessionStateDelegate: - virtual content::BrowserContext* GetBrowserContextByIndex( - MultiProfileIndex index) OVERRIDE; - virtual content::BrowserContext* GetBrowserContextForWindow( - aura::Window* window) OVERRIDE; - virtual int GetMaximumNumberOfLoggedInUsers() const OVERRIDE; - virtual int NumberOfLoggedInUsers() const OVERRIDE; - virtual bool IsActiveUserSessionStarted() const OVERRIDE; - virtual bool CanLockScreen() const OVERRIDE; - virtual bool IsScreenLocked() const OVERRIDE; - virtual bool ShouldLockScreenBeforeSuspending() const OVERRIDE; - virtual void LockScreen() OVERRIDE; - virtual void UnlockScreen() OVERRIDE; - virtual bool IsUserSessionBlocked() const OVERRIDE; - virtual SessionState GetSessionState() const OVERRIDE; - virtual const base::string16 GetUserDisplayName( - ash::MultiProfileIndex index) const OVERRIDE; - virtual const base::string16 GetUserGivenName( - ash::MultiProfileIndex index) const OVERRIDE; - virtual const std::string GetUserEmail( - ash::MultiProfileIndex index) const OVERRIDE; - virtual const std::string GetUserID( - ash::MultiProfileIndex index) const OVERRIDE; - virtual const gfx::ImageSkia& GetUserImage( - content::BrowserContext* context) const OVERRIDE; - virtual bool ShouldShowAvatar(aura::Window* window) OVERRIDE; - virtual void SwitchActiveUser(const std::string& user_id) OVERRIDE; - virtual void CycleActiveUser(CycleUser cycle_user) OVERRIDE; - virtual void AddSessionStateObserver( - ash::SessionStateObserver* observer) OVERRIDE; - virtual void RemoveSessionStateObserver( - ash::SessionStateObserver* observer) OVERRIDE; - - private: - bool screen_locked_; - - // A pseudo user image. - gfx::ImageSkia user_image_; - - DISALLOW_COPY_AND_ASSIGN(SessionStateDelegateStub); -}; - -} // namespace ash - -#endif // ASH_SESSION_STATE_DELEGATE_STUB_H_ diff --git a/ash/session_state_observer.cc b/ash/session_state_observer.cc deleted file mode 100644 index 96b0771..0000000 --- a/ash/session_state_observer.cc +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "ash/session_state_observer.h" - -#include "ash/session_state_delegate.h" -#include "ash/shell.h" - -namespace ash { - -ScopedSessionStateObserver::ScopedSessionStateObserver( - ash::SessionStateObserver* observer) : observer_(observer) { - ash::Shell::GetInstance()->session_state_delegate()-> - AddSessionStateObserver(observer_); -} - -ScopedSessionStateObserver::~ScopedSessionStateObserver() { - ash::Shell::GetInstance()->session_state_delegate()-> - RemoveSessionStateObserver(observer_); -} - -} // namespace ash - diff --git a/ash/session_state_observer.h b/ash/session_state_observer.h deleted file mode 100644 index 59d6f67..0000000 --- a/ash/session_state_observer.h +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (c) 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef ASH_SESSION_STATE_OBSERVER_H_ -#define ASH_SESSION_STATE_OBSERVER_H_ - -#include - -#include "ash/ash_export.h" -#include "ash/session_state_delegate.h" -#include "base/basictypes.h" - -namespace ash { - -class ASH_EXPORT SessionStateObserver { - public: - // Called when active user has changed. - virtual void ActiveUserChanged(const std::string& user_id) {} - - // Called when another user gets added to the existing session. - virtual void UserAddedToSession(const std::string& user_id) {} - - // Called when session state is changed. - virtual void SessionStateChanged(SessionStateDelegate::SessionState state) {} - - protected: - virtual ~SessionStateObserver() {} -}; - -// A class to attach / detach an object as a session state observer with a -// scoped pointer. -class ASH_EXPORT ScopedSessionStateObserver { - public: - explicit ScopedSessionStateObserver(ash::SessionStateObserver* observer); - virtual ~ScopedSessionStateObserver(); - - private: - ash::SessionStateObserver* observer_; - - DISALLOW_COPY_AND_ASSIGN(ScopedSessionStateObserver); -}; - -} // namespace ash - -#endif // ASH_SESSION_STATE_OBSERVER_H_ diff --git a/ash/shelf/shelf_layout_manager.cc b/ash/shelf/shelf_layout_manager.cc index 7a1998d..9df4bdc 100644 --- a/ash/shelf/shelf_layout_manager.cc +++ b/ash/shelf/shelf_layout_manager.cc @@ -14,7 +14,7 @@ #include "ash/ash_switches.h" #include "ash/root_window_controller.h" #include "ash/screen_util.h" -#include "ash/session_state_delegate.h" +#include "ash/session/session_state_delegate.h" #include "ash/shelf/shelf.h" #include "ash/shelf/shelf_bezel_event_filter.h" #include "ash/shelf/shelf_constants.h" diff --git a/ash/shelf/shelf_layout_manager.h b/ash/shelf/shelf_layout_manager.h index 22ebf4a..f0acb42 100644 --- a/ash/shelf/shelf_layout_manager.h +++ b/ash/shelf/shelf_layout_manager.h @@ -8,7 +8,7 @@ #include #include "ash/ash_export.h" -#include "ash/session_state_observer.h" +#include "ash/session/session_state_observer.h" #include "ash/shelf/background_animator.h" #include "ash/shelf/shelf.h" #include "ash/shelf/shelf_types.h" diff --git a/ash/shelf/shelf_layout_manager_unittest.cc b/ash/shelf/shelf_layout_manager_unittest.cc index 7c8b9f7..cc268fa 100644 --- a/ash/shelf/shelf_layout_manager_unittest.cc +++ b/ash/shelf/shelf_layout_manager_unittest.cc @@ -10,7 +10,7 @@ #include "ash/display/display_manager.h" #include "ash/focus_cycler.h" #include "ash/root_window_controller.h" -#include "ash/session_state_delegate.h" +#include "ash/session/session_state_delegate.h" #include "ash/shelf/shelf.h" #include "ash/shelf/shelf_layout_manager_observer.h" #include "ash/shelf/shelf_view.h" diff --git a/ash/shelf/shelf_widget.cc b/ash/shelf/shelf_widget.cc index 8721312..cf980d2 100644 --- a/ash/shelf/shelf_widget.cc +++ b/ash/shelf/shelf_widget.cc @@ -7,7 +7,7 @@ #include "ash/ash_switches.h" #include "ash/focus_cycler.h" #include "ash/root_window_controller.h" -#include "ash/session_state_delegate.h" +#include "ash/session/session_state_delegate.h" #include "ash/shelf/shelf_constants.h" #include "ash/shelf/shelf_delegate.h" #include "ash/shelf/shelf_layout_manager.h" diff --git a/ash/shell.cc b/ash/shell.cc index 7dbe541..9f19b14 100644 --- a/ash/shell.cc +++ b/ash/shell.cc @@ -36,7 +36,7 @@ #include "ash/media_delegate.h" #include "ash/new_window_delegate.h" #include "ash/root_window_controller.h" -#include "ash/session_state_delegate.h" +#include "ash/session/session_state_delegate.h" #include "ash/shelf/app_list_shelf_item_delegate.h" #include "ash/shelf/shelf_delegate.h" #include "ash/shelf/shelf_item_delegate.h" diff --git a/ash/shell/app_list.cc b/ash/shell/app_list.cc index c3ea36b..c487ba1 100644 --- a/ash/shell/app_list.cc +++ b/ash/shell/app_list.cc @@ -4,7 +4,7 @@ #include -#include "ash/session_state_delegate.h" +#include "ash/session/session_state_delegate.h" #include "ash/shell.h" #include "ash/shell/example_factory.h" #include "ash/shell/toplevel_window.h" diff --git a/ash/shell/lock_view.cc b/ash/shell/lock_view.cc index eae9d9c..d14b593 100644 --- a/ash/shell/lock_view.cc +++ b/ash/shell/lock_view.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "ash/session_state_delegate.h" +#include "ash/session/session_state_delegate.h" #include "ash/shell.h" #include "ash/shell/example_factory.h" #include "ash/shell_window_ids.h" diff --git a/ash/shell/shell_delegate_impl.cc b/ash/shell/shell_delegate_impl.cc index 840c6bb..2bf14e8 100644 --- a/ash/shell/shell_delegate_impl.cc +++ b/ash/shell/shell_delegate_impl.cc @@ -10,8 +10,8 @@ #include "ash/gpu_support_stub.h" #include "ash/media_delegate.h" #include "ash/new_window_delegate.h" -#include "ash/session_state_delegate.h" -#include "ash/session_state_delegate_stub.h" +#include "ash/session/session_state_delegate.h" +#include "ash/session/session_state_delegate_stub.h" #include "ash/shell/context_menu.h" #include "ash/shell/example_factory.h" #include "ash/shell/keyboard_controller_proxy_stub.h" diff --git a/ash/shell/window_type_launcher.cc b/ash/shell/window_type_launcher.cc index 9352823..e0214d3 100644 --- a/ash/shell/window_type_launcher.cc +++ b/ash/shell/window_type_launcher.cc @@ -6,7 +6,7 @@ #include "ash/root_window_controller.h" #include "ash/screensaver/screensaver_view.h" -#include "ash/session_state_delegate.h" +#include "ash/session/session_state_delegate.h" #include "ash/shelf/shelf_widget.h" #include "ash/shell.h" #include "ash/shell/example_factory.h" diff --git a/ash/shell_unittest.cc b/ash/shell_unittest.cc index 343bd1d..5c206a5 100644 --- a/ash/shell_unittest.cc +++ b/ash/shell_unittest.cc @@ -12,7 +12,7 @@ #include "ash/display/mouse_cursor_event_filter.h" #include "ash/drag_drop/drag_drop_controller.h" #include "ash/root_window_controller.h" -#include "ash/session_state_delegate.h" +#include "ash/session/session_state_delegate.h" #include "ash/shelf/shelf.h" #include "ash/shelf/shelf_layout_manager.h" #include "ash/shelf/shelf_widget.h" diff --git a/ash/system/chromeos/network/network_connect.cc b/ash/system/chromeos/network/network_connect.cc index 64a5749..d9e9bcf 100644 --- a/ash/system/chromeos/network/network_connect.cc +++ b/ash/system/chromeos/network/network_connect.cc @@ -4,7 +4,7 @@ #include "ash/system/chromeos/network/network_connect.h" -#include "ash/session_state_delegate.h" +#include "ash/session/session_state_delegate.h" #include "ash/shell.h" #include "ash/system/chromeos/network/network_state_notifier.h" #include "ash/system/system_notifier.h" diff --git a/ash/system/chromeos/power/power_event_observer.cc b/ash/system/chromeos/power/power_event_observer.cc index 776b004..103d2df 100644 --- a/ash/system/chromeos/power/power_event_observer.cc +++ b/ash/system/chromeos/power/power_event_observer.cc @@ -4,7 +4,7 @@ #include "ash/system/chromeos/power/power_event_observer.h" -#include "ash/session_state_delegate.h" +#include "ash/session/session_state_delegate.h" #include "ash/shell.h" #include "ash/system/tray/system_tray_notifier.h" #include "ash/wm/power_button_controller.h" diff --git a/ash/system/chromeos/session/logout_confirmation_controller.cc b/ash/system/chromeos/session/logout_confirmation_controller.cc index 61d8c9b..fdf1cc6 100644 --- a/ash/system/chromeos/session/logout_confirmation_controller.cc +++ b/ash/system/chromeos/session/logout_confirmation_controller.cc @@ -4,7 +4,7 @@ #include "ash/system/chromeos/session/logout_confirmation_controller.h" -#include "ash/session_state_delegate.h" +#include "ash/session/session_state_delegate.h" #include "ash/shell.h" #include "ash/system/chromeos/session/logout_confirmation_dialog.h" #include "base/location.h" diff --git a/ash/system/date/date_default_view.cc b/ash/system/date/date_default_view.cc index 389485f..f9ed123 100644 --- a/ash/system/date/date_default_view.cc +++ b/ash/system/date/date_default_view.cc @@ -5,7 +5,7 @@ #include "ash/system/date/date_default_view.h" #include "ash/metrics/user_metrics_recorder.h" -#include "ash/session_state_delegate.h" +#include "ash/session/session_state_delegate.h" #include "ash/shell.h" #include "ash/system/date/date_view.h" #include "ash/system/tray/special_popup_row.h" diff --git a/ash/system/tray/default_system_tray_delegate.cc b/ash/system/tray/default_system_tray_delegate.cc index 5b254c1..1ac2c04 100644 --- a/ash/system/tray/default_system_tray_delegate.cc +++ b/ash/system/tray/default_system_tray_delegate.cc @@ -6,7 +6,7 @@ #include -#include "ash/session_state_delegate.h" +#include "ash/session/session_state_delegate.h" #include "ash/shell.h" #include "ash/volume_control_delegate.h" #include "base/message_loop/message_loop.h" diff --git a/ash/system/user/accounts_detailed_view.cc b/ash/system/user/accounts_detailed_view.cc index fe5bb68..58956b5 100644 --- a/ash/system/user/accounts_detailed_view.cc +++ b/ash/system/user/accounts_detailed_view.cc @@ -7,6 +7,7 @@ #include #include "ash/multi_profile_uma.h" +#include "ash/session/user_info.h" #include "ash/shell.h" #include "ash/system/tray/fixed_sized_scroll_view.h" #include "ash/system/tray/hover_highlight_view.h" @@ -43,8 +44,10 @@ AccountsDetailedView::AccountsDetailedView(TrayUser* owner, account_list_(NULL), add_account_button_(NULL), add_user_button_(NULL) { - std::string user_id = - Shell::GetInstance()->session_state_delegate()->GetUserID(0); + std::string user_id = Shell::GetInstance() + ->session_state_delegate() + ->GetUserInfo(0) + ->GetUserID(); delegate_ = Shell::GetInstance()->system_tray_delegate()->GetUserAccountsDelegate( user_id); @@ -117,11 +120,12 @@ void AccountsDetailedView::AddAddAccountButton() { SessionStateDelegate* session_state_delegate = Shell::GetInstance()->session_state_delegate(); HoverHighlightView* add_account_button = new HoverHighlightView(this); - base::string16 user_name = session_state_delegate->GetUserGivenName(0); + const UserInfo* user_info = session_state_delegate->GetUserInfo(0); + base::string16 user_name = user_info->GetGivenName(); if (user_name.empty()) - user_name = session_state_delegate->GetUserDisplayName(0); + user_name = user_info->GetDisplayName(); if (user_name.empty()) - user_name = base::ASCIIToUTF16(session_state_delegate->GetUserEmail(0)); + user_name = base::ASCIIToUTF16(user_info->GetEmail()); add_account_button->AddLabel( l10n_util::GetStringFUTF16(IDS_ASH_STATUS_TRAY_ADD_ACCOUNT_LABEL, user_name), diff --git a/ash/system/user/config.cc b/ash/system/user/config.cc index d704393..1ea6d32 100644 --- a/ash/system/user/config.cc +++ b/ash/system/user/config.cc @@ -4,7 +4,7 @@ #include "ash/system/user/config.h" -#include "ash/session_state_delegate.h" +#include "ash/session/session_state_delegate.h" #include "ash/shell.h" #include "ash/shell_delegate.h" diff --git a/ash/system/user/login_status.cc b/ash/system/user/login_status.cc index 3172cd7..97c05c15 100644 --- a/ash/system/user/login_status.cc +++ b/ash/system/user/login_status.cc @@ -4,7 +4,7 @@ #include "ash/system/user/login_status.h" -#include "ash/session_state_delegate.h" +#include "ash/session/session_state_delegate.h" #include "ash/shell.h" #include "base/strings/string_util.h" #include "base/strings/utf_string_conversions.h" diff --git a/ash/system/user/tray_user.cc b/ash/system/user/tray_user.cc index 2a8dfe1..cb5676c 100644 --- a/ash/system/user/tray_user.cc +++ b/ash/system/user/tray_user.cc @@ -6,7 +6,8 @@ #include "ash/ash_switches.h" #include "ash/root_window_controller.h" -#include "ash/session_state_delegate.h" +#include "ash/session/session_state_delegate.h" +#include "ash/session/user_info.h" #include "ash/shelf/shelf_layout_manager.h" #include "ash/shell_delegate.h" #include "ash/system/tray/system_tray.h" @@ -263,7 +264,7 @@ void TrayUser::UpdateAvatarImage(user::LoginStatus status) { content::BrowserContext* context = session_state_delegate-> GetBrowserContextByIndex(GetTrayIndex()); - avatar_->SetImage(session_state_delegate->GetUserImage(context), + avatar_->SetImage(session_state_delegate->GetUserInfo(context)->GetImage(), gfx::Size(kTrayAvatarSize, kTrayAvatarSize)); // Unit tests might come here with no images for some users. diff --git a/ash/system/user/tray_user.h b/ash/system/user/tray_user.h index 0b19d47..1e0aa281 100644 --- a/ash/system/user/tray_user.h +++ b/ash/system/user/tray_user.h @@ -6,7 +6,7 @@ #define ASH_SYSTEM_USER_TRAY_USER_H_ #include "ash/ash_export.h" -#include "ash/session_state_delegate.h" +#include "ash/session/session_state_delegate.h" #include "ash/system/tray/system_tray_item.h" #include "ash/system/user/user_observer.h" #include "base/compiler_specific.h" diff --git a/ash/system/user/tray_user_separator.cc b/ash/system/user/tray_user_separator.cc index dd60f6b..7058d2f 100644 --- a/ash/system/user/tray_user_separator.cc +++ b/ash/system/user/tray_user_separator.cc @@ -4,7 +4,7 @@ #include "ash/system/user/tray_user_separator.h" -#include "ash/session_state_delegate.h" +#include "ash/session/session_state_delegate.h" #include "ash/shell.h" #include "ui/views/view.h" diff --git a/ash/system/user/tray_user_unittest.cc b/ash/system/user/tray_user_unittest.cc index b0d77c4..3205666 100644 --- a/ash/system/user/tray_user_unittest.cc +++ b/ash/system/user/tray_user_unittest.cc @@ -6,6 +6,7 @@ #include "ash/ash_switches.h" #include "ash/root_window_controller.h" +#include "ash/session/user_info.h" #include "ash/shelf/shelf_layout_manager.h" #include "ash/shell.h" #include "ash/shell_delegate.h" @@ -238,10 +239,12 @@ TEST_F(TrayUserTest, MutiUserModeButtonClicks) { // Switch to a new user - which has a capitalized name. ClickUserItem(&generator, 1); - EXPECT_EQ(delegate()->get_activated_user(), delegate()->GetUserID(1)); + const UserInfo* active_user = delegate()->GetActiveUserInfo(); + const UserInfo* second_user = delegate()->GetUserInfo(1); + EXPECT_EQ(active_user->GetUserID(), second_user->GetUserID()); // Since the name is capitalized, the email should be different then the // user_id. - EXPECT_NE(delegate()->get_activated_user(), delegate()->GetUserEmail(1)); + EXPECT_NE(active_user->GetUserID(), second_user->GetEmail()); tray()->CloseSystemBubble(); } diff --git a/ash/system/user/user_card_view.cc b/ash/system/user/user_card_view.cc index 6d5413e..af568ae 100644 --- a/ash/system/user/user_card_view.cc +++ b/ash/system/user/user_card_view.cc @@ -7,7 +7,8 @@ #include #include -#include "ash/session_state_delegate.h" +#include "ash/session/session_state_delegate.h" +#include "ash/session/user_info.h" #include "ash/shell.h" #include "ash/system/tray/system_tray_delegate.h" #include "ash/system/tray/tray_constants.h" @@ -89,8 +90,10 @@ PublicAccountUserDetails::PublicAccountUserDetails(int max_width) // Retrieve the user's display name and wrap it with markers. // Note that since this is a public account it always has to be the primary // user. - base::string16 display_name = - Shell::GetInstance()->session_state_delegate()->GetUserDisplayName(0); + base::string16 display_name = Shell::GetInstance() + ->session_state_delegate() + ->GetUserInfo(0) + ->GetDisplayName(); base::RemoveChars(display_name, kDisplayNameMark, &display_name); display_name = kDisplayNameMark[0] + display_name + kDisplayNameMark[0]; // Retrieve the domain managing the device and wrap it with markers. @@ -305,10 +308,10 @@ void UserCardView::AddUserContent(user::LoginStatus login_status, base::string16 user_name_string = login_status == user::LOGGED_IN_GUEST ? l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_GUEST_LABEL) - : delegate->GetUserDisplayName(multiprofile_index); + : delegate->GetUserInfo(multiprofile_index)->GetDisplayName(); if (user_name_string.empty() && IsMultiAccountSupportedAndUserActive()) - user_name_string = - base::ASCIIToUTF16(delegate->GetUserEmail(multiprofile_index)); + user_name_string = base::ASCIIToUTF16( + delegate->GetUserInfo(multiprofile_index)->GetEmail()); if (!user_name_string.empty()) { username = new views::Label(user_name_string); username->SetHorizontalAlignment(gfx::ALIGN_LEFT); @@ -322,7 +325,8 @@ void UserCardView::AddUserContent(user::LoginStatus login_status, login_status == user::LOGGED_IN_LOCALLY_MANAGED ? l10n_util::GetStringUTF16( IDS_ASH_STATUS_TRAY_LOCALLY_MANAGED_LABEL) - : base::UTF8ToUTF16(delegate->GetUserEmail(multiprofile_index)); + : base::UTF8ToUTF16( + delegate->GetUserInfo(multiprofile_index)->GetEmail()); if (!user_email_string.empty()) { additional = new views::Label(user_email_string); additional->SetFontList( @@ -372,7 +376,7 @@ views::View* UserCardView::CreateIcon(user::LoginStatus login_status, Shell::GetInstance()->session_state_delegate(); content::BrowserContext* context = delegate->GetBrowserContextByIndex(multiprofile_index); - icon->SetImage(delegate->GetUserImage(context), + icon->SetImage(delegate->GetUserInfo(context)->GetImage(), gfx::Size(kTrayAvatarSize, kTrayAvatarSize)); } return icon; diff --git a/ash/system/user/user_view.cc b/ash/system/user/user_view.cc index 4743163..f5eb6833 100644 --- a/ash/system/user/user_view.cc +++ b/ash/system/user/user_view.cc @@ -8,7 +8,8 @@ #include "ash/multi_profile_uma.h" #include "ash/popup_message.h" -#include "ash/session_state_delegate.h" +#include "ash/session/session_state_delegate.h" +#include "ash/session/user_info.h" #include "ash/shell.h" #include "ash/shell_delegate.h" #include "ash/system/tray/system_tray.h" @@ -76,7 +77,7 @@ void SwitchUser(ash::MultiProfileIndex user_index) { ash::Shell::GetInstance()->session_state_delegate(); ash::MultiProfileUMA::RecordSwitchActiveUser( ash::MultiProfileUMA::SWITCH_ACTIVE_USER_BY_TRAY); - delegate->SwitchActiveUser(delegate->GetUserID(user_index)); + delegate->SwitchActiveUser(delegate->GetUserInfo(user_index)->GetUserID()); } class LogoutButton : public TrayPopupLabelButton { diff --git a/ash/system/user/user_view.h b/ash/system/user/user_view.h index e6657c6..b51b4c7 100644 --- a/ash/system/user/user_view.h +++ b/ash/system/user/user_view.h @@ -5,7 +5,7 @@ #ifndef ASH_SYSTEM_USER_USER_VIEW_H_ #define ASH_SYSTEM_USER_USER_VIEW_H_ -#include "ash/session_state_delegate.h" +#include "ash/session/session_state_delegate.h" #include "ash/system/tray/tray_constants.h" #include "ash/system/user/login_status.h" #include "ash/system/user/tray_user.h" diff --git a/ash/test/test_session_state_delegate.cc b/ash/test/test_session_state_delegate.cc index f7efe1d..8831b58 100644 --- a/ash/test/test_session_state_delegate.cc +++ b/ash/test/test_session_state_delegate.cc @@ -7,12 +7,17 @@ #include #include +#include "ash/session/user_info.h" #include "ash/shell.h" #include "ash/system/user/login_status.h" +#include "base/stl_util.h" #include "base/strings/string16.h" #include "base/strings/utf_string_conversions.h" #include "testing/gtest/include/gtest/gtest.h" +namespace ash { +namespace test { + namespace { // The the "canonicalized" user ID from a given |email| address. @@ -24,8 +29,40 @@ std::string GetUserIDFromEmail(const std::string& email) { } // namespace -namespace ash { -namespace test { +class MockUserInfo : public UserInfo { + public: + explicit MockUserInfo(const std::string& id) : email_(id) {} + virtual ~MockUserInfo() {} + + void SetUserImage(const gfx::ImageSkia& user_image) { + user_image_ = user_image; + } + + virtual base::string16 GetDisplayName() const OVERRIDE { + return base::UTF8ToUTF16("Über tray Über tray Über tray Über tray"); + } + + virtual base::string16 GetGivenName() const OVERRIDE { + return base::UTF8ToUTF16("Über Über Über Über"); + } + + virtual std::string GetEmail() const OVERRIDE { return email_; } + + virtual std::string GetUserID() const OVERRIDE { + return GetUserIDFromEmail(GetEmail()); + } + + virtual const gfx::ImageSkia& GetImage() const OVERRIDE { + return user_image_; + } + + // A test user image. + gfx::ImageSkia user_image_; + + std::string email_; + + DISALLOW_COPY_AND_ASSIGN(MockUserInfo); +}; TestSessionStateDelegate::TestSessionStateDelegate() : has_active_user_(false), @@ -34,10 +71,26 @@ TestSessionStateDelegate::TestSessionStateDelegate() should_lock_screen_before_suspending_(false), screen_locked_(false), user_adding_screen_running_(false), - logged_in_users_(1) { + logged_in_users_(1), + active_user_index_(0) { + user_list_.push_back( + new MockUserInfo("First@tray")); // This is intended to be capitalized. + user_list_.push_back( + new MockUserInfo("Second@tray")); // This is intended to be capitalized. + user_list_.push_back(new MockUserInfo("third@tray")); + user_list_.push_back(new MockUserInfo("someone@tray")); } TestSessionStateDelegate::~TestSessionStateDelegate() { + STLDeleteElements(&user_list_); +} + +void TestSessionStateDelegate::AddUser(const std::string user_id) { + user_list_.push_back(new MockUserInfo(user_id)); +} + +const UserInfo* TestSessionStateDelegate::GetActiveUserInfo() const { + return user_list_[active_user_index_]; } content::BrowserContext* @@ -136,51 +189,41 @@ void TestSessionStateDelegate::SetUserAddingScreenRunning( void TestSessionStateDelegate::SetUserImage( const gfx::ImageSkia& user_image) { - user_image_ = user_image; -} - -const base::string16 TestSessionStateDelegate::GetUserDisplayName( - MultiProfileIndex index) const { - return base::UTF8ToUTF16("Über tray Über tray Über tray Über tray"); + user_list_[active_user_index_]->SetUserImage(user_image); } -const base::string16 TestSessionStateDelegate::GetUserGivenName( +const UserInfo* TestSessionStateDelegate::GetUserInfo( MultiProfileIndex index) const { - return base::UTF8ToUTF16("Über Über Über Über"); + int max = static_cast(user_list_.size()); + return user_list_[index < max ? index : max - 1]; } -const std::string TestSessionStateDelegate::GetUserEmail( - MultiProfileIndex index) const { - switch (index) { - case 0: return "First@tray"; // This is intended to be capitalized. - case 1: return "Second@tray"; // This is intended to be capitalized. - case 2: return "third@tray"; - default: return "someone@tray"; - } -} - -const std::string TestSessionStateDelegate::GetUserID( - MultiProfileIndex index) const { - return GetUserIDFromEmail(GetUserEmail(index)); -} - -const gfx::ImageSkia& TestSessionStateDelegate::GetUserImage( +const UserInfo* TestSessionStateDelegate::GetUserInfo( content::BrowserContext* context) const { - return user_image_; + return user_list_[active_user_index_]; } -bool TestSessionStateDelegate::ShouldShowAvatar(aura::Window* window) { - return !user_image_.isNull(); +bool TestSessionStateDelegate::ShouldShowAvatar(aura::Window* window) const { + return !GetActiveUserInfo()->GetImage().isNull(); } void TestSessionStateDelegate::SwitchActiveUser(const std::string& user_id) { // Make sure this is a user id and not an email address. EXPECT_EQ(user_id, GetUserIDFromEmail(user_id)); - activated_user_ = user_id; + active_user_index_ = 0; + for (std::vector::iterator iter = user_list_.begin(); + iter != user_list_.end(); + ++iter) { + if ((*iter)->GetUserID() == user_id) { + active_user_index_ = iter - user_list_.begin(); + return; + } + } + NOTREACHED() << "Unknown user:" << user_id; } void TestSessionStateDelegate::CycleActiveUser(CycleUser cycle_user) { - activated_user_ = "someone@tray"; + SwitchActiveUser("someone@tray"); } void TestSessionStateDelegate::AddSessionStateObserver( diff --git a/ash/test/test_session_state_delegate.h b/ash/test/test_session_state_delegate.h index cceefa2..5616eec 100644 --- a/ash/test/test_session_state_delegate.h +++ b/ash/test/test_session_state_delegate.h @@ -5,7 +5,9 @@ #ifndef ASH_TEST_TEST_SESSION_STATE_DELEGATE_H_ #define ASH_TEST_TEST_SESSION_STATE_DELEGATE_H_ -#include "ash/session_state_delegate.h" +#include + +#include "ash/session/session_state_delegate.h" #include "base/basictypes.h" #include "base/compiler_specific.h" #include "ui/gfx/image/image_skia.h" @@ -13,13 +15,16 @@ namespace ash { namespace test { +class MockUserInfo; + class TestSessionStateDelegate : public SessionStateDelegate { public: TestSessionStateDelegate(); virtual ~TestSessionStateDelegate(); void set_logged_in_users(int users) { logged_in_users_ = users; } - const std::string& get_activated_user() { return activated_user_; } + void AddUser(const std::string user_id); + const UserInfo* GetActiveUserInfo() const; // SessionStateDelegate: virtual content::BrowserContext* GetBrowserContextByIndex( @@ -36,17 +41,11 @@ class TestSessionStateDelegate : public SessionStateDelegate { virtual void UnlockScreen() OVERRIDE; virtual bool IsUserSessionBlocked() const OVERRIDE; virtual SessionState GetSessionState() const OVERRIDE; - virtual const base::string16 GetUserDisplayName( - ash::MultiProfileIndex index) const OVERRIDE; - virtual const base::string16 GetUserGivenName( - ash::MultiProfileIndex index) const OVERRIDE; - virtual const std::string GetUserEmail( - ash::MultiProfileIndex index) const OVERRIDE; - virtual const std::string GetUserID( + virtual const UserInfo* GetUserInfo( ash::MultiProfileIndex index) const OVERRIDE; - virtual const gfx::ImageSkia& GetUserImage( + virtual const UserInfo* GetUserInfo( content::BrowserContext* context) const OVERRIDE; - virtual bool ShouldShowAvatar(aura::Window* window) OVERRIDE; + virtual bool ShouldShowAvatar(aura::Window* window) const OVERRIDE; virtual void SwitchActiveUser(const std::string& user_id) OVERRIDE; virtual void CycleActiveUser(CycleUser cycle_user) OVERRIDE; virtual void AddSessionStateObserver( @@ -108,11 +107,10 @@ class TestSessionStateDelegate : public SessionStateDelegate { // The number of users logged in. int logged_in_users_; - // The activated user. - std::string activated_user_; + // The index for the activated user. + int active_user_index_; - // A test user image. - gfx::ImageSkia user_image_; + std::vector user_list_; DISALLOW_COPY_AND_ASSIGN(TestSessionStateDelegate); }; diff --git a/ash/test/test_shell_delegate.cc b/ash/test/test_shell_delegate.cc index 8ba5ba0..52962ee 100644 --- a/ash/test/test_shell_delegate.cc +++ b/ash/test/test_shell_delegate.cc @@ -10,7 +10,7 @@ #include "ash/gpu_support_stub.h" #include "ash/media_delegate.h" #include "ash/new_window_delegate.h" -#include "ash/session_state_delegate.h" +#include "ash/session/session_state_delegate.h" #include "ash/shell.h" #include "ash/shell/keyboard_controller_proxy_stub.h" #include "ash/shell_window_ids.h" diff --git a/ash/test/test_system_tray_delegate.cc b/ash/test/test_system_tray_delegate.cc index 473802d..c4a45b9 100644 --- a/ash/test/test_system_tray_delegate.cc +++ b/ash/test/test_system_tray_delegate.cc @@ -6,7 +6,7 @@ #include -#include "ash/session_state_delegate.h" +#include "ash/session/session_state_delegate.h" #include "ash/shell.h" #include "base/message_loop/message_loop.h" #include "base/time/time.h" diff --git a/ash/wm/event_client_impl.cc b/ash/wm/event_client_impl.cc index b54e622..a12253c 100644 --- a/ash/wm/event_client_impl.cc +++ b/ash/wm/event_client_impl.cc @@ -4,7 +4,7 @@ #include "ash/wm/event_client_impl.h" -#include "ash/session_state_delegate.h" +#include "ash/session/session_state_delegate.h" #include "ash/shell.h" #include "ash/shell_window_ids.h" #include "ui/aura/window.h" diff --git a/ash/wm/gestures/shelf_gesture_handler.cc b/ash/wm/gestures/shelf_gesture_handler.cc index 42b12c5..6d4a01a 100644 --- a/ash/wm/gestures/shelf_gesture_handler.cc +++ b/ash/wm/gestures/shelf_gesture_handler.cc @@ -5,7 +5,7 @@ #include "ash/wm/gestures/shelf_gesture_handler.h" #include "ash/root_window_controller.h" -#include "ash/session_state_delegate.h" +#include "ash/session/session_state_delegate.h" #include "ash/shelf/shelf_layout_manager.h" #include "ash/shelf/shelf_types.h" #include "ash/shelf/shelf_widget.h" diff --git a/ash/wm/lock_state_controller_unittest.cc b/ash/wm/lock_state_controller_unittest.cc index ee686ed..f9c7dd5 100644 --- a/ash/wm/lock_state_controller_unittest.cc +++ b/ash/wm/lock_state_controller_unittest.cc @@ -5,7 +5,7 @@ #include "ash/wm/lock_state_controller.h" #include "ash/ash_switches.h" -#include "ash/session_state_delegate.h" +#include "ash/session/session_state_delegate.h" #include "ash/shell.h" #include "ash/shell_window_ids.h" #include "ash/test/ash_test_base.h" diff --git a/ash/wm/mru_window_tracker.cc b/ash/wm/mru_window_tracker.cc index 83a805a..ef00dfc 100644 --- a/ash/wm/mru_window_tracker.cc +++ b/ash/wm/mru_window_tracker.cc @@ -6,7 +6,7 @@ #include -#include "ash/session_state_delegate.h" +#include "ash/session/session_state_delegate.h" #include "ash/shell.h" #include "ash/shell_window_ids.h" #include "ash/switchable_windows.h" diff --git a/ash/wm/overview/window_selector_controller.cc b/ash/wm/overview/window_selector_controller.cc index b750e37..4553cf3 100644 --- a/ash/wm/overview/window_selector_controller.cc +++ b/ash/wm/overview/window_selector_controller.cc @@ -6,7 +6,7 @@ #include "ash/metrics/user_metrics_recorder.h" #include "ash/root_window_controller.h" -#include "ash/session_state_delegate.h" +#include "ash/session/session_state_delegate.h" #include "ash/shell.h" #include "ash/system/tray/system_tray_delegate.h" #include "ash/wm/mru_window_tracker.h" diff --git a/ash/wm/power_button_controller.cc b/ash/wm/power_button_controller.cc index f349caf..6e96c65 100644 --- a/ash/wm/power_button_controller.cc +++ b/ash/wm/power_button_controller.cc @@ -5,7 +5,7 @@ #include "ash/wm/power_button_controller.h" #include "ash/ash_switches.h" -#include "ash/session_state_delegate.h" +#include "ash/session/session_state_delegate.h" #include "ash/shell.h" #include "ash/shell_window_ids.h" #include "ash/wm/lock_state_controller.h" diff --git a/ash/wm/stacking_controller.cc b/ash/wm/stacking_controller.cc index 18eccce..7566bed 100644 --- a/ash/wm/stacking_controller.cc +++ b/ash/wm/stacking_controller.cc @@ -5,7 +5,7 @@ #include "ash/wm/stacking_controller.h" #include "ash/root_window_controller.h" -#include "ash/session_state_delegate.h" +#include "ash/session/session_state_delegate.h" #include "ash/shell.h" #include "ash/shell_window_ids.h" #include "ash/wm/always_on_top_controller.h" diff --git a/ash/wm/system_modal_container_layout_manager.cc b/ash/wm/system_modal_container_layout_manager.cc index 7de5759..7ee1ef4 100644 --- a/ash/wm/system_modal_container_layout_manager.cc +++ b/ash/wm/system_modal_container_layout_manager.cc @@ -4,7 +4,7 @@ #include "ash/wm/system_modal_container_layout_manager.h" -#include "ash/session_state_delegate.h" +#include "ash/session/session_state_delegate.h" #include "ash/shell.h" #include "ash/shell_window_ids.h" #include "ash/wm/system_modal_container_event_filter.h" diff --git a/ash/wm/system_modal_container_layout_manager_unittest.cc b/ash/wm/system_modal_container_layout_manager_unittest.cc index 568ea50..ca79cef 100644 --- a/ash/wm/system_modal_container_layout_manager_unittest.cc +++ b/ash/wm/system_modal_container_layout_manager_unittest.cc @@ -5,7 +5,7 @@ #include "ash/wm/system_modal_container_layout_manager.h" #include "ash/root_window_controller.h" -#include "ash/session_state_delegate.h" +#include "ash/session/session_state_delegate.h" #include "ash/shell.h" #include "ash/shell_window_ids.h" #include "ash/test/ash_test_base.h" diff --git a/ash/wm/workspace/workspace_layout_manager.cc b/ash/wm/workspace/workspace_layout_manager.cc index c817141..668f895 100644 --- a/ash/wm/workspace/workspace_layout_manager.cc +++ b/ash/wm/workspace/workspace_layout_manager.cc @@ -7,7 +7,7 @@ #include "ash/display/display_controller.h" #include "ash/root_window_controller.h" #include "ash/screen_util.h" -#include "ash/session_state_delegate.h" +#include "ash/session/session_state_delegate.h" #include "ash/shelf/shelf_layout_manager.h" #include "ash/shell.h" #include "ash/wm/always_on_top_controller.h" diff --git a/ash/wm/workspace/workspace_layout_manager_unittest.cc b/ash/wm/workspace/workspace_layout_manager_unittest.cc index 4af3056..6629357 100644 --- a/ash/wm/workspace/workspace_layout_manager_unittest.cc +++ b/ash/wm/workspace/workspace_layout_manager_unittest.cc @@ -8,7 +8,7 @@ #include "ash/display/display_manager.h" #include "ash/root_window_controller.h" #include "ash/screen_util.h" -#include "ash/session_state_delegate.h" +#include "ash/session/session_state_delegate.h" #include "ash/shelf/shelf_layout_manager.h" #include "ash/shell.h" #include "ash/shell_observer.h" diff --git a/chrome/browser/chromeos/accessibility/accessibility_manager.cc b/chrome/browser/chromeos/accessibility/accessibility_manager.cc index b0152ab..58a9d6f 100644 --- a/chrome/browser/chromeos/accessibility/accessibility_manager.cc +++ b/chrome/browser/chromeos/accessibility/accessibility_manager.cc @@ -8,7 +8,7 @@ #include "ash/autoclick/autoclick_controller.h" #include "ash/high_contrast/high_contrast_controller.h" #include "ash/metrics/user_metrics_recorder.h" -#include "ash/session_state_delegate.h" +#include "ash/session/session_state_delegate.h" #include "ash/shell.h" #include "ash/sticky_keys/sticky_keys_controller.h" #include "ash/system/tray/system_tray_notifier.h" diff --git a/chrome/browser/chromeos/accessibility/accessibility_manager.h b/chrome/browser/chromeos/accessibility/accessibility_manager.h index 21584ee..a0aec2c 100644 --- a/chrome/browser/chromeos/accessibility/accessibility_manager.h +++ b/chrome/browser/chromeos/accessibility/accessibility_manager.h @@ -8,7 +8,7 @@ #include #include "ash/accessibility_delegate.h" -#include "ash/session_state_observer.h" +#include "ash/session/session_state_observer.h" #include "base/callback_list.h" #include "base/memory/weak_ptr.h" #include "base/prefs/pref_change_registrar.h" diff --git a/chrome/browser/chromeos/accessibility/magnification_manager.cc b/chrome/browser/chromeos/accessibility/magnification_manager.cc index 60ff17b..6d2b358 100644 --- a/chrome/browser/chromeos/accessibility/magnification_manager.cc +++ b/chrome/browser/chromeos/accessibility/magnification_manager.cc @@ -8,7 +8,7 @@ #include "ash/magnifier/magnification_controller.h" #include "ash/magnifier/partial_magnification_controller.h" -#include "ash/session_state_delegate.h" +#include "ash/session/session_state_delegate.h" #include "ash/shell.h" #include "ash/shell_delegate.h" #include "ash/system/tray/system_tray_notifier.h" diff --git a/chrome/browser/chromeos/dbus/printer_service_provider.cc b/chrome/browser/chromeos/dbus/printer_service_provider.cc index 0f01405..7813159 100644 --- a/chrome/browser/chromeos/dbus/printer_service_provider.cc +++ b/chrome/browser/chromeos/dbus/printer_service_provider.cc @@ -4,7 +4,7 @@ #include "chrome/browser/chromeos/dbus/printer_service_provider.h" -#include "ash/session_state_delegate.h" +#include "ash/session/session_state_delegate.h" #include "ash/shell.h" #include "ash/wm/window_util.h" #include "base/bind.h" diff --git a/chrome/browser/chromeos/extensions/first_run_private_api.cc b/chrome/browser/chromeos/extensions/first_run_private_api.cc index 9f56c96..2828af6 100644 --- a/chrome/browser/chromeos/extensions/first_run_private_api.cc +++ b/chrome/browser/chromeos/extensions/first_run_private_api.cc @@ -19,11 +19,11 @@ bool FirstRunPrivateGetLocalizedStringsFunction::RunSync() { base::DictionaryValue* localized_strings = new base::DictionaryValue(); chromeos::User* user = chromeos::UserManager::Get()->GetUserByProfile(GetProfile()); - if (!user->given_name().empty()) { + if (!user->GetGivenName().empty()) { localized_strings->SetString( "greetingHeader", l10n_util::GetStringFUTF16(IDS_FIRST_RUN_GREETING_STEP_HEADER, - user->given_name())); + user->GetGivenName())); } else { localized_strings->SetString( "greetingHeader", diff --git a/chrome/browser/chromeos/file_manager/file_manager_browsertest.cc b/chrome/browser/chromeos/file_manager/file_manager_browsertest.cc index a626517c4..04e60ce 100644 --- a/chrome/browser/chromeos/file_manager/file_manager_browsertest.cc +++ b/chrome/browser/chromeos/file_manager/file_manager_browsertest.cc @@ -13,7 +13,7 @@ #include "apps/app_window.h" #include "apps/app_window_registry.h" -#include "ash/session_state_delegate.h" +#include "ash/session/session_state_delegate.h" #include "ash/shell.h" #include "base/bind.h" #include "base/callback.h" diff --git a/chrome/browser/chromeos/login/session_login_browsertest.cc b/chrome/browser/chromeos/login/session_login_browsertest.cc index 75e5b4928..941485a 100644 --- a/chrome/browser/chromeos/login/session_login_browsertest.cc +++ b/chrome/browser/chromeos/login/session_login_browsertest.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "ash/session_state_delegate.h" +#include "ash/session/session_state_delegate.h" #include "ash/shell.h" #include "chrome/browser/chromeos/login/login_manager_test.h" #include "chrome/browser/chromeos/login/startup_utils.h" diff --git a/chrome/browser/chromeos/login/user.cc b/chrome/browser/chromeos/login/user.cc index f165e55..c212228 100644 --- a/chrome/browser/chromeos/login/user.cc +++ b/chrome/browser/chromeos/login/user.cc @@ -10,6 +10,7 @@ #include "base/threading/thread_restrictions.h" #include "chrome/browser/chromeos/login/default_user_images.h" #include "chrome/browser/chromeos/login/user_manager.h" +#include "google_apis/gaia/gaia_auth_util.h" #include "grit/theme_resources.h" #include "ui/base/resource/resource_bundle.h" @@ -168,6 +169,10 @@ void UserContext::CopyFrom(const UserContext& other) { auth_flow = other.auth_flow; } +std::string User::GetEmail() const { + return display_email(); +} + base::string16 User::GetDisplayName() const { // Fallback to the email account name in case display name haven't been set. return display_name_.empty() ? @@ -175,6 +180,18 @@ base::string16 User::GetDisplayName() const { display_name_; } +base::string16 User::GetGivenName() const { + return given_name_; +} + +const gfx::ImageSkia& User::GetImage() const { + return user_image_.image(); +} + +std::string User::GetUserID() const { + return gaia::CanonicalizeEmail(gaia::SanitizeEmail(email())); +} + std::string User::GetAccountName(bool use_display_email) const { if (use_display_email && !display_email_.empty()) return GetUserName(display_email_); diff --git a/chrome/browser/chromeos/login/user.h b/chrome/browser/chromeos/login/user.h index e80b13b..58eb1a3 100644 --- a/chrome/browser/chromeos/login/user.h +++ b/chrome/browser/chromeos/login/user.h @@ -8,6 +8,7 @@ #include #include +#include "ash/session/user_info.h" #include "base/basictypes.h" #include "base/strings/string16.h" #include "chrome/browser/chromeos/login/user_image.h" @@ -69,7 +70,7 @@ struct UserContext { // returned by |displayed_email()|. // Displayed emails are for use in UI only, anywhere else users must be referred // to by |email()|. -class User { +class User : public ash::UserInfo { public: // The user type. Used in a histogram; do not modify existing types. typedef enum { @@ -123,19 +124,20 @@ class User { // The email the user used to log in. const std::string& email() const { return email_; } - // Returns the human name to display for this user. - base::string16 GetDisplayName() const; + // The displayed user name. + base::string16 display_name() const { return display_name_; } - // Returns given name of user, or empty string if given name is unknown. - const base::string16& given_name() const { return given_name_; } + // ash::UserInfo + virtual std::string GetEmail() const OVERRIDE; + virtual base::string16 GetDisplayName() const OVERRIDE; + virtual base::string16 GetGivenName() const OVERRIDE; + virtual const gfx::ImageSkia& GetImage() const OVERRIDE; + virtual std::string GetUserID() const OVERRIDE; // Returns the account name part of the email. Use the display form of the // email if available and use_display_name == true. Otherwise use canonical. std::string GetAccountName(bool use_display_email) const; - // The image for this user. - const gfx::ImageSkia& image() const { return user_image_.image(); } - // Whether the user has a default image. bool HasDefaultImage() const; @@ -168,9 +170,6 @@ class User { // True if image is being loaded from file. bool image_is_loading() const { return image_is_loading_; } - // The displayed user name. - base::string16 display_name() const { return display_name_; } - // The displayed (non-canonical) user email. virtual std::string display_email() const; diff --git a/chrome/browser/chromeos/login/user_adding_screen_browsertest.cc b/chrome/browser/chromeos/login/user_adding_screen_browsertest.cc index fb02077..5c90708 100644 --- a/chrome/browser/chromeos/login/user_adding_screen_browsertest.cc +++ b/chrome/browser/chromeos/login/user_adding_screen_browsertest.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "ash/session_state_delegate.h" +#include "ash/session/session_state_delegate.h" #include "ash/shell.h" #include "base/prefs/pref_service.h" #include "chrome/browser/chromeos/login/login_display_host_impl.h" diff --git a/chrome/browser/chromeos/login/user_image_manager_browsertest.cc b/chrome/browser/chromeos/login/user_image_manager_browsertest.cc index 03d3064..796998b 100644 --- a/chrome/browser/chromeos/login/user_image_manager_browsertest.cc +++ b/chrome/browser/chromeos/login/user_image_manager_browsertest.cc @@ -362,8 +362,8 @@ IN_PROC_BROWSER_TEST_F(UserImageManagerTest, PRE_NonJPEGImageFromFile) { EXPECT_FALSE(user->image_is_safe_format()); // Check image dimensions. const gfx::ImageSkia& saved_image = GetDefaultImage(kFirstDefaultImageIndex); - EXPECT_EQ(saved_image.width(), user->image().width()); - EXPECT_EQ(saved_image.height(), user->image().height()); + EXPECT_EQ(saved_image.width(), user->GetImage().width()); + EXPECT_EQ(saved_image.height(), user->GetImage().height()); } IN_PROC_BROWSER_TEST_F(UserImageManagerTest, NonJPEGImageFromFile) { @@ -380,8 +380,8 @@ IN_PROC_BROWSER_TEST_F(UserImageManagerTest, NonJPEGImageFromFile) { EXPECT_TRUE(user->image_is_safe_format()); // Check image dimensions. Images can't be compared since JPEG is lossy. const gfx::ImageSkia& saved_image = GetDefaultImage(kFirstDefaultImageIndex); - EXPECT_EQ(saved_image.width(), user->image().width()); - EXPECT_EQ(saved_image.height(), user->image().height()); + EXPECT_EQ(saved_image.width(), user->GetImage().width()); + EXPECT_EQ(saved_image.height(), user->GetImage().height()); } IN_PROC_BROWSER_TEST_F(UserImageManagerTest, PRE_SaveUserDefaultImageIndex) { @@ -403,7 +403,7 @@ IN_PROC_BROWSER_TEST_F(UserImageManagerTest, SaveUserDefaultImageIndex) { EXPECT_TRUE(user->HasDefaultImage()); EXPECT_EQ(kFirstDefaultImageIndex, user->image_index()); - EXPECT_TRUE(test::AreImagesEqual(default_image, user->image())); + EXPECT_TRUE(test::AreImagesEqual(default_image, user->GetImage())); ExpectNewUserImageInfo(kTestUser1, kFirstDefaultImageIndex, base::FilePath()); } @@ -432,7 +432,7 @@ IN_PROC_BROWSER_TEST_F(UserImageManagerTest, SaveUserImage) { EXPECT_FALSE(user->HasDefaultImage()); EXPECT_EQ(User::kExternalImageIndex, user->image_index()); - EXPECT_TRUE(test::AreImagesEqual(custom_image, user->image())); + EXPECT_TRUE(test::AreImagesEqual(custom_image, user->GetImage())); ExpectNewUserImageInfo(kTestUser1, User::kExternalImageIndex, GetUserImagePath(kTestUser1, "jpg")); @@ -470,7 +470,7 @@ IN_PROC_BROWSER_TEST_F(UserImageManagerTest, SaveUserImageFromFile) { EXPECT_FALSE(user->HasDefaultImage()); EXPECT_EQ(User::kExternalImageIndex, user->image_index()); - EXPECT_TRUE(test::AreImagesEqual(*custom_image, user->image())); + EXPECT_TRUE(test::AreImagesEqual(*custom_image, user->GetImage())); ExpectNewUserImageInfo(kTestUser1, User::kExternalImageIndex, GetUserImagePath(kTestUser1, "jpg")); @@ -514,7 +514,7 @@ IN_PROC_BROWSER_TEST_F(UserImageManagerTest, SaveUserImageFromProfileImage) { EXPECT_FALSE(user->HasDefaultImage()); EXPECT_EQ(User::kProfileImageIndex, user->image_index()); - EXPECT_TRUE(test::AreImagesEqual(profile_image, user->image())); + EXPECT_TRUE(test::AreImagesEqual(profile_image, user->GetImage())); ExpectNewUserImageInfo(kTestUser1, User::kProfileImageIndex, GetUserImagePath(kTestUser1, "jpg")); @@ -564,7 +564,7 @@ IN_PROC_BROWSER_TEST_F(UserImageManagerTest, EXPECT_TRUE(user->HasDefaultImage()); EXPECT_EQ(kFirstDefaultImageIndex, user->image_index()); - EXPECT_TRUE(test::AreImagesEqual(default_image, user->image())); + EXPECT_TRUE(test::AreImagesEqual(default_image, user->GetImage())); ExpectNewUserImageInfo(kTestUser1, kFirstDefaultImageIndex, base::FilePath()); } @@ -679,7 +679,7 @@ IN_PROC_BROWSER_TEST_F(UserImageManagerPolicyTest, SetAndClear) { EXPECT_FALSE(user->HasDefaultImage()); EXPECT_EQ(User::kExternalImageIndex, user->image_index()); - EXPECT_TRUE(test::AreImagesEqual(*policy_image_, user->image())); + EXPECT_TRUE(test::AreImagesEqual(*policy_image_, user->GetImage())); ExpectNewUserImageInfo(kTestUser1, User::kExternalImageIndex, GetUserImagePath(kTestUser1, "jpg")); @@ -707,7 +707,7 @@ IN_PROC_BROWSER_TEST_F(UserImageManagerPolicyTest, SetAndClear) { EXPECT_FALSE(user->HasDefaultImage()); EXPECT_EQ(User::kExternalImageIndex, user->image_index()); - EXPECT_TRUE(test::AreImagesEqual(*policy_image_, user->image())); + EXPECT_TRUE(test::AreImagesEqual(*policy_image_, user->GetImage())); ExpectNewUserImageInfo(kTestUser1, User::kExternalImageIndex, GetUserImagePath(kTestUser1, "jpg")); @@ -730,7 +730,7 @@ IN_PROC_BROWSER_TEST_F(UserImageManagerPolicyTest, SetAndClear) { EXPECT_TRUE(user->HasDefaultImage()); EXPECT_EQ(kFirstDefaultImageIndex, user->image_index()); - EXPECT_TRUE(test::AreImagesEqual(default_image, user->image())); + EXPECT_TRUE(test::AreImagesEqual(default_image, user->GetImage())); ExpectNewUserImageInfo(kTestUser1, kFirstDefaultImageIndex, base::FilePath()); } @@ -763,7 +763,7 @@ IN_PROC_BROWSER_TEST_F(UserImageManagerPolicyTest, PolicyOverridesUser) { EXPECT_TRUE(user->HasDefaultImage()); EXPECT_EQ(kFirstDefaultImageIndex, user->image_index()); - EXPECT_TRUE(test::AreImagesEqual(default_image, user->image())); + EXPECT_TRUE(test::AreImagesEqual(default_image, user->GetImage())); ExpectNewUserImageInfo(kTestUser1, kFirstDefaultImageIndex, base::FilePath()); // Set policy. Verify that the policy-provided user image is downloaded, set @@ -779,7 +779,7 @@ IN_PROC_BROWSER_TEST_F(UserImageManagerPolicyTest, PolicyOverridesUser) { EXPECT_FALSE(user->HasDefaultImage()); EXPECT_EQ(User::kExternalImageIndex, user->image_index()); - EXPECT_TRUE(test::AreImagesEqual(*policy_image_, user->image())); + EXPECT_TRUE(test::AreImagesEqual(*policy_image_, user->GetImage())); ExpectNewUserImageInfo(kTestUser1, User::kExternalImageIndex, GetUserImagePath(kTestUser1, "jpg")); @@ -825,7 +825,7 @@ IN_PROC_BROWSER_TEST_F(UserImageManagerPolicyTest, UserDoesNotOverridePolicy) { EXPECT_FALSE(user->HasDefaultImage()); EXPECT_EQ(User::kExternalImageIndex, user->image_index()); - EXPECT_TRUE(test::AreImagesEqual(*policy_image_, user->image())); + EXPECT_TRUE(test::AreImagesEqual(*policy_image_, user->GetImage())); ExpectNewUserImageInfo(kTestUser1, User::kExternalImageIndex, GetUserImagePath(kTestUser1, "jpg")); @@ -846,7 +846,7 @@ IN_PROC_BROWSER_TEST_F(UserImageManagerPolicyTest, UserDoesNotOverridePolicy) { EXPECT_FALSE(user->HasDefaultImage()); EXPECT_EQ(User::kExternalImageIndex, user->image_index()); - EXPECT_TRUE(test::AreImagesEqual(*policy_image_, user->image())); + EXPECT_TRUE(test::AreImagesEqual(*policy_image_, user->GetImage())); ExpectNewUserImageInfo(kTestUser1, User::kExternalImageIndex, GetUserImagePath(kTestUser1, "jpg")); diff --git a/chrome/browser/chromeos/login/user_image_manager_impl.cc b/chrome/browser/chromeos/login/user_image_manager_impl.cc index ea729c7..5ead90d 100644 --- a/chrome/browser/chromeos/login/user_image_manager_impl.cc +++ b/chrome/browser/chromeos/login/user_image_manager_impl.cc @@ -858,7 +858,7 @@ void UserImageManagerImpl::TryToInitDownloadedProfileImage() { // user if it has not been initialized already, the user image is the // profile image and the user image has been loaded successfully. VLOG(1) << "Profile image initialized from disk."; - downloaded_profile_image_ = user->image(); + downloaded_profile_image_ = user->GetImage(); profile_image_url_ = user->image_url(); } } diff --git a/chrome/browser/chromeos/memory/oom_priority_manager.cc b/chrome/browser/chromeos/memory/oom_priority_manager.cc index d182ebf..a6d408c 100644 --- a/chrome/browser/chromeos/memory/oom_priority_manager.cc +++ b/chrome/browser/chromeos/memory/oom_priority_manager.cc @@ -9,7 +9,7 @@ #include #include "ash/multi_profile_uma.h" -#include "ash/session_state_delegate.h" +#include "ash/session/session_state_delegate.h" #include "ash/shell.h" #include "base/bind.h" #include "base/bind_helpers.h" diff --git a/chrome/browser/chromeos/policy/device_local_account_browsertest.cc b/chrome/browser/chromeos/policy/device_local_account_browsertest.cc index 793ccca..e439529 100644 --- a/chrome/browser/chromeos/policy/device_local_account_browsertest.cc +++ b/chrome/browser/chromeos/policy/device_local_account_browsertest.cc @@ -1040,7 +1040,7 @@ IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, UserAvatarImage) { EXPECT_FALSE(user->HasDefaultImage()); EXPECT_EQ(chromeos::User::kExternalImageIndex, user->image_index()); - EXPECT_TRUE(chromeos::test::AreImagesEqual(*policy_image, user->image())); + EXPECT_TRUE(chromeos::test::AreImagesEqual(*policy_image, user->GetImage())); const base::DictionaryValue* images_pref = g_browser_process->local_state()->GetDictionary("user_image_info"); ASSERT_TRUE(images_pref); diff --git a/chrome/browser/chromeos/profiles/profile_list_chromeos.cc b/chrome/browser/chromeos/profiles/profile_list_chromeos.cc index 992e758..5860dda 100644 --- a/chrome/browser/chromeos/profiles/profile_list_chromeos.cc +++ b/chrome/browser/chromeos/profiles/profile_list_chromeos.cc @@ -50,7 +50,7 @@ void ProfileListChromeOS::RebuildMenu() { size_t i = profile_info_->GetIndexOfProfileWithPath( ProfileHelper::GetProfilePathByUserIdHash((*it)->username_hash())); - gfx::Image icon = gfx::Image((*it)->image()); + gfx::Image icon = gfx::Image((*it)->GetImage()); if (!CommandLine::ForCurrentProcess()->HasSwitch( switches::kNewProfileManagement)) { // old avatar menu uses resized-small images diff --git a/chrome/browser/idle_chromeos.cc b/chrome/browser/idle_chromeos.cc index 36a33a5..62a72d4 100644 --- a/chrome/browser/idle_chromeos.cc +++ b/chrome/browser/idle_chromeos.cc @@ -4,7 +4,7 @@ #include "chrome/browser/idle.h" -#include "ash/session_state_delegate.h" +#include "ash/session/session_state_delegate.h" #include "ash/shell.h" #include "base/time/time.h" #include "ui/wm/core/user_activity_detector.h" diff --git a/chrome/browser/notifications/message_center_settings_controller.cc b/chrome/browser/notifications/message_center_settings_controller.cc index 9f1e26f..d92a92e 100644 --- a/chrome/browser/notifications/message_center_settings_controller.cc +++ b/chrome/browser/notifications/message_center_settings_controller.cc @@ -475,12 +475,12 @@ void MessageCenterSettingsController::CreateNotifierGroupForGuestLogin() { chromeos::User* user = user_manager->GetActiveUser(); Profile* profile = user_manager->GetProfileByUser(user); DCHECK(profile); - notifier_groups_.push_back(new message_center::ProfileNotifierGroup( - gfx::Image(user->image()), - user->GetDisplayName(), - user->GetDisplayName(), - 0, - profile)); + notifier_groups_.push_back( + new message_center::ProfileNotifierGroup(gfx::Image(user->GetImage()), + user->GetDisplayName(), + user->GetDisplayName(), + 0, + profile)); FOR_EACH_OBSERVER(message_center::NotifierSettingsObserver, observers_, diff --git a/chrome/browser/ui/ash/launcher/chrome_launcher_controller_unittest.cc b/chrome/browser/ui/ash/launcher/chrome_launcher_controller_unittest.cc index 4c50411..b0b4a01 100644 --- a/chrome/browser/ui/ash/launcher/chrome_launcher_controller_unittest.cc +++ b/chrome/browser/ui/ash/launcher/chrome_launcher_controller_unittest.cc @@ -799,9 +799,7 @@ class MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest ChromeLauncherControllerTest::SetUp(); // Get some base objects. - session_delegate_ = static_cast( - ash::Shell::GetInstance()->session_state_delegate()); - session_delegate_->set_logged_in_users(2); + session_delegate()->set_logged_in_users(2); shell_delegate_ = static_cast( ash::Shell::GetInstance()->delegate()); shell_delegate_->set_multi_profiles_enabled(true); @@ -825,8 +823,11 @@ class MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest // the ownership of the created object. TestingProfile* CreateMultiUserProfile(const std::string& user_name) { std::string email_string = user_name + "@example.com"; - + static_cast( + ash::Shell::GetInstance()->session_state_delegate()) + ->AddUser(email_string); // Add a user to the fake user manager. + session_delegate()->AddUser(email_string); GetFakeUserManager()->AddUser(email_string); GetFakeUserManager()->UserLoggedIn( @@ -904,8 +905,10 @@ class MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest return v1_app; } - ash::test::TestSessionStateDelegate* - session_delegate() { return session_delegate_; } + ash::test::TestSessionStateDelegate* session_delegate() { + return static_cast( + ash::Shell::GetInstance()->session_state_delegate()); + } ash::test::TestShellDelegate* shell_delegate() { return shell_delegate_; } // Override BrowserWithTestWindowTest: @@ -936,7 +939,6 @@ class MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest scoped_ptr profile_manager_; scoped_ptr user_manager_enabler_; - ash::test::TestSessionStateDelegate* session_delegate_; ash::test::TestShellDelegate* shell_delegate_; ProfileToNameMap created_profiles_; diff --git a/chrome/browser/ui/ash/multi_user/multi_user_context_menu_chromeos.cc b/chrome/browser/ui/ash/multi_user/multi_user_context_menu_chromeos.cc index 84a5fd7..8d56f0a 100644 --- a/chrome/browser/ui/ash/multi_user/multi_user_context_menu_chromeos.cc +++ b/chrome/browser/ui/ash/multi_user/multi_user_context_menu_chromeos.cc @@ -5,7 +5,7 @@ #include "chrome/browser/ui/ash/multi_user/multi_user_context_menu.h" #include "ash/multi_profile_uma.h" -#include "ash/session_state_delegate.h" +#include "ash/session/session_state_delegate.h" #include "ash/shell.h" #include "base/bind.h" #include "base/callback.h" @@ -87,13 +87,13 @@ scoped_ptr CreateMultiUserContextMenu(aura::Window* window) { new chromeos::MultiUserContextMenuChromeos(window); model.reset(menu); for (int user_index = 1; user_index < logged_in_users; ++user_index) { - menu->AddItem( - user_index == 1 ? IDC_VISIT_DESKTOP_OF_LRU_USER_2 : - IDC_VISIT_DESKTOP_OF_LRU_USER_3, - l10n_util::GetStringFUTF16( - IDS_VISIT_DESKTOP_OF_LRU_USER, - delegate->GetUserDisplayName(user_index), - base::ASCIIToUTF16(delegate->GetUserEmail(user_index)))); + const ash::UserInfo* user_info = delegate->GetUserInfo(user_index); + menu->AddItem(user_index == 1 ? IDC_VISIT_DESKTOP_OF_LRU_USER_2 + : IDC_VISIT_DESKTOP_OF_LRU_USER_3, + l10n_util::GetStringFUTF16( + IDS_VISIT_DESKTOP_OF_LRU_USER, + user_info->GetDisplayName(), + base::ASCIIToUTF16(user_info->GetEmail()))); } } return model.Pass(); @@ -118,8 +118,11 @@ void ExecuteVisitDesktopCommand(int command_id, aura::Window* window) { // When running the multi user mode on Chrome OS, windows can "visit" // another user's desktop. const std::string& user_id = - ash::Shell::GetInstance()->session_state_delegate()->GetUserID( - IDC_VISIT_DESKTOP_OF_LRU_USER_2 == command_id ? 1 : 2); + ash::Shell::GetInstance() + ->session_state_delegate() + ->GetUserInfo(IDC_VISIT_DESKTOP_OF_LRU_USER_2 == command_id ? 1 + : 2) + ->GetUserID(); base::Callback on_accept = base::Bind(&OnAcceptTeleportWarning, user_id, window); diff --git a/chrome/browser/ui/ash/multi_user/multi_user_notification_blocker_chromeos_unittest.cc b/chrome/browser/ui/ash/multi_user/multi_user_notification_blocker_chromeos_unittest.cc index 2d1bc91..88bf046 100644 --- a/chrome/browser/ui/ash/multi_user/multi_user_notification_blocker_chromeos_unittest.cc +++ b/chrome/browser/ui/ash/multi_user/multi_user_notification_blocker_chromeos_unittest.cc @@ -2,10 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "ash/session_state_delegate.h" +#include "ash/session/session_state_delegate.h" +#include "ash/session/user_info.h" #include "ash/shell.h" #include "ash/system/system_notifier.h" #include "ash/test/ash_test_base.h" +#include "ash/test/test_session_state_delegate.h" #include "ash/test/test_shell_delegate.h" #include "chrome/browser/ui/ash/multi_user/multi_user_notification_blocker_chromeos.h" #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.h" @@ -38,6 +40,11 @@ class MultiUserNotificationBlockerChromeOSTest shell_delegate->set_multi_profiles_enabled(true); chrome::MultiUserWindowManager::CreateInstance(); + ash::test::TestSessionStateDelegate* session_state_delegate = + static_cast( + ash::Shell::GetInstance()->session_state_delegate()); + session_state_delegate->AddUser("test2@example.com"); + // Disable any animations for the test. GetMultiUserWindowManager()->SetAnimationSpeedForTest( chrome::MultiUserWindowManagerChromeOS::ANIMATION_SPEED_DISABLED); @@ -64,7 +71,10 @@ class MultiUserNotificationBlockerChromeOSTest } const std::string GetDefaultUserId() { - return ash::Shell::GetInstance()->session_state_delegate()->GetUserID(0); + return ash::Shell::GetInstance() + ->session_state_delegate() + ->GetUserInfo(0) + ->GetUserID(); } const message_center::NotificationBlocker* blocker() { diff --git a/chrome/browser/ui/ash/multi_user/multi_user_window_manager.cc b/chrome/browser/ui/ash/multi_user/multi_user_window_manager.cc index fc269782..93b2af1 100644 --- a/chrome/browser/ui/ash/multi_user/multi_user_window_manager.cc +++ b/chrome/browser/ui/ash/multi_user/multi_user_window_manager.cc @@ -10,7 +10,8 @@ #if defined(OS_CHROMEOS) #include "ash/ash_switches.h" #include "ash/multi_profile_uma.h" -#include "ash/session_state_delegate.h" +#include "ash/session/session_state_delegate.h" +#include "ash/session/user_info.h" #include "ash/shell.h" #include "ash/shell_delegate.h" #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.h" @@ -41,8 +42,11 @@ MultiUserWindowManager* MultiUserWindowManager::CreateInstance() { ash::MultiProfileUMA::SESSION_SINGLE_USER_MODE; if (!g_instance && ash::Shell::GetInstance()->delegate()->IsMultiProfilesEnabled()) { - g_instance = new MultiUserWindowManagerChromeOS( - ash::Shell::GetInstance()->session_state_delegate()->GetUserID(0)); + g_instance = + new MultiUserWindowManagerChromeOS(ash::Shell::GetInstance() + ->session_state_delegate() + ->GetUserInfo(0) + ->GetUserID()); multi_user_mode_ = MULTI_PROFILE_MODE_SEPARATED; mode = ash::MultiProfileUMA::SESSION_SEPARATE_DESKTOP_MODE; } else if (ash::Shell::GetInstance()->delegate()->IsMultiProfilesEnabled()) { diff --git a/chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.cc b/chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.cc index d1e344e4..50480bcc 100644 --- a/chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.cc +++ b/chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.cc @@ -9,7 +9,7 @@ #include "ash/ash_switches.h" #include "ash/multi_profile_uma.h" #include "ash/root_window_controller.h" -#include "ash/session_state_delegate.h" +#include "ash/session/session_state_delegate.h" #include "ash/shelf/shelf.h" #include "ash/shell.h" #include "ash/shell_delegate.h" diff --git a/chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.h b/chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.h index 66a89cc..4812431 100644 --- a/chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.h +++ b/chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.h @@ -8,7 +8,7 @@ #include #include -#include "ash/session_state_observer.h" +#include "ash/session/session_state_observer.h" #include "base/compiler_specific.h" #include "base/memory/scoped_ptr.h" #include "base/observer_list.h" diff --git a/chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos_unittest.cc b/chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos_unittest.cc index 44fe75c..8dc3171 100644 --- a/chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos_unittest.cc +++ b/chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos_unittest.cc @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "ash/session/user_info.h" #include "ash/shell.h" #include "ash/shell_window_ids.h" #include "ash/test/ash_test_base.h" @@ -102,7 +103,8 @@ class MultiUserWindowManagerChromeOSTest : public AshTestBase { // manager. This function gets the current user from it and also sets it to // the multi user window manager. std::string GetAndValidateCurrentUserFromSessionStateObserver() { - const std::string& user = session_state_delegate()->get_activated_user(); + const std::string& user = + session_state_delegate()->GetActiveUserInfo()->GetUserID(); if (user != multi_user_window_manager_->GetCurrentUserForTest()) multi_user_window_manager()->ActiveUserChanged(user); return user; @@ -148,6 +150,9 @@ void MultiUserWindowManagerChromeOSTest::SetUp() { session_state_delegate_ = static_cast ( ash::Shell::GetInstance()->session_state_delegate()); + session_state_delegate_->AddUser("a"); + session_state_delegate_->AddUser("b"); + session_state_delegate_->AddUser("c"); } void MultiUserWindowManagerChromeOSTest::SetUpForThisManyWindows(int windows) { @@ -643,11 +648,11 @@ TEST_F(MultiUserWindowManagerChromeOSTest, SwitchUsersUponModalityChange) { // Making the window system modal should not change anything. MakeWindowSystemModal(window(0)); - EXPECT_EQ("a", session_state_delegate()->get_activated_user()); + EXPECT_EQ("a", session_state_delegate()->GetActiveUserInfo()->GetUserID()); // Making the window owned by user B should switch users. multi_user_window_manager()->SetWindowOwner(window(0), "b"); - EXPECT_EQ("b", session_state_delegate()->get_activated_user()); + EXPECT_EQ("b", session_state_delegate()->GetActiveUserInfo()->GetUserID()); } // Test that a system modal dialog will not switch desktop if active user has @@ -658,11 +663,11 @@ TEST_F(MultiUserWindowManagerChromeOSTest, DontSwitchUsersUponModalityChange) { // Making the window system modal should not change anything. MakeWindowSystemModal(window(0)); - EXPECT_EQ("a", session_state_delegate()->get_activated_user()); + EXPECT_EQ("a", session_state_delegate()->GetActiveUserInfo()->GetUserID()); // Making the window owned by user a should not switch users. multi_user_window_manager()->SetWindowOwner(window(0), "a"); - EXPECT_EQ("a", session_state_delegate()->get_activated_user()); + EXPECT_EQ("a", session_state_delegate()->GetActiveUserInfo()->GetUserID()); } // Test that a system modal dialog will not switch if shown on correct desktop @@ -678,7 +683,7 @@ TEST_F(MultiUserWindowManagerChromeOSTest, MakeWindowSystemModal(window(0)); // Showing the window should trigger no user switch. window(0)->Show(); - EXPECT_EQ("a", session_state_delegate()->get_activated_user()); + EXPECT_EQ("a", session_state_delegate()->GetActiveUserInfo()->GetUserID()); } // Test that a system modal dialog will switch if shown on incorrect desktop but @@ -694,7 +699,7 @@ TEST_F(MultiUserWindowManagerChromeOSTest, MakeWindowSystemModal(window(0)); // Showing the window should trigger a user switch. window(0)->Show(); - EXPECT_EQ("b", session_state_delegate()->get_activated_user()); + EXPECT_EQ("b", session_state_delegate()->GetActiveUserInfo()->GetUserID()); } // Test that using the full user switch animations are working as expected. diff --git a/chrome/browser/ui/ash/session_state_delegate_chromeos.cc b/chrome/browser/ui/ash/session_state_delegate_chromeos.cc index 07997ea..8679a41 100644 --- a/chrome/browser/ui/ash/session_state_delegate_chromeos.cc +++ b/chrome/browser/ui/ash/session_state_delegate_chromeos.cc @@ -5,7 +5,7 @@ #include "chrome/browser/ui/ash/session_state_delegate_chromeos.h" #include "ash/multi_profile_uma.h" -#include "ash/session_state_observer.h" +#include "ash/session/session_state_observer.h" #include "base/command_line.h" #include "base/logging.h" #include "base/prefs/pref_service.h" @@ -132,44 +132,21 @@ SessionStateDelegateChromeos::GetSessionState() const { return session_state_; } -const base::string16 SessionStateDelegateChromeos::GetUserDisplayName( +const ash::UserInfo* SessionStateDelegateChromeos::GetUserInfo( ash::MultiProfileIndex index) const { DCHECK_LT(index, NumberOfLoggedInUsers()); - return chromeos::UserManager::Get()-> - GetLRULoggedInUsers()[index]->display_name(); + return chromeos::UserManager::Get()->GetLRULoggedInUsers()[index]; } -const base::string16 SessionStateDelegateChromeos::GetUserGivenName( - ash::MultiProfileIndex index) const { - DCHECK_LT(index, NumberOfLoggedInUsers()); - return chromeos::UserManager::Get() - ->GetLRULoggedInUsers()[index] - ->given_name(); -} - -const std::string SessionStateDelegateChromeos::GetUserEmail( - ash::MultiProfileIndex index) const { - DCHECK_LT(index, NumberOfLoggedInUsers()); - return chromeos::UserManager::Get()-> - GetLRULoggedInUsers()[index]->display_email(); -} - -const std::string SessionStateDelegateChromeos::GetUserID( - ash::MultiProfileIndex index) const { - DCHECK_LT(index, NumberOfLoggedInUsers()); - return gaia::CanonicalizeEmail(gaia::SanitizeEmail( - chromeos::UserManager::Get()-> - GetLRULoggedInUsers()[index]->email())); -} - -const gfx::ImageSkia& SessionStateDelegateChromeos::GetUserImage( +const ash::UserInfo* SessionStateDelegateChromeos::GetUserInfo( content::BrowserContext* context) const { DCHECK(context); return chromeos::UserManager::Get()->GetUserByProfile( - Profile::FromBrowserContext(context))->image(); + Profile::FromBrowserContext(context)); } -bool SessionStateDelegateChromeos::ShouldShowAvatar(aura::Window* window) { +bool SessionStateDelegateChromeos::ShouldShowAvatar( + aura::Window* window) const { return chrome::MultiUserWindowManager::GetInstance()-> ShouldShowAvatar(window); } diff --git a/chrome/browser/ui/ash/session_state_delegate_chromeos.h b/chrome/browser/ui/ash/session_state_delegate_chromeos.h index 913462b..2b28c0d 100644 --- a/chrome/browser/ui/ash/session_state_delegate_chromeos.h +++ b/chrome/browser/ui/ash/session_state_delegate_chromeos.h @@ -5,7 +5,7 @@ #ifndef CHROME_BROWSER_UI_ASH_SESSION_STATE_DELEGATE_CHROMEOS_H_ #define CHROME_BROWSER_UI_ASH_SESSION_STATE_DELEGATE_CHROMEOS_H_ -#include "ash/session_state_delegate.h" +#include "ash/session/session_state_delegate.h" #include "base/basictypes.h" #include "base/compiler_specific.h" #include "base/observer_list.h" @@ -41,17 +41,11 @@ class SessionStateDelegateChromeos virtual void UnlockScreen() OVERRIDE; virtual bool IsUserSessionBlocked() const OVERRIDE; virtual SessionState GetSessionState() const OVERRIDE; - virtual const base::string16 GetUserDisplayName( + virtual const ash::UserInfo* GetUserInfo( ash::MultiProfileIndex index) const OVERRIDE; - virtual const base::string16 GetUserGivenName( - ash::MultiProfileIndex index) const OVERRIDE; - virtual const std::string GetUserEmail( - ash::MultiProfileIndex index) const OVERRIDE; - virtual const std::string GetUserID( - ash::MultiProfileIndex index) const OVERRIDE; - virtual const gfx::ImageSkia& GetUserImage( + virtual const ash::UserInfo* GetUserInfo( content::BrowserContext* context) const OVERRIDE; - virtual bool ShouldShowAvatar(aura::Window* window) OVERRIDE; + virtual bool ShouldShowAvatar(aura::Window* window) const OVERRIDE; virtual void SwitchActiveUser(const std::string& user_id) OVERRIDE; virtual void CycleActiveUser(CycleUser cycle_user) OVERRIDE; virtual void AddSessionStateObserver( diff --git a/chrome/browser/ui/ash/session_state_delegate_views.cc b/chrome/browser/ui/ash/session_state_delegate_views.cc index e3e86b1..2be4389 100644 --- a/chrome/browser/ui/ash/session_state_delegate_views.cc +++ b/chrome/browser/ui/ash/session_state_delegate_views.cc @@ -4,15 +4,50 @@ #include "chrome/browser/ui/ash/session_state_delegate_views.h" +#include "ash/session/user_info.h" #include "base/logging.h" #include "base/strings/string16.h" #include "base/strings/utf_string_conversions.h" #include "ui/gfx/image/image_skia.h" namespace { -// This isn't really used. It is mainly here to make the compiler happy. -gfx::ImageSkia null_image; -} + +class EmptyUserInfo : public ash::UserInfo { + public: + EmptyUserInfo() {} + virtual ~EmptyUserInfo() {} + + // ash::UserInfo: + virtual base::string16 GetDisplayName() const OVERRIDE { + NOTIMPLEMENTED(); + return base::UTF8ToUTF16(std::string()); + } + virtual base::string16 GetGivenName() const OVERRIDE { + NOTIMPLEMENTED(); + return base::UTF8ToUTF16(std::string()); + } + virtual std::string GetEmail() const OVERRIDE { + NOTIMPLEMENTED(); + return std::string(); + } + virtual std::string GetUserID() const OVERRIDE { + NOTIMPLEMENTED(); + return std::string(); + } + + virtual const gfx::ImageSkia& GetImage() const OVERRIDE { + NOTIMPLEMENTED(); + // To make the compiler happy. + return null_image_; + } + + private: + const gfx::ImageSkia null_image_; + + DISALLOW_COPY_AND_ASSIGN(EmptyUserInfo); +}; + +} // namespace SessionStateDelegate::SessionStateDelegate() { } @@ -71,38 +106,18 @@ ash::SessionStateDelegate::SessionState SessionStateDelegate::GetSessionState() return SESSION_STATE_ACTIVE; } -const base::string16 SessionStateDelegate::GetUserDisplayName( - ash::MultiProfileIndex index) const { - NOTIMPLEMENTED(); - return base::UTF8ToUTF16(""); -} - -const base::string16 SessionStateDelegate::GetUserGivenName( - ash::MultiProfileIndex index) const { - NOTIMPLEMENTED(); - return base::UTF8ToUTF16(""); -} - -const std::string SessionStateDelegate::GetUserEmail( - ash::MultiProfileIndex index) const { - NOTIMPLEMENTED(); - return ""; -} - -const std::string SessionStateDelegate::GetUserID( +const ash::UserInfo* SessionStateDelegate::GetUserInfo( ash::MultiProfileIndex index) const { - NOTIMPLEMENTED(); - return ""; + return GetUserInfo(NULL); } -const gfx::ImageSkia& SessionStateDelegate::GetUserImage( +const ash::UserInfo* SessionStateDelegate::GetUserInfo( content::BrowserContext* context) const { - NOTIMPLEMENTED(); - // To make the compiler happy. - return null_image; + static const ash::UserInfo* kUserInfo = new EmptyUserInfo(); + return kUserInfo; } -bool SessionStateDelegate::ShouldShowAvatar(aura::Window* window) { +bool SessionStateDelegate::ShouldShowAvatar(aura::Window* window) const { return false; } diff --git a/chrome/browser/ui/ash/session_state_delegate_views.h b/chrome/browser/ui/ash/session_state_delegate_views.h index 8f6ac61..717fa61 100644 --- a/chrome/browser/ui/ash/session_state_delegate_views.h +++ b/chrome/browser/ui/ash/session_state_delegate_views.h @@ -5,7 +5,7 @@ #ifndef CHROME_BROWSER_UI_ASH_SESSION_STATE_DELEGATE_VIEWS_H_ #define CHROME_BROWSER_UI_ASH_SESSION_STATE_DELEGATE_VIEWS_H_ -#include "ash/session_state_delegate.h" +#include "ash/session/session_state_delegate.h" #include "base/basictypes.h" #include "base/compiler_specific.h" #include "base/observer_list.h" @@ -34,17 +34,11 @@ class SessionStateDelegate : public ash::SessionStateDelegate { virtual void UnlockScreen() OVERRIDE; virtual bool IsUserSessionBlocked() const OVERRIDE; virtual SessionState GetSessionState() const OVERRIDE; - virtual const base::string16 GetUserDisplayName( + virtual const ash::UserInfo* GetUserInfo( ash::MultiProfileIndex index) const OVERRIDE; - virtual const base::string16 GetUserGivenName( - ash::MultiProfileIndex index) const OVERRIDE; - virtual const std::string GetUserEmail( - ash::MultiProfileIndex index) const OVERRIDE; - virtual const std::string GetUserID( - ash::MultiProfileIndex index) const OVERRIDE; - virtual const gfx::ImageSkia& GetUserImage( + virtual const ash::UserInfo* GetUserInfo( content::BrowserContext* context) const OVERRIDE; - virtual bool ShouldShowAvatar(aura::Window* window) OVERRIDE; + virtual bool ShouldShowAvatar(aura::Window* window) const OVERRIDE; virtual void SwitchActiveUser(const std::string& user_id) OVERRIDE; virtual void CycleActiveUser(CycleUser cycle_user) OVERRIDE; virtual void AddSessionStateObserver( diff --git a/chrome/browser/ui/ash/system_tray_delegate_chromeos.cc b/chrome/browser/ui/ash/system_tray_delegate_chromeos.cc index 000bd67..02eaccd 100644 --- a/chrome/browser/ui/ash/system_tray_delegate_chromeos.cc +++ b/chrome/browser/ui/ash/system_tray_delegate_chromeos.cc @@ -14,8 +14,8 @@ #include "ash/ime/input_method_menu_item.h" #include "ash/ime/input_method_menu_manager.h" #include "ash/metrics/user_metrics_recorder.h" -#include "ash/session_state_delegate.h" -#include "ash/session_state_observer.h" +#include "ash/session/session_state_delegate.h" +#include "ash/session/session_state_observer.h" #include "ash/shell.h" #include "ash/shell_delegate.h" #include "ash/shell_window_ids.h" diff --git a/chrome/browser/ui/ash/system_tray_delegate_chromeos.h b/chrome/browser/ui/ash/system_tray_delegate_chromeos.h index 8a1fc30..378df87 100644 --- a/chrome/browser/ui/ash/system_tray_delegate_chromeos.h +++ b/chrome/browser/ui/ash/system_tray_delegate_chromeos.h @@ -7,7 +7,7 @@ #include "apps/app_window_registry.h" #include "ash/ime/input_method_menu_manager.h" -#include "ash/session_state_observer.h" +#include "ash/session/session_state_observer.h" #include "ash/system/tray/system_tray.h" #include "ash/system/tray/system_tray_delegate.h" #include "ash/system/tray/system_tray_notifier.h" diff --git a/chrome/browser/ui/browser_command_controller.cc b/chrome/browser/ui/browser_command_controller.cc index fc95256..14ee6d5 100644 --- a/chrome/browser/ui/browser_command_controller.cc +++ b/chrome/browser/ui/browser_command_controller.cc @@ -61,7 +61,7 @@ #if defined(OS_CHROMEOS) #include "ash/multi_profile_uma.h" -#include "ash/session_state_delegate.h" +#include "ash/session/session_state_delegate.h" #include "ash/shell.h" #include "chrome/browser/ui/ash/multi_user/multi_user_context_menu.h" #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h" diff --git a/chrome/browser/ui/views/ash/chrome_browser_main_extra_parts_ash.cc b/chrome/browser/ui/views/ash/chrome_browser_main_extra_parts_ash.cc index b1f8062..6b858b7 100644 --- a/chrome/browser/ui/views/ash/chrome_browser_main_extra_parts_ash.cc +++ b/chrome/browser/ui/views/ash/chrome_browser_main_extra_parts_ash.cc @@ -5,7 +5,7 @@ #include "chrome/browser/ui/views/ash/chrome_browser_main_extra_parts_ash.h" #include "ash/root_window_controller.h" -#include "ash/session_state_delegate.h" +#include "ash/session/session_state_delegate.h" #include "ash/shell.h" #include "base/command_line.h" #include "base/lazy_instance.h" diff --git a/chrome/browser/ui/views/frame/browser_frame.cc b/chrome/browser/ui/views/frame/browser_frame.cc index 585a12c..4b4606c 100644 --- a/chrome/browser/ui/views/frame/browser_frame.cc +++ b/chrome/browser/ui/views/frame/browser_frame.cc @@ -44,7 +44,7 @@ #endif #if defined(OS_CHROMEOS) -#include "ash/session_state_delegate.h" +#include "ash/session/session_state_delegate.h" #endif #if defined(USE_X11) diff --git a/chrome/browser/ui/views/frame/system_menu_model_builder.cc b/chrome/browser/ui/views/frame/system_menu_model_builder.cc index 69b63b8..44dacd8 100644 --- a/chrome/browser/ui/views/frame/system_menu_model_builder.cc +++ b/chrome/browser/ui/views/frame/system_menu_model_builder.cc @@ -16,7 +16,8 @@ #include "ui/base/models/simple_menu_model.h" #if defined(OS_CHROMEOS) -#include "ash/session_state_delegate.h" +#include "ash/session/session_state_delegate.h" +#include "ash/session/user_info.h" #include "ash/shell.h" #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h" @@ -151,13 +152,13 @@ void SystemMenuModelBuilder::AppendTeleportMenu(ui::SimpleMenuModel* model) { model->AddSeparator(ui::NORMAL_SEPARATOR); DCHECK(logged_in_users <= 3); for (int user_index = 1; user_index < logged_in_users; ++user_index) { + const ash::UserInfo* user_info = delegate->GetUserInfo(user_index); model->AddItem( - user_index == 1 ? IDC_VISIT_DESKTOP_OF_LRU_USER_2 : - IDC_VISIT_DESKTOP_OF_LRU_USER_3, - l10n_util::GetStringFUTF16( - IDS_VISIT_DESKTOP_OF_LRU_USER, - delegate->GetUserDisplayName(user_index), - base::ASCIIToUTF16(delegate->GetUserEmail(user_index)))); + user_index == 1 ? IDC_VISIT_DESKTOP_OF_LRU_USER_2 + : IDC_VISIT_DESKTOP_OF_LRU_USER_3, + l10n_util::GetStringFUTF16(IDS_VISIT_DESKTOP_OF_LRU_USER, + user_info->GetDisplayName(), + base::ASCIIToUTF16(user_info->GetEmail()))); } #endif } diff --git a/chrome/browser/ui/webui/options/chromeos/change_picture_options_handler.cc b/chrome/browser/ui/webui/options/chromeos/change_picture_options_handler.cc index 2c0732e..554839b 100644 --- a/chrome/browser/ui/webui/options/chromeos/change_picture_options_handler.cc +++ b/chrome/browser/ui/webui/options/chromeos/change_picture_options_handler.cc @@ -269,13 +269,13 @@ void ChangePictureOptionsHandler::SendSelectedImage() { switch (previous_image_index_) { case User::kExternalImageIndex: { // User has image from camera/file, record it and add to the image list. - previous_image_ = user->image(); + previous_image_ = user->GetImage(); SendOldImage(webui::GetBitmapDataUrl(*previous_image_.bitmap())); break; } case User::kProfileImageIndex: { // User has his/her Profile image as the current image. - SendProfileImage(user->image(), true); + SendProfileImage(user->GetImage(), true); break; } default: { diff --git a/chrome/browser/ui/webui/options/chromeos/core_chromeos_options_handler.cc b/chrome/browser/ui/webui/options/chromeos/core_chromeos_options_handler.cc index 4e3e98a..5771c5e 100644 --- a/chrome/browser/ui/webui/options/chromeos/core_chromeos_options_handler.cc +++ b/chrome/browser/ui/webui/options/chromeos/core_chromeos_options_handler.cc @@ -6,7 +6,7 @@ #include -#include "ash/session_state_delegate.h" +#include "ash/session/session_state_delegate.h" #include "ash/shell.h" #include "base/bind.h" #include "base/prefs/pref_change_registrar.h" -- cgit v1.1