ozone: evdev: Sync caps lock LED state to evdev
[chromium-blink-merge.git] / chrome / browser / android / signin / signin_manager_android.h
blob23424f8aa564d34c54ab42eac63a398210159423
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_
8 #include <jni.h>
10 #include <string>
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"
17 #include "google_apis/gaia/merge_session_helper.h"
19 class GoogleServiceAuthError;
20 class Profile;
22 namespace policy {
23 class CloudPolicyClient;
26 // 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
28 // a single instance of this wrapper. The name of the Java class is
29 // SigninManager.
30 // This class should only be accessed from the UI thread.
32 // This class implements parts of the sign-in flow, to make sure that policy
33 // is available before sign-in completes.
34 class SigninManagerAndroid : public MergeSessionHelper::Observer {
35 public:
36 SigninManagerAndroid(JNIEnv* env, jobject obj);
38 // Registers the SigninManagerAndroid's native methods through JNI.
39 static bool Register(JNIEnv* env);
41 void CheckPolicyBeforeSignIn(JNIEnv* env, jobject obj, jstring username);
43 void FetchPolicyBeforeSignIn(JNIEnv* env, jobject obj);
45 // Indicates that the user has made the choice to sign-in. |username|
46 // contains the email address of the account to use as primary.
47 // |accountIds| and |accoundNames| are two arrays of equal length: one
48 // containing strings of stable account ids and the other containing
49 // strings of account names (or emails). An account id corresponds
50 // with the account name at the same position in the array.
51 void OnSignInCompleted(JNIEnv* env, jobject obj, jstring username,
52 jobjectArray accountIds, jobjectArray accountNames);
54 void SignOut(JNIEnv* env, jobject obj);
56 base::android::ScopedJavaLocalRef<jstring> GetManagementDomain(JNIEnv* env,
57 jobject obj);
59 void WipeProfileData(JNIEnv* env, jobject obj);
61 void LogInSignedInUser(JNIEnv* env, jobject obj);
63 void ClearLastSignedInUser(JNIEnv* env, jobject obj);
65 jboolean IsSigninAllowedByPolicy(JNIEnv* env, jobject obj);
67 jboolean IsSignedInOnNative(JNIEnv* env, jobject obj);
69 private:
70 ~SigninManagerAndroid() override;
72 #if defined(ENABLE_CONFIGURATION_POLICY)
73 void OnPolicyRegisterDone(const std::string& dm_token,
74 const std::string& client_id);
75 void OnPolicyFetchDone(bool success);
76 #endif
78 void OnBrowsingDataRemoverDone();
80 void ClearLastSignedInUser();
82 void OnSigninAllowedPrefChanged();
84 // MergeSessionHelper::Observer implementation.
85 void MergeSessionCompleted(
86 const std::string& account_id,
87 const GoogleServiceAuthError& error) override;
89 Profile* profile_;
91 // Java-side SigninManager object.
92 base::android::ScopedJavaGlobalRef<jobject> java_signin_manager_;
94 #if defined(ENABLE_CONFIGURATION_POLICY)
95 // CloudPolicy credentials stored during a pending sign-in, awaiting user
96 // confirmation before starting to fetch policies.
97 std::string dm_token_;
98 std::string client_id_;
100 // Username that is pending sign-in. This is used to extract the domain name
101 // for the policy dialog, when |username_| corresponds to a managed account.
102 std::string username_;
103 #endif
105 // Helper to merge the signed into account into the cookie jar session.
106 scoped_ptr<MergeSessionHelper> merge_session_helper_;
108 PrefChangeRegistrar pref_change_registrar_;
110 base::WeakPtrFactory<SigninManagerAndroid> weak_factory_;
112 DISALLOW_COPY_AND_ASSIGN(SigninManagerAndroid);
115 #endif // CHROME_BROWSER_ANDROID_SIGNIN_SIGNIN_MANAGER_ANDROID_H_