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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_ANDROID_SIGNIN_SIGNIN_MANAGER_ANDROID_H_
6 #define CHROME_BROWSER_ANDROID_SIGNIN_SIGNIN_MANAGER_ANDROID_H_
12 #include "base/android/scoped_java_ref.h"
13 #include "base/basictypes.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "base/memory/weak_ptr.h"
16 #include "base/prefs/pref_change_registrar.h"
21 class CloudPolicyClient
;
24 // 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
26 // a single instance of this wrapper. The name of the Java class is
28 // This class should only be accessed from the UI thread.
30 // This class implements parts of the sign-in flow, to make sure that policy
31 // is available before sign-in completes.
32 class SigninManagerAndroid
{
34 SigninManagerAndroid(JNIEnv
* env
, jobject obj
);
36 // Registers the SigninManagerAndroid's native methods through JNI.
37 static bool Register(JNIEnv
* env
);
39 void CheckPolicyBeforeSignIn(JNIEnv
* env
, jobject obj
, jstring username
);
41 void FetchPolicyBeforeSignIn(JNIEnv
* env
, jobject obj
);
43 // Indicates that the user has made the choice to sign-in. |username|
44 // contains the email address of the account to use as primary.
45 // |accountIds| and |accoundNames| are two arrays of equal length: one
46 // containing strings of stable account ids and the other containing
47 // strings of account names (or emails). An account id corresponds
48 // with the account name at the same position in the array.
49 void OnSignInCompleted(JNIEnv
* env
, jobject obj
, jstring username
,
50 jobjectArray accountIds
, jobjectArray accountNames
);
52 void SignOut(JNIEnv
* env
, jobject obj
);
54 base::android::ScopedJavaLocalRef
<jstring
> GetManagementDomain(JNIEnv
* env
,
57 void WipeProfileData(JNIEnv
* env
, jobject obj
);
59 void LogInSignedInUser(JNIEnv
* env
, jobject obj
);
61 void ClearLastSignedInUser(JNIEnv
* env
, jobject obj
);
63 jboolean
IsSigninAllowedByPolicy(JNIEnv
* env
, jobject obj
);
65 jboolean
IsSignedInOnNative(JNIEnv
* env
, jobject obj
);
68 ~SigninManagerAndroid();
70 #if defined(ENABLE_CONFIGURATION_POLICY)
71 void OnPolicyRegisterDone(const std::string
& dm_token
,
72 const std::string
& client_id
);
73 void OnPolicyFetchDone(bool success
);
76 void OnBrowsingDataRemoverDone();
78 void ClearLastSignedInUser();
80 void OnSigninAllowedPrefChanged();
84 // Java-side SigninManager object.
85 base::android::ScopedJavaGlobalRef
<jobject
> java_signin_manager_
;
87 #if defined(ENABLE_CONFIGURATION_POLICY)
88 // CloudPolicy credentials stored during a pending sign-in, awaiting user
89 // confirmation before starting to fetch policies.
90 std::string dm_token_
;
91 std::string client_id_
;
93 // Username that is pending sign-in. This is used to extract the domain name
94 // for the policy dialog, when |username_| corresponds to a managed account.
95 std::string username_
;
98 PrefChangeRegistrar pref_change_registrar_
;
100 base::WeakPtrFactory
<SigninManagerAndroid
> weak_factory_
;
102 DISALLOW_COPY_AND_ASSIGN(SigninManagerAndroid
);
105 #endif // CHROME_BROWSER_ANDROID_SIGNIN_SIGNIN_MANAGER_ANDROID_H_