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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/ash/user_accounts_delegate_chromeos.cc
diff --git a/chrome/browser/ui/ash/user_accounts_delegate_chromeos.cc b/chrome/browser/ui/ash/user_accounts_delegate_chromeos.cc
new file mode 100644
index 0000000000000000000000000000000000000000..7a21476fbec9d56d8a405b17a0e6897f24de3f51
--- /dev/null
+++ b/chrome/browser/ui/ash/user_accounts_delegate_chromeos.cc
@@ -0,0 +1,83 @@
+// 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.
+
+#include "chrome/browser/ui/ash/user_accounts_delegate_chromeos.h"
+
+#include <algorithm>
+#include <iterator>
+
+#include "base/logging.h"
+#include "chrome/browser/chromeos/login/user_manager.h"
+#include "chrome/browser/chromeos/ui/inline_login_dialog.h"
+#include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
+#include "chrome/browser/signin/signin_manager_factory.h"
+#include "components/signin/core/browser/mutable_profile_oauth2_token_service.h"
+#include "components/signin/core/browser/profile_oauth2_token_service.h"
+#include "components/signin/core/browser/signin_manager.h"
+
+namespace chromeos {
+
+UserAccountsDelegateChromeOS::UserAccountsDelegateChromeOS(
+ Profile* user_profile)
+ : user_profile_(user_profile) {
+ ProfileOAuth2TokenServiceFactory::GetForProfile(user_profile_)
+ ->AddObserver(this);
+}
+
+UserAccountsDelegateChromeOS::~UserAccountsDelegateChromeOS() {
+ ProfileOAuth2TokenServiceFactory::GetForProfile(user_profile_)
+ ->RemoveObserver(this);
+}
+
+std::string UserAccountsDelegateChromeOS::GetPrimaryAccount() {
+ return SigninManagerFactory::GetForProfile(user_profile_)
+ ->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
+}
+
+std::vector<std::string>
+UserAccountsDelegateChromeOS::GetSecondaryAccountsList() {
+ ProfileOAuth2TokenService* token_service =
+ ProfileOAuth2TokenServiceFactory::GetForProfile(user_profile_);
+ std::vector<std::string> accounts = token_service->GetAccounts();
+ // Filter primary account.
+ std::vector<std::string>::iterator it =
+ std::remove(accounts.begin(), accounts.end(), GetPrimaryAccount());
+ LOG_IF(WARNING, std::distance(it, accounts.end()) != 1)
+ << "Found " << std::distance(it, accounts.end())
+ << " primary accounts in the account list.";
+ accounts.erase(it, accounts.end());
+ return accounts;
+}
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.
+
+std::string UserAccountsDelegateChromeOS::GetAccountDisplayName(
+ const std::string& account_id) {
+ User* user = UserManager::Get()->GetUserByProfile(user_profile_);
+ 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.
+ return user->display_email();
+ return account_id;
+}
+
+void UserAccountsDelegateChromeOS::DeleteAccount(
+ const std::string& account_id) {
+ MutableProfileOAuth2TokenService* oauth2_token_service =
+ ProfileOAuth2TokenServiceFactory::GetPlatformSpecificForProfile(
+ user_profile_);
+ oauth2_token_service->RevokeCredentials(account_id);
+}
+
+void UserAccountsDelegateChromeOS::LaunchAddAccountDialog() {
+ ui::InlineLoginDialog::Show(user_profile_);
+}
+
+void UserAccountsDelegateChromeOS::OnRefreshTokenAvailable(
+ const std::string& account_id) {
+ NotifyAccountListChanged();
+}
+
+void UserAccountsDelegateChromeOS::OnRefreshTokenRevoked(
+ const std::string& account_id) {
+ NotifyAccountListChanged();
+}
+
+} // namespace chromeos

Powered by Google App Engine
This is Rietveld 408576698