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