summaryrefslogtreecommitdiffstats
path: root/ash
diff options
context:
space:
mode:
authoroshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-30 10:33:51 +0000
committeroshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-30 10:33:51 +0000
commit5a40d60411da361e5ac216efa90a80a29ebe8b57 (patch)
tree4abb6c2b7957a65becce19018af7b66ee555da06 /ash
parentb8e9c841de80d18f9debade1fdbfafcccbfa3a5e (diff)
downloadchromium_src-5a40d60411da361e5ac216efa90a80a29ebe8b57.zip
chromium_src-5a40d60411da361e5ac216efa90a80a29ebe8b57.tar.gz
chromium_src-5a40d60411da361e5ac216efa90a80a29ebe8b57.tar.bz2
CleanUp: Introduce UserInfo. Move session_state stuff to ash/session.
BUG=None R=nkostylev@chromium.org TBR=sky@chromium.org Review URL: https://codereview.chromium.org/253063002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@267158 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r--ash/accelerators/accelerator_controller.cc4
-rw-r--r--ash/accelerators/nested_dispatcher_controller_unittest.cc2
-rw-r--r--ash/ash.gyp15
-rw-r--r--ash/desktop_background/desktop_background_view.cc2
-rw-r--r--ash/frame/custom_frame_view_ash.cc2
-rw-r--r--ash/frame/frame_util.cc9
-rw-r--r--ash/root_window_controller.cc2
-rw-r--r--ash/root_window_controller_unittest.cc2
-rw-r--r--ash/session/session_state_delegate.h (renamed from ash/session_state_delegate.h)33
-rw-r--r--ash/session/session_state_delegate_stub.cc (renamed from ash/session_state_delegate_stub.cc)75
-rw-r--r--ash/session/session_state_delegate_stub.h (renamed from ash/session_state_delegate_stub.h)27
-rw-r--r--ash/session/session_state_observer.cc25
-rw-r--r--ash/session/session_state_observer.h (renamed from ash/session_state_observer.h)8
-rw-r--r--ash/session/user_info.h45
-rw-r--r--ash/session_state_observer.cc24
-rw-r--r--ash/shelf/shelf_layout_manager.cc2
-rw-r--r--ash/shelf/shelf_layout_manager.h2
-rw-r--r--ash/shelf/shelf_layout_manager_unittest.cc2
-rw-r--r--ash/shelf/shelf_widget.cc2
-rw-r--r--ash/shell.cc2
-rw-r--r--ash/shell/app_list.cc2
-rw-r--r--ash/shell/lock_view.cc2
-rw-r--r--ash/shell/shell_delegate_impl.cc4
-rw-r--r--ash/shell/window_type_launcher.cc2
-rw-r--r--ash/shell_unittest.cc2
-rw-r--r--ash/system/chromeos/network/network_connect.cc2
-rw-r--r--ash/system/chromeos/power/power_event_observer.cc2
-rw-r--r--ash/system/chromeos/session/logout_confirmation_controller.cc2
-rw-r--r--ash/system/date/date_default_view.cc2
-rw-r--r--ash/system/tray/default_system_tray_delegate.cc2
-rw-r--r--ash/system/user/accounts_detailed_view.cc14
-rw-r--r--ash/system/user/config.cc2
-rw-r--r--ash/system/user/login_status.cc2
-rw-r--r--ash/system/user/tray_user.cc5
-rw-r--r--ash/system/user/tray_user.h2
-rw-r--r--ash/system/user/tray_user_separator.cc2
-rw-r--r--ash/system/user/tray_user_unittest.cc7
-rw-r--r--ash/system/user/user_card_view.cc20
-rw-r--r--ash/system/user/user_view.cc5
-rw-r--r--ash/system/user/user_view.h2
-rw-r--r--ash/test/test_session_state_delegate.cc107
-rw-r--r--ash/test/test_session_state_delegate.h28
-rw-r--r--ash/test/test_shell_delegate.cc2
-rw-r--r--ash/test/test_system_tray_delegate.cc2
-rw-r--r--ash/wm/event_client_impl.cc2
-rw-r--r--ash/wm/gestures/shelf_gesture_handler.cc2
-rw-r--r--ash/wm/lock_state_controller_unittest.cc2
-rw-r--r--ash/wm/mru_window_tracker.cc2
-rw-r--r--ash/wm/overview/window_selector_controller.cc2
-rw-r--r--ash/wm/power_button_controller.cc2
-rw-r--r--ash/wm/stacking_controller.cc2
-rw-r--r--ash/wm/system_modal_container_layout_manager.cc2
-rw-r--r--ash/wm/system_modal_container_layout_manager_unittest.cc2
-rw-r--r--ash/wm/workspace/workspace_layout_manager.cc2
-rw-r--r--ash/wm/workspace/workspace_layout_manager_unittest.cc2
55 files changed, 313 insertions, 216 deletions
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 99c340d..803e078 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_state_delegate.h b/ash/session/session_state_delegate.h
index dcbd7f9..78777a0 100644
--- a/ash/session_state_delegate.h
+++ b/ash/session/session_state_delegate.h
@@ -2,8 +2,8 @@
// 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_
+#ifndef ASH_SESSION_SESSION_STATE_DELEGATE_H_
+#define ASH_SESSION_SESSION_STATE_DELEGATE_H_
#include <string>
#include <vector>
@@ -26,6 +26,7 @@ class ImageSkia;
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.
@@ -108,34 +109,18 @@ class ASH_EXPORT SessionStateDelegate {
// 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;
+ // TODO(oshima): consolidate these two GetUserInfo.
- // Gets the user id (sanitized email address) for the user with the given
- // |index|. The function would return something like "foobar@mock.com".
+ // Gets the user info for the user with the given |index|.
// Note that |index| can at maximum be |NumberOfLoggedInUsers() - 1|.
- virtual const std::string GetUserID(MultiProfileIndex index) const = 0;
+ virtual const UserInfo* GetUserInfo(MultiProfileIndex index) const = 0;
// Gets the avatar image for the user associated with the |context|.
- virtual const gfx::ImageSkia& GetUserImage(
+ 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) = 0;
+ virtual bool ShouldShowAvatar(aura::Window* window) const = 0;
// Switches to another active user with |user_id|
// (if that user has already signed in).
@@ -152,4 +137,4 @@ class ASH_EXPORT SessionStateDelegate {
} // namespace ash
-#endif // ASH_SESSION_STATE_DELEGATE_H_
+#endif // ASH_SESSION_SESSION_STATE_DELEGATE_H_
diff --git a/ash/session_state_delegate_stub.cc b/ash/session/session_state_delegate_stub.cc
index ba1058b..05bca13 100644
--- a/ash/session_state_delegate_stub.cc
+++ b/ash/session/session_state_delegate_stub.cc
@@ -2,30 +2,60 @@
// 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/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 {
-SessionStateDelegateStub::SessionStateDelegateStub() : screen_locked_(false) {
+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(
+content::BrowserContext* SessionStateDelegateStub::GetBrowserContextByIndex(
MultiProfileIndex index) {
return Shell::GetInstance()->delegate()->GetActiveBrowserContext();
}
-content::BrowserContext*
-SessionStateDelegateStub::GetBrowserContextForWindow(
+content::BrowserContext* SessionStateDelegateStub::GetBrowserContextForWindow(
aura::Window* window) {
return Shell::GetInstance()->delegate()->GetActiveBrowserContext();
}
@@ -65,44 +95,29 @@ void SessionStateDelegateStub::UnlockScreen() {
Shell::GetInstance()->UpdateShelfVisibility();
}
-bool SessionStateDelegateStub::IsUserSessionBlocked() const {
+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";
+ return IsActiveUserSessionStarted() ? SESSION_STATE_ACTIVE
+ : SESSION_STATE_LOGIN_PRIMARY;
}
-const std::string SessionStateDelegateStub::GetUserID(
+const UserInfo* SessionStateDelegateStub::GetUserInfo(
MultiProfileIndex index) const {
- return GetUserEmail(index);
+ return user_info_.get();
}
-const gfx::ImageSkia& SessionStateDelegateStub::GetUserImage(
+const UserInfo* SessionStateDelegateStub::GetUserInfo(
content::BrowserContext* context) const {
- return user_image_;
+ return user_info_.get();
}
-bool SessionStateDelegateStub::ShouldShowAvatar(aura::Window* window) {
- return !user_image_.isNull();
+bool SessionStateDelegateStub::ShouldShowAvatar(aura::Window* window) const {
+ return !user_info_->GetImage().isNull();
}
void SessionStateDelegateStub::SwitchActiveUser(const std::string& user_id) {
diff --git a/ash/session_state_delegate_stub.h b/ash/session/session_state_delegate_stub.h
index 5145fb8..5ce9cf3 100644
--- a/ash/session_state_delegate_stub.h
+++ b/ash/session/session_state_delegate_stub.h
@@ -2,13 +2,13 @@
// 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_
+#ifndef ASH_SESSION_SESSION_STATE_DELEGATE_STUB_H_
+#define ASH_SESSION_SESSION_STATE_DELEGATE_STUB_H_
-#include "ash/session_state_delegate.h"
+#include "ash/session/session_state_delegate.h"
#include "base/basictypes.h"
#include "base/compiler_specific.h"
-#include "ui/gfx/image/image_skia.h"
+#include "base/memory/scoped_ptr.h"
namespace ash {
@@ -33,17 +33,10 @@ class SessionStateDelegateStub : 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(
- ash::MultiProfileIndex index) const OVERRIDE;
- virtual const gfx::ImageSkia& GetUserImage(
+ virtual const UserInfo* GetUserInfo(MultiProfileIndex index) const OVERRIDE;
+ 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(
@@ -54,12 +47,12 @@ class SessionStateDelegateStub : public SessionStateDelegate {
private:
bool screen_locked_;
- // A pseudo user image.
- gfx::ImageSkia user_image_;
+ // A pseudo user info.
+ scoped_ptr<UserInfo> user_info_;
DISALLOW_COPY_AND_ASSIGN(SessionStateDelegateStub);
};
} // namespace ash
-#endif // ASH_SESSION_STATE_DELEGATE_STUB_H_
+#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_state_observer.h b/ash/session/session_state_observer.h
index 59d6f67..36fad83 100644
--- a/ash/session_state_observer.h
+++ b/ash/session/session_state_observer.h
@@ -2,13 +2,13 @@
// 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_
+#ifndef ASH_SESSION_SESSION_STATE_OBSERVER_H_
+#define ASH_SESSION_SESSION_STATE_OBSERVER_H_
#include <string>
#include "ash/ash_export.h"
-#include "ash/session_state_delegate.h"
+#include "ash/session/session_state_delegate.h"
#include "base/basictypes.h"
namespace ash {
@@ -43,4 +43,4 @@ class ASH_EXPORT ScopedSessionStateObserver {
} // namespace ash
-#endif // ASH_SESSION_STATE_OBSERVER_H_
+#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 <string>
+
+#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_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/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 <vector>
#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 <string>
-#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 <string>
-#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 <vector>
#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 <algorithm>
#include <vector>
-#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 <algorithm>
#include <string>
+#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<int>(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<MockUserInfo*>::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 <vector>
+
+#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<MockUserInfo*> 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 <string>
-#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 <algorithm>
-#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"