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 <string> | 10 #include <string> |
11 | 11 |
12 #include "base/android/scoped_java_ref.h" | 12 #include "base/android/scoped_java_ref.h" |
13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
| 16 #include "chrome/browser/signin/google_auto_login_helper.h" |
16 | 17 |
| 18 class GoogleServiceAuthError; |
17 class Profile; | 19 class Profile; |
18 | 20 |
19 namespace policy { | 21 namespace policy { |
20 class CloudPolicyClient; | 22 class CloudPolicyClient; |
21 } | 23 } |
22 | 24 |
23 // Android wrapper of the SigninManager which provides access from the Java | 25 // Android wrapper of the SigninManager which provides access from the Java |
24 // layer. Note that on Android, there's only a single profile, and therefore | 26 // layer. Note that on Android, there's only a single profile, and therefore |
25 // a single instance of this wrapper. The name of the Java class is | 27 // a single instance of this wrapper. The name of the Java class is |
26 // SigninManager. | 28 // SigninManager. |
27 // This class should only be accessed from the UI thread. | 29 // This class should only be accessed from the UI thread. |
28 // | 30 // |
29 // This class implements parts of the sign-in flow, to make sure that policy | 31 // This class implements parts of the sign-in flow, to make sure that policy |
30 // is available before sign-in completes. | 32 // is available before sign-in completes. |
31 class SigninManagerAndroid { | 33 class SigninManagerAndroid : public GoogleAutoLoginHelper::Observer { |
32 public: | 34 public: |
33 SigninManagerAndroid(JNIEnv* env, jobject obj); | 35 SigninManagerAndroid(JNIEnv* env, jobject obj); |
34 | 36 |
35 // Registers the SigninManagerAndroid's native methods through JNI. | 37 // Registers the SigninManagerAndroid's native methods through JNI. |
36 static bool Register(JNIEnv* env); | 38 static bool Register(JNIEnv* env); |
37 | 39 |
38 void CheckPolicyBeforeSignIn(JNIEnv* env, jobject obj, jstring username); | 40 void CheckPolicyBeforeSignIn(JNIEnv* env, jobject obj, jstring username); |
39 | 41 |
40 void FetchPolicyBeforeSignIn(JNIEnv* env, jobject obj); | 42 void FetchPolicyBeforeSignIn(JNIEnv* env, jobject obj); |
41 | 43 |
(...skipping 12 matching lines...) Expand all Loading... |
54 virtual ~SigninManagerAndroid(); | 56 virtual ~SigninManagerAndroid(); |
55 | 57 |
56 #if defined(ENABLE_CONFIGURATION_POLICY) | 58 #if defined(ENABLE_CONFIGURATION_POLICY) |
57 void OnPolicyRegisterDone(const std::string& dm_token, | 59 void OnPolicyRegisterDone(const std::string& dm_token, |
58 const std::string& client_id); | 60 const std::string& client_id); |
59 void OnPolicyFetchDone(bool success); | 61 void OnPolicyFetchDone(bool success); |
60 #endif | 62 #endif |
61 | 63 |
62 void OnBrowsingDataRemoverDone(); | 64 void OnBrowsingDataRemoverDone(); |
63 | 65 |
| 66 // GoogleAutoLoginHelper::Observer implementation. |
| 67 virtual void MergeSessionCompleted( |
| 68 const std::string& account_id, |
| 69 const GoogleServiceAuthError& error) OVERRIDE; |
| 70 |
64 Profile* profile_; | 71 Profile* profile_; |
65 | 72 |
66 // Java-side SigninManager object. | 73 // Java-side SigninManager object. |
67 base::android::ScopedJavaGlobalRef<jobject> java_signin_manager_; | 74 base::android::ScopedJavaGlobalRef<jobject> java_signin_manager_; |
68 | 75 |
69 #if defined(ENABLE_CONFIGURATION_POLICY) | 76 #if defined(ENABLE_CONFIGURATION_POLICY) |
70 // CloudPolicy credentials stored during a pending sign-in, awaiting user | 77 // CloudPolicy credentials stored during a pending sign-in, awaiting user |
71 // confirmation before starting to fetch policies. | 78 // confirmation before starting to fetch policies. |
72 std::string dm_token_; | 79 std::string dm_token_; |
73 std::string client_id_; | 80 std::string client_id_; |
74 | 81 |
75 // Username that is pending sign-in. This is used to extract the domain name | 82 // Username that is pending sign-in. This is used to extract the domain name |
76 // for the policy dialog, when |username_| corresponds to a managed account. | 83 // for the policy dialog, when |username_| corresponds to a managed account. |
77 std::string username_; | 84 std::string username_; |
78 #endif | 85 #endif |
79 | 86 |
| 87 // Helper to merge the signed into account into the cookie jar session. |
| 88 scoped_ptr<GoogleAutoLoginHelper> merge_session_helper_; |
| 89 |
80 base::WeakPtrFactory<SigninManagerAndroid> weak_factory_; | 90 base::WeakPtrFactory<SigninManagerAndroid> weak_factory_; |
81 | 91 |
82 DISALLOW_COPY_AND_ASSIGN(SigninManagerAndroid); | 92 DISALLOW_COPY_AND_ASSIGN(SigninManagerAndroid); |
83 }; | 93 }; |
84 | 94 |
85 #endif // CHROME_BROWSER_ANDROID_SIGNIN_SIGNIN_MANAGER_ANDROID_H_ | 95 #endif // CHROME_BROWSER_ANDROID_SIGNIN_SIGNIN_MANAGER_ANDROID_H_ |
OLD | NEW |