Home | History | Annotate | Download | only in android
      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_ANDROID_FOREIGN_SESSION_HELPER_H_
      6 #define CHROME_BROWSER_ANDROID_FOREIGN_SESSION_HELPER_H_
      7 
      8 #include <jni.h>
      9 
     10 #include "base/android/scoped_java_ref.h"
     11 #include "chrome/browser/profiles/profile.h"
     12 #include "content/public/browser/notification_observer.h"
     13 #include "content/public/browser/notification_registrar.h"
     14 
     15 using base::android::ScopedJavaLocalRef;
     16 
     17 struct SessionWindow;
     18 
     19 namespace browser_sync {
     20 struct SyncedSession;
     21 }  // namespace browser_sync
     22 
     23 class ForeignSessionHelper : public content::NotificationObserver {
     24  public:
     25   explicit ForeignSessionHelper(Profile* profile);
     26   void Destroy(JNIEnv* env, jobject obj);
     27   jboolean IsTabSyncEnabled(JNIEnv* env, jobject obj);
     28   void SetOnForeignSessionCallback(JNIEnv* env, jobject obj, jobject callback);
     29   jboolean GetForeignSessions(JNIEnv* env, jobject obj, jobject result);
     30   jboolean OpenForeignSessionTab(JNIEnv* env,
     31                                  jobject obj,
     32                                  jobject j_tab,
     33                                  jstring session_tag,
     34                                  jint tab_id,
     35                                  jint disposition);
     36   void DeleteForeignSession(JNIEnv* env, jobject obj, jstring session_tag);
     37 
     38   // NotificationObserver implemenation
     39   virtual void Observe(int type,
     40                        const content::NotificationSource& source,
     41                        const content::NotificationDetails& details) OVERRIDE;
     42 
     43   static bool RegisterForeignSessionHelper(JNIEnv* env);
     44 
     45  private:
     46   virtual ~ForeignSessionHelper();
     47 
     48   Profile* profile_;  // weak
     49   base::android::ScopedJavaGlobalRef<jobject> callback_;
     50   content::NotificationRegistrar registrar_;
     51 
     52   DISALLOW_COPY_AND_ASSIGN(ForeignSessionHelper);
     53 };
     54 
     55 #endif  // CHROME_BROWSER_ANDROID_FOREIGN_SESSION_HELPER_H_
     56