// Copyright 2013 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CHROME_BROWSER_ANDROID_FOREIGN_SESSION_HELPER_H_ #define CHROME_BROWSER_ANDROID_FOREIGN_SESSION_HELPER_H_ #include #include "base/android/scoped_java_ref.h" #include "base/macros.h" #include "base/scoped_observer.h" #include "chrome/browser/profiles/profile.h" #include "components/sync_driver/sync_service_observer.h" using base::android::ScopedJavaLocalRef; struct SessionWindow; namespace browser_sync { struct SyncedSession; } // namespace browser_sync namespace sync_driver { class SyncService; } // namespace sync_driver class ForeignSessionHelper : public sync_driver::SyncServiceObserver { public: explicit ForeignSessionHelper(Profile* profile); void Destroy(JNIEnv* env, const base::android::JavaParamRef& obj); jboolean IsTabSyncEnabled(JNIEnv* env, const base::android::JavaParamRef& obj); void TriggerSessionSync(JNIEnv* env, const base::android::JavaParamRef& obj); void SetOnForeignSessionCallback( JNIEnv* env, const base::android::JavaParamRef& obj, const base::android::JavaParamRef& callback); jboolean GetForeignSessions( JNIEnv* env, const base::android::JavaParamRef& obj, const base::android::JavaParamRef& result); jboolean OpenForeignSessionTab( JNIEnv* env, const base::android::JavaParamRef& obj, const base::android::JavaParamRef& j_tab, const base::android::JavaParamRef& session_tag, jint tab_id, jint disposition); void DeleteForeignSession( JNIEnv* env, const base::android::JavaParamRef& obj, const base::android::JavaParamRef& session_tag); // sync_driver::SyncServiceObserver implementation void OnStateChanged() override {} void OnSyncConfigurationCompleted() override; void OnForeignSessionUpdated() override; static bool RegisterForeignSessionHelper(JNIEnv* env); private: ~ForeignSessionHelper() override; // Fires |callback_| if it is not null. void FireForeignSessionCallback(); Profile* profile_; // weak base::android::ScopedJavaGlobalRef callback_; ScopedObserver scoped_observer_; DISALLOW_COPY_AND_ASSIGN(ForeignSessionHelper); }; #endif // CHROME_BROWSER_ANDROID_FOREIGN_SESSION_HELPER_H_