Roll src/third_party/WebKit eac3800:0237a66 (svn 202606:202607)
[chromium-blink-merge.git] / chrome / browser / android / recently_closed_tabs_bridge.h
blobf223c7f93221f332a4e2a461f176b320276fea2c
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_
8 #include <jni.h>
10 #include "base/android/scoped_java_ref.h"
11 #include "base/compiler_specific.h"
12 #include "components/sessions/core/tab_restore_service_observer.h"
14 class Profile;
16 // Provides the list of recently closed tabs to Java.
17 class RecentlyClosedTabsBridge : public sessions::TabRestoreServiceObserver {
18 public:
19 explicit RecentlyClosedTabsBridge(Profile* profile);
21 void Destroy(JNIEnv* env, jobject obj);
22 void SetRecentlyClosedCallback(JNIEnv* env, jobject obj, jobject jcallback);
23 jboolean GetRecentlyClosedTabs(JNIEnv* env,
24 jobject obj,
25 jobject jtabs,
26 jint max_tab_count);
27 jboolean OpenRecentlyClosedTab(JNIEnv* env,
28 jobject obj,
29 jobject jtab,
30 jint tab_id,
31 jint j_disposition);
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 void TabRestoreServiceChanged(sessions::TabRestoreService* service) override;
38 // Observer callback when our associated TabRestoreService is destroyed.
39 void TabRestoreServiceDestroyed(
40 sessions::TabRestoreService* service) override;
42 // Registers JNI methods.
43 static bool Register(JNIEnv* env);
45 private:
46 ~RecentlyClosedTabsBridge() override;
48 // Construct and initialize tab_restore_service_ if it's NULL.
49 // tab_restore_service_ may still be NULL, however, in incognito mode.
50 void EnsureTabRestoreService();
52 // The callback to be notified when the list of recently closed tabs changes.
53 base::android::ScopedJavaGlobalRef<jobject> callback_;
55 // The profile whose recently closed tabs are being monitored.
56 Profile* profile_;
58 // TabRestoreService that we are observing.
59 sessions::TabRestoreService* tab_restore_service_;
61 DISALLOW_COPY_AND_ASSIGN(RecentlyClosedTabsBridge);
64 #endif // CHROME_BROWSER_ANDROID_RECENTLY_CLOSED_TABS_BRIDGE_H_