- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / browser / android / recently_closed_tabs_bridge.h
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_RECENTLY_CLOSED_TABS_BRIDGE_H_
6 #define CHROME_BROWSER_ANDROID_RECENTLY_CLOSED_TABS_BRIDGE_H_
7
8 #include <jni.h>
9
10 #include "base/android/scoped_java_ref.h"
11 #include "base/compiler_specific.h"
12 #include "chrome/browser/sessions/tab_restore_service_observer.h"
13
14 class Profile;
15 class TabRestoreService;
16
17 // Provides the list of recently closed tabs to Java.
18 class RecentlyClosedTabsBridge : public TabRestoreServiceObserver {
19  public:
20   explicit RecentlyClosedTabsBridge(Profile* profile);
21
22   void Destroy(JNIEnv* env, jobject obj);
23   void SetRecentlyClosedCallback(JNIEnv* env, jobject obj, jobject jcallback);
24   jboolean GetRecentlyClosedTabs(JNIEnv* env, jobject obj, jobject jtabs);
25   jboolean OpenRecentlyClosedTab(JNIEnv* env, jobject obj, jobject jtab,
26                                  jint tab_id);
27   void ClearRecentlyClosedTabs(JNIEnv* env, jobject obj);
28
29   // Observer callback for TabRestoreServiceObserver. Notifies the registered
30   // callback that the recently closed tabs list has changed.
31   virtual void TabRestoreServiceChanged(TabRestoreService* service) OVERRIDE;
32
33   // Observer callback when our associated TabRestoreService is destroyed.
34   virtual void TabRestoreServiceDestroyed(TabRestoreService* service) OVERRIDE;
35
36   // Registers JNI methods.
37   static bool Register(JNIEnv* env);
38
39  private:
40   virtual ~RecentlyClosedTabsBridge();
41
42   // Construct and initialize tab_restore_service_ if it's NULL.
43   // tab_restore_service_ may still be NULL, however, in incognito mode.
44   void EnsureTabRestoreService();
45
46   // The callback to be notified when the list of recently closed tabs changes.
47   base::android::ScopedJavaGlobalRef<jobject> callback_;
48
49   // The profile whose recently closed tabs are being monitored.
50   Profile* profile_;
51
52   // TabRestoreService that we are observing.
53   TabRestoreService* tab_restore_service_;
54
55   DISALLOW_COPY_AND_ASSIGN(RecentlyClosedTabsBridge);
56 };
57
58 #endif  // CHROME_BROWSER_ANDROID_RECENTLY_CLOSED_TABS_BRIDGE_H_