| OLD | NEW |
| 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 #ifndef CHROME_BROWSER_ANDROID_SIGNIN_SIGNIN_MANAGER_ANDROID_H_ | 5 #ifndef CHROME_BROWSER_ANDROID_SIGNIN_SIGNIN_MANAGER_ANDROID_H_ |
| 6 #define CHROME_BROWSER_ANDROID_SIGNIN_SIGNIN_MANAGER_ANDROID_H_ | 6 #define CHROME_BROWSER_ANDROID_SIGNIN_SIGNIN_MANAGER_ANDROID_H_ |
| 7 | 7 |
| 8 #include <jni.h> | 8 #include <jni.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| 11 #include <string> | 11 #include <string> |
| 12 | 12 |
| 13 #include "base/android/scoped_java_ref.h" | 13 #include "base/android/scoped_java_ref.h" |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
| 16 #include "base/threading/thread_checker.h" |
| 16 #include "components/prefs/pref_change_registrar.h" | 17 #include "components/prefs/pref_change_registrar.h" |
| 18 #include "components/signin/core/browser/signin_manager_base.h" |
| 17 | 19 |
| 18 class Profile; | 20 class Profile; |
| 19 | 21 |
| 20 namespace policy { | 22 namespace policy { |
| 21 class CloudPolicyClient; | 23 class CloudPolicyClient; |
| 22 } | 24 } |
| 23 | 25 |
| 24 // Android wrapper of the SigninManager which provides access from the Java | 26 // Android wrapper of the SigninManager which provides access from the Java |
| 25 // layer. Note that on Android, there's only a single profile, and therefore | 27 // layer. Note that on Android, there's only a single profile, and therefore |
| 26 // a single instance of this wrapper. The name of the Java class is | 28 // a single instance of this wrapper. The name of the Java class is |
| 27 // SigninManager. | 29 // SigninManager. |
| 28 // This class should only be accessed from the UI thread. | 30 // This class should only be accessed from the UI thread. |
| 29 // | 31 // |
| 30 // This class implements parts of the sign-in flow, to make sure that policy | 32 // This class implements parts of the sign-in flow, to make sure that policy |
| 31 // is available before sign-in completes. | 33 // is available before sign-in completes. |
| 32 class SigninManagerAndroid { | 34 class SigninManagerAndroid : public SigninManagerBase::Observer { |
| 33 public: | 35 public: |
| 34 SigninManagerAndroid(JNIEnv* env, jobject obj); | 36 SigninManagerAndroid(JNIEnv* env, jobject obj); |
| 35 | 37 |
| 36 // Registers the SigninManagerAndroid's native methods through JNI. | 38 // Registers the SigninManagerAndroid's native methods through JNI. |
| 37 static bool Register(JNIEnv* env); | 39 static bool Register(JNIEnv* env); |
| 38 | 40 |
| 39 void CheckPolicyBeforeSignIn( | 41 void CheckPolicyBeforeSignIn( |
| 40 JNIEnv* env, | 42 JNIEnv* env, |
| 41 const base::android::JavaParamRef<jobject>& obj, | 43 const base::android::JavaParamRef<jobject>& obj, |
| 42 const base::android::JavaParamRef<jstring>& username); | 44 const base::android::JavaParamRef<jstring>& username); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 69 void ClearLastSignedInUser(JNIEnv* env, | 71 void ClearLastSignedInUser(JNIEnv* env, |
| 70 const base::android::JavaParamRef<jobject>& obj); | 72 const base::android::JavaParamRef<jobject>& obj); |
| 71 | 73 |
| 72 jboolean IsSigninAllowedByPolicy( | 74 jboolean IsSigninAllowedByPolicy( |
| 73 JNIEnv* env, | 75 JNIEnv* env, |
| 74 const base::android::JavaParamRef<jobject>& obj); | 76 const base::android::JavaParamRef<jobject>& obj); |
| 75 | 77 |
| 76 jboolean IsSignedInOnNative(JNIEnv* env, | 78 jboolean IsSignedInOnNative(JNIEnv* env, |
| 77 const base::android::JavaParamRef<jobject>& obj); | 79 const base::android::JavaParamRef<jobject>& obj); |
| 78 | 80 |
| 81 // SigninManagerBase::Observer implementation. |
| 82 void GoogleSigninFailed(const GoogleServiceAuthError& error) override; |
| 83 void GoogleSigninSucceeded(const std::string& account_id, |
| 84 const std::string& username, |
| 85 const std::string& password) override; |
| 86 void GoogleSignedOut(const std::string& account_id, |
| 87 const std::string& username) override; |
| 88 |
| 79 private: | 89 private: |
| 80 ~SigninManagerAndroid(); | 90 ~SigninManagerAndroid() override; |
| 81 | 91 |
| 82 void OnPolicyRegisterDone(const std::string& dm_token, | 92 void OnPolicyRegisterDone(const std::string& dm_token, |
| 83 const std::string& client_id); | 93 const std::string& client_id); |
| 84 void OnPolicyFetchDone(bool success); | 94 void OnPolicyFetchDone(bool success); |
| 85 | 95 |
| 86 void OnBrowsingDataRemoverDone( | 96 void OnBrowsingDataRemoverDone( |
| 87 const base::android::ScopedJavaGlobalRef<jobject>& callback); | 97 const base::android::ScopedJavaGlobalRef<jobject>& callback); |
| 88 | 98 |
| 89 void ClearLastSignedInUser(); | 99 void ClearLastSignedInUser(); |
| 90 | 100 |
| 91 void OnSigninAllowedPrefChanged(); | 101 void OnSigninAllowedPrefChanged(); |
| 92 | 102 |
| 93 Profile* profile_; | 103 Profile* profile_; |
| 94 | 104 |
| 95 // Java-side SigninManager object. | 105 // Java-side SigninManager object. |
| 96 base::android::ScopedJavaGlobalRef<jobject> java_signin_manager_; | 106 base::android::ScopedJavaGlobalRef<jobject> java_signin_manager_; |
| 97 | 107 |
| 98 // CloudPolicy credentials stored during a pending sign-in, awaiting user | 108 // CloudPolicy credentials stored during a pending sign-in, awaiting user |
| 99 // confirmation before starting to fetch policies. | 109 // confirmation before starting to fetch policies. |
| 100 std::string dm_token_; | 110 std::string dm_token_; |
| 101 std::string client_id_; | 111 std::string client_id_; |
| 102 | 112 |
| 103 // Username that is pending sign-in. This is used to extract the domain name | 113 // Username that is pending sign-in. This is used to extract the domain name |
| 104 // for the policy dialog, when |username_| corresponds to a managed account. | 114 // for the policy dialog, when |username_| corresponds to a managed account. |
| 105 std::string username_; | 115 std::string username_; |
| 106 | 116 |
| 107 PrefChangeRegistrar pref_change_registrar_; | 117 PrefChangeRegistrar pref_change_registrar_; |
| 108 | 118 |
| 119 base::ThreadChecker thread_checker_; |
| 120 |
| 109 base::WeakPtrFactory<SigninManagerAndroid> weak_factory_; | 121 base::WeakPtrFactory<SigninManagerAndroid> weak_factory_; |
| 110 | 122 |
| 111 DISALLOW_COPY_AND_ASSIGN(SigninManagerAndroid); | 123 DISALLOW_COPY_AND_ASSIGN(SigninManagerAndroid); |
| 112 }; | 124 }; |
| 113 | 125 |
| 114 #endif // CHROME_BROWSER_ANDROID_SIGNIN_SIGNIN_MANAGER_ANDROID_H_ | 126 #endif // CHROME_BROWSER_ANDROID_SIGNIN_SIGNIN_MANAGER_ANDROID_H_ |
| OLD | NEW |