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

Side by Side Diff: chrome/browser/android/signin/signin_manager_android.cc

Issue 1143323005: Refactor AO2TS to make it easier to componentize. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address final comments Created 5 years, 5 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <vector> 5 #include <vector>
6 6
7 #include "chrome/browser/android/signin/signin_manager_android.h" 7 #include "chrome/browser/android/signin/signin_manager_android.h"
8 8
9 #include "base/android/jni_android.h" 9 #include "base/android/jni_android.h"
10 #include "base/android/jni_array.h" 10 #include "base/android/jni_array.h"
11 #include "base/android/jni_string.h" 11 #include "base/android/jni_string.h"
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/bind_helpers.h" 13 #include "base/bind_helpers.h"
14 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
15 #include "base/prefs/pref_service.h" 15 #include "base/prefs/pref_service.h"
16 #include "base/single_thread_task_runner.h" 16 #include "base/single_thread_task_runner.h"
17 #include "base/thread_task_runner_handle.h" 17 #include "base/thread_task_runner_handle.h"
18 #include "base/thread_task_runner_handle.h" 18 #include "base/thread_task_runner_handle.h"
19 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 19 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
20 #include "chrome/browser/browser_process.h" 20 #include "chrome/browser/browser_process.h"
21 #include "chrome/browser/browsing_data/browsing_data_helper.h" 21 #include "chrome/browser/browsing_data/browsing_data_helper.h"
22 #include "chrome/browser/browsing_data/browsing_data_remover.h" 22 #include "chrome/browser/browsing_data/browsing_data_remover.h"
23 #include "chrome/browser/profiles/profile_manager.h" 23 #include "chrome/browser/profiles/profile_manager.h"
24 #include "chrome/browser/signin/account_tracker_service_factory.h" 24 #include "chrome/browser/signin/account_tracker_service_factory.h"
25 #include "chrome/browser/signin/android_profile_oauth2_token_service.h" 25 #include "chrome/browser/signin/oauth2_token_service_delegate_android.h"
26 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" 26 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
27 #include "chrome/browser/signin/signin_manager_factory.h" 27 #include "chrome/browser/signin/signin_manager_factory.h"
28 #include "chrome/common/pref_names.h" 28 #include "chrome/common/pref_names.h"
29 #include "components/bookmarks/browser/bookmark_model.h" 29 #include "components/bookmarks/browser/bookmark_model.h"
30 #include "components/signin/core/browser/account_tracker_service.h" 30 #include "components/signin/core/browser/account_tracker_service.h"
31 #include "components/signin/core/browser/profile_oauth2_token_service.h" 31 #include "components/signin/core/browser/profile_oauth2_token_service.h"
32 #include "components/signin/core/browser/signin_manager.h" 32 #include "components/signin/core/browser/signin_manager.h"
33 #include "components/signin/core/browser/signin_metrics.h" 33 #include "components/signin/core/browser/signin_metrics.h"
34 #include "components/signin/core/common/profile_management_switches.h" 34 #include "components/signin/core/common/profile_management_switches.h"
35 #include "google_apis/gaia/gaia_constants.h" 35 #include "google_apis/gaia/gaia_constants.h"
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 ClearLastSignedInUser(); 258 ClearLastSignedInUser();
259 } 259 }
260 260
261 void SigninManagerAndroid::ClearLastSignedInUser() { 261 void SigninManagerAndroid::ClearLastSignedInUser() {
262 profile_->GetPrefs()->ClearPref(prefs::kGoogleServicesLastUsername); 262 profile_->GetPrefs()->ClearPref(prefs::kGoogleServicesLastUsername);
263 } 263 }
264 264
265 void SigninManagerAndroid::LogInSignedInUser(JNIEnv* env, jobject obj) { 265 void SigninManagerAndroid::LogInSignedInUser(JNIEnv* env, jobject obj) {
266 SigninManagerBase* signin_manager = 266 SigninManagerBase* signin_manager =
267 SigninManagerFactory::GetForProfile(profile_); 267 SigninManagerFactory::GetForProfile(profile_);
268 // Just fire the events and let the Account Reconcilor handles everything. 268 // With the account consistency enabled let the account Reconcilor handles
269 AndroidProfileOAuth2TokenService* token_service = 269 // everything.
270 ProfileOAuth2TokenServiceFactory::GetPlatformSpecificForProfile( 270 ProfileOAuth2TokenService* token_service =
271 profile_); 271 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_);
272 const std::string& primary_acct = 272 const std::string& primary_acct = signin_manager->GetAuthenticatedAccountId();
273 signin_manager->GetAuthenticatedAccountId(); 273
274 token_service->ValidateAccounts(primary_acct, true); 274 static_cast<OAuth2TokenServiceDelegateAndroid*>(token_service->GetDelegate())
275 ->ValidateAccounts(primary_acct, true);
275 } 276 }
276 277
277 jboolean SigninManagerAndroid::IsSigninAllowedByPolicy(JNIEnv* env, 278 jboolean SigninManagerAndroid::IsSigninAllowedByPolicy(JNIEnv* env,
278 jobject obj) { 279 jobject obj) {
279 return SigninManagerFactory::GetForProfile(profile_)->IsSigninAllowed(); 280 return SigninManagerFactory::GetForProfile(profile_)->IsSigninAllowed();
280 } 281 }
281 282
282 jboolean SigninManagerAndroid::IsSignedInOnNative(JNIEnv* env, jobject obj) { 283 jboolean SigninManagerAndroid::IsSignedInOnNative(JNIEnv* env, jobject obj) {
283 return SigninManagerFactory::GetForProfile(profile_)->IsAuthenticated(); 284 return SigninManagerFactory::GetForProfile(profile_)->IsAuthenticated();
284 } 285 }
(...skipping 19 matching lines...) Expand all
304 return !policy::BrowserPolicyConnector::IsNonEnterpriseUser(username); 305 return !policy::BrowserPolicyConnector::IsNonEnterpriseUser(username);
305 #else 306 #else
306 return false; 307 return false;
307 #endif 308 #endif
308 } 309 }
309 310
310 // static 311 // static
311 bool SigninManagerAndroid::Register(JNIEnv* env) { 312 bool SigninManagerAndroid::Register(JNIEnv* env) {
312 return RegisterNativesImpl(env); 313 return RegisterNativesImpl(env);
313 } 314 }
OLDNEW
« no previous file with comments | « chrome/browser/android/chrome_jni_registrar.cc ('k') | chrome/browser/chromeos/policy/consumer_enrollment_handler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698