Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(338)

Side by Side Diff: chrome/browser/sync/profile_sync_service_android.h

Issue 12313075: [sync] Upstream the Android ProfileSyncService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed comments Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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.
4
5 #ifndef CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_ANDROID_H_
6 #define CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_ANDROID_H_
7
8 #include <jni.h>
9 #include <map>
10
11 #include "base/android/jni_helper.h"
12 #include "base/compiler_specific.h"
13 #include "chrome/browser/api/sync/profile_sync_service_observer.h"
14 #include "sync/internal_api/public/base/model_type.h"
15
16 class Profile;
17 class ProfileSyncService;
18
19 // Android wrapper of the ProfileSyncService which provides access from the Java
20 // layer. Note that on Android, there's only a single profile, and therefore
21 // a single instance of this wrapper. The name of the Java class is
22 // ProfileSyncService.
23 class ProfileSyncServiceAndroid : public ProfileSyncServiceObserver {
24 public:
25 ProfileSyncServiceAndroid(JNIEnv* env, jobject obj);
26 void Destroy(JNIEnv*env, jobject obj);
Yaron 2013/02/27 23:10:25 nit: insert space. also, this is uncalled and coul
nyquist 2013/02/28 22:38:50 Done.
27
28 void NudgeSyncer(JNIEnv* env,
29 jobject obj,
30 jstring objectId,
31 jlong version,
32 jstring payload);
33
34 void TokenAvailable(JNIEnv*, jobject, jstring username, jstring auth_token);
35
36 // Called from Java when the user manually enables sync
37 void EnableSync(JNIEnv* env, jobject obj);
38
39 // Called from Java when the user manually disables sync
40 void DisableSync(JNIEnv* env, jobject obj);
41
42 // Called from Java when the user signs in to Chrome. Starts up sync, and
43 // if auth credentials are required, uses the passed |auth_token|. If
44 // |auth_token| is empty, a new |auth_token| is requested from the UI thread
45 // via a call to InvalidateAuthToken().
46 void SignInSync(JNIEnv* env, jobject obj, jstring username,
47 jstring auth_token);
48
49 // Called from Java when the user signs out of Chrome
50 void SignOutSync(JNIEnv* env, jobject obj);
51
52 // Returns a string version of browser_sync::SyncBackendHost::StatusSummary
53 base::android::ScopedJavaLocalRef<jstring> QuerySyncStatusSummary(
54 JNIEnv* env, jobject obj);
55
56 // Called from Java early during startup to ensure we use the correct
57 // unique machine tag in session sync. Returns true if the machine tag was
58 // succesfully set.
59 // This must be called before the |SessionModelAssociator| is initialized.
60 jboolean SetSyncSessionsId(JNIEnv* env, jobject obj, jstring tag);
61
62 // Returns true if the sync backend is initialized.
63 jboolean IsSyncInitialized(JNIEnv* env, jobject obj);
64
65 // Returns true if the sync is currently being setup for the first time.
66 jboolean IsFirstSetupInProgress(JNIEnv* env, jobject obj);
67
68 // Returns true if the user is currently encrypting everything.
69 jboolean IsEncryptEverythingEnabled(JNIEnv* env, jobject obj);
70
71 // Returns true if the sync code needs a passphrase for either encryption or
72 // decryption (can need a passphrase for encryption if the user is turning on
73 // encryption and no passphrase has been set yet).
74 jboolean IsPassphraseRequired(JNIEnv* env, jobject obj);
75
76 // Returns true if the sync code needs a decryption passphrase for one of the
77 // currently enabled types.
78 jboolean IsPassphraseRequiredForDecryption(JNIEnv* env, jobject obj);
79
80 // Returns true if the sync code needs a decryption passphrase for *any* type,
81 // even types that aren't supported on this platform (like passwords).
82 jboolean IsPassphraseRequiredForExternalType(JNIEnv* env, jobject obj);
83
84 // Returns true if the sync code needs a custom decryption passphrase.
85 // Can not be called if the sync backend is not initialized.
86 jboolean IsUsingSecondaryPassphrase(JNIEnv* env, jobject obj);
87
88 // Returns true if the decryption passphrase works (was able to decrypt the
89 // stored sync data). Should only be called if
90 // IsPassphraseRequiredForDecryption() returns true.
91 jboolean SetDecryptionPassphrase(JNIEnv* env,
92 jobject obj,
93 jstring passphrase);
94
95 // Encrypts the user's data with the passed passphrase. If |is_gaia| == true
96 // then the passphrase is treated as a google (GAIA) passphrase, otherwise
97 // it's treated like an explicit/custom passphrase.
98 void SetEncryptionPassphrase(JNIEnv* env,
99 jobject obj,
100 jstring passphrase,
101 jboolean is_gaia);
102
103 // Returns whether the cryptographer is ready (i.e. encrypted types can be
104 // handled).
105 jboolean IsCryptographerReady(JNIEnv* env, jobject);
106
107 // Returns the actual passphrase type being used for encryption. This is a
108 // value from the enum defined in syncer::PassphraseType and must be matched
109 // in Java.
110 jint GetPassphraseType(JNIEnv* env, jobject obj);
111
112 // Returns true if the current explicit passphrase time is defined.
113 jboolean HasExplicitPassphraseTime(JNIEnv* env, jobject);
114
115 base::android::ScopedJavaLocalRef<jstring>
116 GetSyncEnterGooglePassphraseBodyWithDateText(
117 JNIEnv* env, jobject);
118
119 base::android::ScopedJavaLocalRef<jstring>
120 GetSyncEnterCustomPassphraseBodyWithDateText(
121 JNIEnv* env, jobject);
122
123 static base::android::ScopedJavaLocalRef<jstring>
124 GetSyncEnterCustomPassphraseBodyText(
125 JNIEnv* env, jclass);
126
127 // Returns true if sync has been migrated.
128 jboolean IsMigrated(JNIEnv* env, jobject obj);
129
130 // Enables the passed data types. If |sync_everything| is true, then all
131 // data types are enabled and the value of the other parameters is ignored.
132 void SetPreferredDataTypes(JNIEnv* env,
133 jobject obj,
134 jboolean sync_everything,
135 jboolean sync_autofill,
136 jboolean sync_bookmarks,
137 jboolean sync_passwords,
138 jboolean sync_sessions,
139 jboolean sync_typed_urls);
140
141 // Tells sync that we're currently configuring so no data types should be
142 // downloaded yet.
143 void SetSetupInProgress(JNIEnv* env, jobject obj, jboolean in_progress);
144
145 // Tells sync that sync setup is complete so we can start syncing now.
146 void SetSyncSetupCompleted(JNIEnv* env, jobject obj);
147
148 // Returns true if sync setup has been completed.
149 jboolean HasSyncSetupCompleted(JNIEnv* env, jobject obj);
150
151 // Returns true if sync is configured to "sync everything".
152 jboolean HasKeepEverythingSynced(JNIEnv* env, jobject obj);
153
154 // Returns true if the user has autofill sync enabled.
155 jboolean IsAutofillSyncEnabled(JNIEnv* env, jobject obj);
156
157 // Returns true if the user has bookmark sync enabled.
158 jboolean IsBookmarkSyncEnabled(JNIEnv* env, jobject obj);
159
160 // Returns true if the user has password sync enabled.
161 jboolean IsPasswordSyncEnabled(JNIEnv* env, jobject obj);
162
163 // Returns true if the user has typed URL sync enabled.
164 jboolean IsTypedUrlSyncEnabled(JNIEnv* env, jobject obj);
165
166 // Returns true if the user has session sync enabled.
167 jboolean IsSessionSyncEnabled(JNIEnv* env, jobject obj);
168
169 // Turns on encryption for all data types. This is an asynchronous operation
170 // which happens after the current configuration pass is done, so a call to
171 // this routine must be followed by a call to SetEnabledDataTypes().
172 void EnableEncryptEverything(JNIEnv* env, jobject obj);
173
174 // Returns true if sync has encountered an unrecoverable error.
175 jboolean HasUnrecoverableError(JNIEnv* env, jobject obj);
176
177 // Returns sync internals in a JSON-formatted Java string.
178 base::android::ScopedJavaLocalRef<jstring> GetAboutInfoForTest(JNIEnv* env,
179 jobject obj);
180
181 // Returns the integer value corresponding to the current auth error state
182 // (GoogleServiceAuthError.State).
183 jint GetAuthError(JNIEnv* env, jobject obj);
184
185 // ProfileSyncServiceObserver:
186 virtual void OnStateChanged() OVERRIDE;
187
188 // Registers the ProfileSyncServiceAndroid's native methods through JNI.
189 static bool Register(JNIEnv* env);
190
191 private:
192 virtual ~ProfileSyncServiceAndroid();
193 // Add and remove observers to profile sync service.
194 void AddObserver();
195 void RemoveObserver();
196 void InvalidateAuthToken();
197 void SendNudgeNotification(const std::string& str_object_id,
198 int64 version,
199 const std::string& payload);
200
201 Profile* profile_;
202 ProfileSyncService* sync_service_;
203 // Java-side ProfileSyncService object.
204 JavaObjectWeakGlobalRef weak_java_profile_sync_service_;
205
206 // The invalidation API spec allows for the possibility of redundant
207 // invalidations, so keep track of the max versions and drop
208 // invalidations with old versions.
209 std::map<syncer::ModelType, int64> max_invalidation_versions_;
210
211 DISALLOW_COPY_AND_ASSIGN(ProfileSyncServiceAndroid);
212 };
213
214 #endif // CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_ANDROID_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698