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

Side by Side Diff: chrome/browser/ui/ash/user_accounts_delegate_chromeos.cc

Issue 256623002: Implemented inline login dialog for Chrome OS. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/ui/ash/user_accounts_delegate_chromeos.h"
6
7 #include <algorithm>
8 #include <iterator>
9
10 #include "base/logging.h"
11 #include "chrome/browser/chromeos/login/user_manager.h"
12 #include "chrome/browser/chromeos/ui/inline_login_dialog.h"
13 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
14 #include "chrome/browser/signin/signin_manager_factory.h"
15 #include "components/signin/core/browser/mutable_profile_oauth2_token_service.h"
16 #include "components/signin/core/browser/profile_oauth2_token_service.h"
17 #include "components/signin/core/browser/signin_manager.h"
18
19 namespace chromeos {
20
21 UserAccountsDelegateChromeOS::UserAccountsDelegateChromeOS(
22 Profile* user_profile)
23 : user_profile_(user_profile) {
24 ProfileOAuth2TokenServiceFactory::GetForProfile(user_profile_)
25 ->AddObserver(this);
26 }
27
28 UserAccountsDelegateChromeOS::~UserAccountsDelegateChromeOS() {
29 ProfileOAuth2TokenServiceFactory::GetForProfile(user_profile_)
30 ->RemoveObserver(this);
31 }
32
33 std::string UserAccountsDelegateChromeOS::GetPrimaryAccount() {
34 return SigninManagerFactory::GetForProfile(user_profile_)
35 ->GetAuthenticatedUsername();
xiyuan 2014/04/24 21:22:10 Should this be GetAuthenticatedAccountId? Right no
dzhioev (left Google) 2014/04/24 22:06:20 I'm little confused. Comment for GetAuthenticatedA
xiyuan 2014/04/24 22:31:51 The plan is to make GetAuthenticatedAccountId retu
36 }
37
38 std::vector<std::string>
39 UserAccountsDelegateChromeOS::GetSecondaryAccountsList() {
40 ProfileOAuth2TokenService* token_service =
41 ProfileOAuth2TokenServiceFactory::GetForProfile(user_profile_);
42 std::vector<std::string> accounts = token_service->GetAccounts();
43 // Filter primary account.
44 std::vector<std::string>::iterator it =
45 std::remove(accounts.begin(), accounts.end(), GetPrimaryAccount());
46 if (std::distance(it, accounts.end()) != 1)
xiyuan 2014/04/24 21:22:10 nit: LOG_IF since this "if" only do logging.
dzhioev (left Google) 2014/04/24 22:06:20 Done.
47 LOG(WARNING) << "Found " << std::distance(it, accounts.end())
48 << " primary "
49 "accounts in the account list.";
50 accounts.erase(it, accounts.end());
51 return accounts;
52 }
53
54 std::string UserAccountsDelegateChromeOS::GetAccountDisplayName(
55 const std::string& account_id) {
56 User* user = UserManager::Get()->GetUserByProfile(user_profile_);
57 if (user->email() == account_id && !user->display_email().empty())
58 return user->display_email();
59 return account_id;
60 }
61
62 void UserAccountsDelegateChromeOS::DeleteAccount(
63 const std::string& account_id) {
64 MutableProfileOAuth2TokenService* oauth2_token_service =
65 ProfileOAuth2TokenServiceFactory::GetPlatformSpecificForProfile(
66 user_profile_);
67 oauth2_token_service->RevokeCredentials(account_id);
68 }
69
70 void UserAccountsDelegateChromeOS::LaunchAddAccountDialog() {
71 ui::InlineLoginDialog::Show(user_profile_);
72 }
73
74 void UserAccountsDelegateChromeOS::OnRefreshTokenAvailable(
75 const std::string& account_id) {
76 NotifyAccountListChanged();
77 }
78
79 void UserAccountsDelegateChromeOS::OnRefreshTokenRevoked(
80 const std::string& account_id) {
81 NotifyAccountListChanged();
82 }
83
84 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698