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.
5 #ifndef CHROME_BROWSER_ANDROID_RECENTLY_CLOSED_TABS_BRIDGE_H_
6 #define CHROME_BROWSER_ANDROID_RECENTLY_CLOSED_TABS_BRIDGE_H_
10 #include "base/android/scoped_java_ref.h"
11 #include "base/compiler_specific.h"
12 #include "chrome/browser/sessions/tab_restore_service_observer.h"
15 class TabRestoreService
;
17 // Provides the list of recently closed tabs to Java.
18 class RecentlyClosedTabsBridge
: public TabRestoreServiceObserver
{
20 explicit RecentlyClosedTabsBridge(Profile
* profile
);
22 void Destroy(JNIEnv
* env
, jobject obj
);
23 void SetRecentlyClosedCallback(JNIEnv
* env
, jobject obj
, jobject jcallback
);
24 jboolean
GetRecentlyClosedTabs(JNIEnv
* env
,
28 jboolean
OpenRecentlyClosedTab(JNIEnv
* env
,
32 void ClearRecentlyClosedTabs(JNIEnv
* env
, jobject obj
);
34 // Observer callback for TabRestoreServiceObserver. Notifies the registered
35 // callback that the recently closed tabs list has changed.
36 virtual void TabRestoreServiceChanged(TabRestoreService
* service
) OVERRIDE
;
38 // Observer callback when our associated TabRestoreService is destroyed.
39 virtual void TabRestoreServiceDestroyed(TabRestoreService
* service
) OVERRIDE
;
41 // Registers JNI methods.
42 static bool Register(JNIEnv
* env
);
45 virtual ~RecentlyClosedTabsBridge();
47 // Construct and initialize tab_restore_service_ if it's NULL.
48 // tab_restore_service_ may still be NULL, however, in incognito mode.
49 void EnsureTabRestoreService();
51 // The callback to be notified when the list of recently closed tabs changes.
52 base::android::ScopedJavaGlobalRef
<jobject
> callback_
;
54 // The profile whose recently closed tabs are being monitored.
57 // TabRestoreService that we are observing.
58 TabRestoreService
* tab_restore_service_
;
60 DISALLOW_COPY_AND_ASSIGN(RecentlyClosedTabsBridge
);
63 #endif // CHROME_BROWSER_ANDROID_RECENTLY_CLOSED_TABS_BRIDGE_H_