| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_ANDROID_FOREIGN_SESSION_HELPER_H_ | 5 #ifndef CHROME_BROWSER_ANDROID_FOREIGN_SESSION_HELPER_H_ |
| 6 #define CHROME_BROWSER_ANDROID_FOREIGN_SESSION_HELPER_H_ | 6 #define CHROME_BROWSER_ANDROID_FOREIGN_SESSION_HELPER_H_ |
| 7 | 7 |
| 8 #include <jni.h> | 8 #include <jni.h> |
| 9 | 9 |
| 10 #include "base/android/scoped_java_ref.h" | 10 #include "base/android/scoped_java_ref.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/scoped_observer.h" | 12 #include "base/scoped_observer.h" |
| 13 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
| 14 #include "components/sync/driver/sync_service_observer.h" | 14 #include "components/sync/driver/sync_service_observer.h" |
| 15 | 15 |
| 16 using base::android::ScopedJavaLocalRef; | 16 using base::android::ScopedJavaLocalRef; |
| 17 | 17 |
| 18 struct SessionWindow; | 18 struct SessionWindow; |
| 19 | 19 |
| 20 namespace browser_sync { | 20 namespace browser_sync { |
| 21 struct SyncedSession; | 21 struct SyncedSession; |
| 22 } // namespace browser_sync | 22 } // namespace browser_sync |
| 23 | 23 |
| 24 namespace syncer { | 24 namespace sync_driver { |
| 25 class SyncService; | 25 class SyncService; |
| 26 } // namespace syncer | 26 } // namespace sync_driver |
| 27 | 27 |
| 28 class ForeignSessionHelper : public syncer::SyncServiceObserver { | 28 class ForeignSessionHelper : public sync_driver::SyncServiceObserver { |
| 29 public: | 29 public: |
| 30 explicit ForeignSessionHelper(Profile* profile); | 30 explicit ForeignSessionHelper(Profile* profile); |
| 31 void Destroy(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj); | 31 void Destroy(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj); |
| 32 jboolean IsTabSyncEnabled(JNIEnv* env, | 32 jboolean IsTabSyncEnabled(JNIEnv* env, |
| 33 const base::android::JavaParamRef<jobject>& obj); | 33 const base::android::JavaParamRef<jobject>& obj); |
| 34 void TriggerSessionSync(JNIEnv* env, | 34 void TriggerSessionSync(JNIEnv* env, |
| 35 const base::android::JavaParamRef<jobject>& obj); | 35 const base::android::JavaParamRef<jobject>& obj); |
| 36 void SetOnForeignSessionCallback( | 36 void SetOnForeignSessionCallback( |
| 37 JNIEnv* env, | 37 JNIEnv* env, |
| 38 const base::android::JavaParamRef<jobject>& obj, | 38 const base::android::JavaParamRef<jobject>& obj, |
| 39 const base::android::JavaParamRef<jobject>& callback); | 39 const base::android::JavaParamRef<jobject>& callback); |
| 40 jboolean GetForeignSessions( | 40 jboolean GetForeignSessions( |
| 41 JNIEnv* env, | 41 JNIEnv* env, |
| 42 const base::android::JavaParamRef<jobject>& obj, | 42 const base::android::JavaParamRef<jobject>& obj, |
| 43 const base::android::JavaParamRef<jobject>& result); | 43 const base::android::JavaParamRef<jobject>& result); |
| 44 jboolean OpenForeignSessionTab( | 44 jboolean OpenForeignSessionTab( |
| 45 JNIEnv* env, | 45 JNIEnv* env, |
| 46 const base::android::JavaParamRef<jobject>& obj, | 46 const base::android::JavaParamRef<jobject>& obj, |
| 47 const base::android::JavaParamRef<jobject>& j_tab, | 47 const base::android::JavaParamRef<jobject>& j_tab, |
| 48 const base::android::JavaParamRef<jstring>& session_tag, | 48 const base::android::JavaParamRef<jstring>& session_tag, |
| 49 jint tab_id, | 49 jint tab_id, |
| 50 jint disposition); | 50 jint disposition); |
| 51 void DeleteForeignSession( | 51 void DeleteForeignSession( |
| 52 JNIEnv* env, | 52 JNIEnv* env, |
| 53 const base::android::JavaParamRef<jobject>& obj, | 53 const base::android::JavaParamRef<jobject>& obj, |
| 54 const base::android::JavaParamRef<jstring>& session_tag); | 54 const base::android::JavaParamRef<jstring>& session_tag); |
| 55 | 55 |
| 56 // syncer::SyncServiceObserver implementation | 56 // sync_driver::SyncServiceObserver implementation |
| 57 void OnStateChanged() override {} | 57 void OnStateChanged() override {} |
| 58 void OnSyncConfigurationCompleted() override; | 58 void OnSyncConfigurationCompleted() override; |
| 59 void OnForeignSessionUpdated() override; | 59 void OnForeignSessionUpdated() override; |
| 60 | 60 |
| 61 static bool RegisterForeignSessionHelper(JNIEnv* env); | 61 static bool RegisterForeignSessionHelper(JNIEnv* env); |
| 62 | 62 |
| 63 private: | 63 private: |
| 64 ~ForeignSessionHelper() override; | 64 ~ForeignSessionHelper() override; |
| 65 | 65 |
| 66 // Fires |callback_| if it is not null. | 66 // Fires |callback_| if it is not null. |
| 67 void FireForeignSessionCallback(); | 67 void FireForeignSessionCallback(); |
| 68 | 68 |
| 69 Profile* profile_; // weak | 69 Profile* profile_; // weak |
| 70 base::android::ScopedJavaGlobalRef<jobject> callback_; | 70 base::android::ScopedJavaGlobalRef<jobject> callback_; |
| 71 ScopedObserver<syncer::SyncService, syncer::SyncServiceObserver> | 71 ScopedObserver<sync_driver::SyncService, sync_driver::SyncServiceObserver> |
| 72 scoped_observer_; | 72 scoped_observer_; |
| 73 | 73 |
| 74 DISALLOW_COPY_AND_ASSIGN(ForeignSessionHelper); | 74 DISALLOW_COPY_AND_ASSIGN(ForeignSessionHelper); |
| 75 }; | 75 }; |
| 76 | 76 |
| 77 #endif // CHROME_BROWSER_ANDROID_FOREIGN_SESSION_HELPER_H_ | 77 #endif // CHROME_BROWSER_ANDROID_FOREIGN_SESSION_HELPER_H_ |
| OLD | NEW |