Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / android / signin / signin_manager_android.h
blob49e1a03acc2cbffa9c265346da99c96230133d77
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 "chrome/browser/signin/google_auto_login_helper.h"
18 class GoogleServiceAuthError;
19 class Profile;
21 namespace policy {
22 class CloudPolicyClient;
25 // Android wrapper of the SigninManager which provides access from the Java
26 // layer. Note that on Android, there's only a single profile, and therefore
27 // a single instance of this wrapper. The name of the Java class is
28 // SigninManager.
29 // This class should only be accessed from the UI thread.
31 // This class implements parts of the sign-in flow, to make sure that policy
32 // is available before sign-in completes.
33 class SigninManagerAndroid : public GoogleAutoLoginHelper::Observer {
34 public:
35 SigninManagerAndroid(JNIEnv* env, jobject obj);
37 // Registers the SigninManagerAndroid's native methods through JNI.
38 static bool Register(JNIEnv* env);
40 void CheckPolicyBeforeSignIn(JNIEnv* env, jobject obj, jstring username);
42 void FetchPolicyBeforeSignIn(JNIEnv* env, jobject obj);
44 void OnSignInCompleted(JNIEnv* env, jobject obj, jstring username);
46 void SignOut(JNIEnv* env, jobject obj);
48 base::android::ScopedJavaLocalRef<jstring> GetManagementDomain(JNIEnv* env,
49 jobject obj);
51 void WipeProfileData(JNIEnv* env, jobject obj);
53 void LogInSignedInUser(JNIEnv* env, jobject obj);
55 private:
56 virtual ~SigninManagerAndroid();
58 #if defined(ENABLE_CONFIGURATION_POLICY)
59 void OnPolicyRegisterDone(const std::string& dm_token,
60 const std::string& client_id);
61 void OnPolicyFetchDone(bool success);
62 #endif
64 void OnBrowsingDataRemoverDone();
66 // GoogleAutoLoginHelper::Observer implementation.
67 virtual void MergeSessionCompleted(
68 const std::string& account_id,
69 const GoogleServiceAuthError& error) OVERRIDE;
71 Profile* profile_;
73 // Java-side SigninManager object.
74 base::android::ScopedJavaGlobalRef<jobject> java_signin_manager_;
76 #if defined(ENABLE_CONFIGURATION_POLICY)
77 // CloudPolicy credentials stored during a pending sign-in, awaiting user
78 // confirmation before starting to fetch policies.
79 std::string dm_token_;
80 std::string client_id_;
82 // Username that is pending sign-in. This is used to extract the domain name
83 // for the policy dialog, when |username_| corresponds to a managed account.
84 std::string username_;
85 #endif
87 // Helper to merge the signed into account into the cookie jar session.
88 scoped_ptr<GoogleAutoLoginHelper> merge_session_helper_;
90 base::WeakPtrFactory<SigninManagerAndroid> weak_factory_;
92 DISALLOW_COPY_AND_ASSIGN(SigninManagerAndroid);
95 #endif // CHROME_BROWSER_ANDROID_SIGNIN_SIGNIN_MANAGER_ANDROID_H_