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

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: Comments addressed. 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();
Roger Tawa OOO till Jul 10th 2014/04/28 19:06:22 What is the intent of the return value? Will the
dzhioev (left Google) 2014/04/28 19:49:17 It is used as ID and isn't displayed to user. The
Roger Tawa OOO till Jul 10th 2014/04/29 00:03:25 Today username == account_id, so the code will wor
dzhioev (left Google) 2014/04/29 12:23:58 Done, used GetAuthenticatedAccountId here and rena
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 LOG_IF(WARNING, std::distance(it, accounts.end()) != 1)
47 << "Found " << std::distance(it, accounts.end())
48 << " primary accounts in the account list.";
49 accounts.erase(it, accounts.end());
50 return accounts;
51 }
Roger Tawa OOO till Jul 10th 2014/04/28 19:06:22 Same question as above. Also I'd suggest changing
dzhioev (left Google) 2014/04/29 12:23:58 Done.
52
53 std::string UserAccountsDelegateChromeOS::GetAccountDisplayName(
54 const std::string& account_id) {
55 User* user = UserManager::Get()->GetUserByProfile(user_profile_);
56 if (user->email() == account_id && !user->display_email().empty())
Roger Tawa OOO till Jul 10th 2014/04/29 00:03:25 Instead of using std::string::op==(), please use g
dzhioev (left Google) 2014/04/29 12:23:58 Done.
57 return user->display_email();
58 return account_id;
59 }
60
61 void UserAccountsDelegateChromeOS::DeleteAccount(
62 const std::string& account_id) {
63 MutableProfileOAuth2TokenService* oauth2_token_service =
64 ProfileOAuth2TokenServiceFactory::GetPlatformSpecificForProfile(
65 user_profile_);
66 oauth2_token_service->RevokeCredentials(account_id);
67 }
68
69 void UserAccountsDelegateChromeOS::LaunchAddAccountDialog() {
70 ui::InlineLoginDialog::Show(user_profile_);
71 }
72
73 void UserAccountsDelegateChromeOS::OnRefreshTokenAvailable(
74 const std::string& account_id) {
75 NotifyAccountListChanged();
76 }
77
78 void UserAccountsDelegateChromeOS::OnRefreshTokenRevoked(
79 const std::string& account_id) {
80 NotifyAccountListChanged();
81 }
82
83 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698