diff options
author | alemate <alemate@chromium.org> | 2015-10-30 09:21:58 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-10-30 16:23:11 +0000 |
commit | cd06408625de9e0d5cf4c7c1ede412cb5c82542b (patch) | |
tree | 5f46a533381febd1b74d260624df0bcfa69e1d75 /ash | |
parent | 80004a8df9cf8b81f5b231696e3a24d190a8e05b (diff) | |
download | chromium_src-cd06408625de9e0d5cf4c7c1ede412cb5c82542b.zip chromium_src-cd06408625de9e0d5cf4c7c1ede412cb5c82542b.tar.gz chromium_src-cd06408625de9e0d5cf4c7c1ede412cb5c82542b.tar.bz2 |
This CL replaces user_manager::UserID with AccountId.
This CL replaces API of user_manager::UserManager, thus modifying API of all
child objects, and all calls to UserManager.
This is part of transition to AccountId.
BUG=468875
TEST=manual
Review URL: https://codereview.chromium.org/1412813003
Cr-Commit-Position: refs/heads/master@{#357119}
Diffstat (limited to 'ash')
-rw-r--r-- | ash/BUILD.gn | 1 | ||||
-rw-r--r-- | ash/DEPS | 1 | ||||
-rw-r--r-- | ash/ash.gyp | 2 | ||||
-rw-r--r-- | ash/system/DEPS | 1 | ||||
-rw-r--r-- | ash/system/user/tray_user.cc | 11 | ||||
-rw-r--r-- | ash/system/user/tray_user_unittest.cc | 6 | ||||
-rw-r--r-- | ash/system/user/user_view.cc | 4 | ||||
-rw-r--r-- | ash/test/test_session_state_delegate.cc | 27 |
8 files changed, 33 insertions, 20 deletions
diff --git a/ash/BUILD.gn b/ash/BUILD.gn index 6f5e693..8aaa1c0 100644 --- a/ash/BUILD.gn +++ b/ash/BUILD.gn @@ -27,6 +27,7 @@ component("ash") { "//base/third_party/dynamic_annotations", "//cc", "//components/device_event_log", + "//components/signin/core/account_id", "//components/user_manager", "//components/wallpaper", "//content/public/browser", @@ -2,6 +2,7 @@ include_rules = [ "+device/bluetooth", "+cc/debug", "+chromeos", + "+components/signin/core/account_id", "+components/user_manager", "+components/wallpaper", "+gpu/config", diff --git a/ash/ash.gyp b/ash/ash.gyp index 20960ee..a775584 100644 --- a/ash/ash.gyp +++ b/ash/ash.gyp @@ -949,6 +949,7 @@ '../base/third_party/dynamic_annotations/dynamic_annotations.gyp:dynamic_annotations', '../cc/cc.gyp:cc', '../components/components.gyp:device_event_log_component', + '../components/components.gyp:signin_core_account_id', '../components/components.gyp:user_manager', '../components/components.gyp:wallpaper', '../content/content.gyp:content_browser', @@ -1145,6 +1146,7 @@ '../base/base.gyp:base', '../base/base.gyp:test_support_base', '../chrome/chrome_resources.gyp:packed_resources', + '../components/components.gyp:signin_core_account_id', '../components/components.gyp:user_manager', '../content/content.gyp:content_browser', '../content/content_shell_and_tests.gyp:test_support_content', diff --git a/ash/system/DEPS b/ash/system/DEPS index abf5b5f..1121c69 100644 --- a/ash/system/DEPS +++ b/ash/system/DEPS @@ -1,3 +1,4 @@ include_rules = [ "-chromeos", + "+components/signin/core/account_id", ] diff --git a/ash/system/user/tray_user.cc b/ash/system/user/tray_user.cc index fd101e7..06d1823 100644 --- a/ash/system/user/tray_user.cc +++ b/ash/system/user/tray_user.cc @@ -20,6 +20,7 @@ #include "ash/system/user/user_view.h" #include "base/logging.h" #include "base/strings/string16.h" +#include "components/signin/core/account_id/account_id.h" #include "components/user_manager/user_info.h" #include "grit/ash_strings.h" #include "ui/aura/window.h" @@ -112,13 +113,13 @@ views::View* TrayUser::CreateDefaultView(user::LoginStatus status) { } views::View* TrayUser::CreateDetailedView(user::LoginStatus status) { - std::string user_id = Shell::GetInstance() - ->session_state_delegate() - ->GetUserInfo(0) - ->GetUserID(); + const AccountId account_id = Shell::GetInstance() + ->session_state_delegate() + ->GetUserInfo(0) + ->GetAccountId(); tray::UserAccountsDelegate* delegate = Shell::GetInstance()->system_tray_delegate()->GetUserAccountsDelegate( - user_id); + account_id.GetUserEmail()); if (!delegate) return nullptr; return new tray::AccountsDetailedView(this, status, delegate); diff --git a/ash/system/user/tray_user_unittest.cc b/ash/system/user/tray_user_unittest.cc index 5d9d3d3..ee1a92a 100644 --- a/ash/system/user/tray_user_unittest.cc +++ b/ash/system/user/tray_user_unittest.cc @@ -17,6 +17,7 @@ #include "ash/test/test_session_state_delegate.h" #include "ash/test/test_shell_delegate.h" #include "base/strings/utf_string_conversions.h" +#include "components/signin/core/account_id/account_id.h" #include "components/user_manager/user_info.h" #include "ui/accessibility/ax_view_state.h" #include "ui/events/test/event_generator.h" @@ -272,10 +273,11 @@ TEST_F(TrayUserTest, MutiUserModeButtonClicks) { ClickUserItem(&generator, 1); const user_manager::UserInfo* active_user = delegate()->GetActiveUserInfo(); const user_manager::UserInfo* second_user = delegate()->GetUserInfo(1); - EXPECT_EQ(active_user->GetUserID(), second_user->GetUserID()); + EXPECT_EQ(active_user->GetAccountId(), second_user->GetAccountId()); // Since the name is capitalized, the email should be different then the // user_id. - EXPECT_NE(active_user->GetUserID(), second_user->GetEmail()); + EXPECT_NE(active_user->GetAccountId().GetUserEmail(), + second_user->GetEmail()); tray()->CloseSystemBubble(); } diff --git a/ash/system/user/user_view.cc b/ash/system/user/user_view.cc index 7f7ece5..0c48ca9 100644 --- a/ash/system/user/user_view.cc +++ b/ash/system/user/user_view.cc @@ -19,6 +19,7 @@ #include "ash/system/user/config.h" #include "ash/system/user/rounded_image_view.h" #include "ash/system/user/user_card_view.h" +#include "components/signin/core/account_id/account_id.h" #include "components/user_manager/user_info.h" #include "grit/ash_resources.h" #include "grit/ash_strings.h" @@ -77,7 +78,8 @@ void SwitchUser(ash::UserIndex user_index) { ash::Shell::GetInstance()->session_state_delegate(); ash::MultiProfileUMA::RecordSwitchActiveUser( ash::MultiProfileUMA::SWITCH_ACTIVE_USER_BY_TRAY); - delegate->SwitchActiveUser(delegate->GetUserInfo(user_index)->GetUserID()); + delegate->SwitchActiveUser( + delegate->GetUserInfo(user_index)->GetAccountId().GetUserEmail()); } class LogoutButton : public TrayPopupLabelButton { diff --git a/ash/test/test_session_state_delegate.cc b/ash/test/test_session_state_delegate.cc index 7f2e648..bd0bdd3 100644 --- a/ash/test/test_session_state_delegate.cc +++ b/ash/test/test_session_state_delegate.cc @@ -12,6 +12,7 @@ #include "base/stl_util.h" #include "base/strings/string16.h" #include "base/strings/utf_string_conversions.h" +#include "components/signin/core/account_id/account_id.h" #include "components/user_manager/user_info.h" #include "testing/gtest/include/gtest/gtest.h" @@ -20,18 +21,20 @@ namespace test { namespace { -// The the "canonicalized" user ID from a given |email| address. -std::string GetUserIDFromEmail(const std::string& email) { +// The the "canonicalized" Account ID from a given |email| address. +AccountId GetAccountIdFromEmail(const std::string& email) { std::string user_id = email; std::transform(user_id.begin(), user_id.end(), user_id.begin(), ::tolower); - return user_id; + return AccountId::FromUserEmail(user_id); } } // namespace class MockUserInfo : public user_manager::UserInfo { public: - explicit MockUserInfo(const std::string& id) : email_(id) {} + explicit MockUserInfo(const std::string& display_email) + : display_email_(display_email), + account_id_(GetAccountIdFromEmail(display_email)) {} ~MockUserInfo() override {} void SetUserImage(const gfx::ImageSkia& user_image) { @@ -46,18 +49,17 @@ class MockUserInfo : public user_manager::UserInfo { return base::UTF8ToUTF16("Über Über Über Über"); } - std::string GetEmail() const override { return email_; } + std::string GetEmail() const override { return display_email_; } - std::string GetUserID() const override { - return GetUserIDFromEmail(GetEmail()); - } + AccountId GetAccountId() const override { return account_id_; } const gfx::ImageSkia& GetImage() const override { return user_image_; } // A test user image. gfx::ImageSkia user_image_; - std::string email_; + std::string display_email_; + const AccountId account_id_; DISALLOW_COPY_AND_ASSIGN(MockUserInfo); }; @@ -215,18 +217,19 @@ gfx::ImageSkia TestSessionStateDelegate::GetAvatarImageForWindow( } void TestSessionStateDelegate::SwitchActiveUser(const std::string& user_id) { + const AccountId account_id(GetAccountIdFromEmail(user_id)); // Make sure this is a user id and not an email address. - EXPECT_EQ(user_id, GetUserIDFromEmail(user_id)); + EXPECT_EQ(user_id, account_id.GetUserEmail()); active_user_index_ = 0; for (std::vector<MockUserInfo*>::iterator iter = user_list_.begin(); iter != user_list_.end(); ++iter) { - if ((*iter)->GetUserID() == user_id) { + if ((*iter)->GetAccountId() == account_id) { active_user_index_ = iter - user_list_.begin(); return; } } - NOTREACHED() << "Unknown user:" << user_id; + NOTREACHED() << "Unknown user:" << account_id.GetUserEmail(); } void TestSessionStateDelegate::CycleActiveUser(CycleUser cycle_user) { |