GoogleURLTrackerInfoBarDelegate: Initialize uninitialized member in constructor.
[chromium-blink-merge.git] / chrome / browser / android / signin / signin_manager_android.h
blob851681217daff607439f783b7d6a0586d6a7fc69
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 "google_apis/gaia/merge_session_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 MergeSessionHelper::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 void ClearLastSignedInUser(JNIEnv* env, jobject obj);
57 private:
58 virtual ~SigninManagerAndroid();
60 #if defined(ENABLE_CONFIGURATION_POLICY)
61 void OnPolicyRegisterDone(const std::string& dm_token,
62 const std::string& client_id);
63 void OnPolicyFetchDone(bool success);
64 #endif
66 void OnBrowsingDataRemoverDone();
68 void ClearLastSignedInUser();
70 // MergeSessionHelper::Observer implementation.
71 virtual void MergeSessionCompleted(
72 const std::string& account_id,
73 const GoogleServiceAuthError& error) OVERRIDE;
75 Profile* profile_;
77 // Java-side SigninManager object.
78 base::android::ScopedJavaGlobalRef<jobject> java_signin_manager_;
80 #if defined(ENABLE_CONFIGURATION_POLICY)
81 // CloudPolicy credentials stored during a pending sign-in, awaiting user
82 // confirmation before starting to fetch policies.
83 std::string dm_token_;
84 std::string client_id_;
86 // Username that is pending sign-in. This is used to extract the domain name
87 // for the policy dialog, when |username_| corresponds to a managed account.
88 std::string username_;
89 #endif
91 // Helper to merge the signed into account into the cookie jar session.
92 scoped_ptr<MergeSessionHelper> merge_session_helper_;
94 base::WeakPtrFactory<SigninManagerAndroid> weak_factory_;
96 DISALLOW_COPY_AND_ASSIGN(SigninManagerAndroid);
99 #endif // CHROME_BROWSER_ANDROID_SIGNIN_SIGNIN_MANAGER_ANDROID_H_