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"
20 class CloudPolicyClient;
23 // 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
25 // a single instance of this wrapper. The name of the Java class is
27 // This class should only be accessed from the UI thread.
29 // This class implements parts of the sign-in flow, to make sure that policy
30 // is available before sign-in completes.
31 class SigninManagerAndroid {
33 SigninManagerAndroid(JNIEnv* env, jobject obj);
35 // Registers the SigninManagerAndroid's native methods through JNI.
36 static bool Register(JNIEnv* env);
38 void CheckPolicyBeforeSignIn(JNIEnv* env, jobject obj, jstring username);
40 void FetchPolicyBeforeSignIn(JNIEnv* env, jobject obj);
42 void OnSignInCompleted(JNIEnv* env, jobject obj, jstring username);
44 void SignOut(JNIEnv* env, jobject obj);
46 base::android::ScopedJavaLocalRef<jstring> GetManagementDomain(JNIEnv* env,
49 void WipeProfileData(JNIEnv* env, jobject obj);
51 void LogInSignedInUser(JNIEnv* env, jobject obj);
54 virtual ~SigninManagerAndroid();
56 #if defined(ENABLE_CONFIGURATION_POLICY)
57 void OnPolicyRegisterDone(scoped_ptr<policy::CloudPolicyClient> client);
58 void OnPolicyFetchDone(bool success);
61 void OnBrowsingDataRemoverDone();
65 // Java-side SigninManager object.
66 base::android::ScopedJavaGlobalRef<jobject> java_signin_manager_;
68 #if defined(ENABLE_CONFIGURATION_POLICY)
69 // CloudPolicyClient stored during a pending sign-in, awaiting user
70 // confirmation before starting to fetch policies.
71 scoped_ptr<policy::CloudPolicyClient> cloud_policy_client_;
73 // Username that is pending sign-in. This is used to extract the domain name
74 // for the policy dialog, when |username_| corresponds to a managed account.
75 std::string username_;
78 base::WeakPtrFactory<SigninManagerAndroid> weak_factory_;
80 DISALLOW_COPY_AND_ASSIGN(SigninManagerAndroid);
83 #endif // CHROME_BROWSER_ANDROID_SIGNIN_SIGNIN_MANAGER_ANDROID_H_