11e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// Copyright 2013 The Chromium Authors. All rights reserved. 21e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 31e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// found in the LICENSE file. 41e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 51e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#ifndef CHROME_BROWSER_ANDROID_RECENTLY_CLOSED_TABS_BRIDGE_H_ 61e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#define CHROME_BROWSER_ANDROID_RECENTLY_CLOSED_TABS_BRIDGE_H_ 71e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 81e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#include <jni.h> 91e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 101e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#include "base/android/scoped_java_ref.h" 111e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#include "base/compiler_specific.h" 121e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#include "chrome/browser/sessions/tab_restore_service_observer.h" 131e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 141e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)class Profile; 151e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)class TabRestoreService; 161e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 171e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// Provides the list of recently closed tabs to Java. 181e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)class RecentlyClosedTabsBridge : public TabRestoreServiceObserver { 191e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) public: 201e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) explicit RecentlyClosedTabsBridge(Profile* profile); 211e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 221e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) void Destroy(JNIEnv* env, jobject obj); 231e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) void SetRecentlyClosedCallback(JNIEnv* env, jobject obj, jobject jcallback); 24f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) jboolean GetRecentlyClosedTabs(JNIEnv* env, 25f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) jobject obj, 26f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) jobject jtabs, 27f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) jint max_tab_count); 28f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) jboolean OpenRecentlyClosedTab(JNIEnv* env, 29f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) jobject obj, 30f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) jobject jtab, 31effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch jint tab_id, 32effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch jint j_disposition); 331e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) void ClearRecentlyClosedTabs(JNIEnv* env, jobject obj); 341e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 351e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) // Observer callback for TabRestoreServiceObserver. Notifies the registered 361e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) // callback that the recently closed tabs list has changed. 371e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) virtual void TabRestoreServiceChanged(TabRestoreService* service) OVERRIDE; 381e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 391e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) // Observer callback when our associated TabRestoreService is destroyed. 401e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) virtual void TabRestoreServiceDestroyed(TabRestoreService* service) OVERRIDE; 411e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 421e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) // Registers JNI methods. 431e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) static bool Register(JNIEnv* env); 441e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 451e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) private: 461e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) virtual ~RecentlyClosedTabsBridge(); 471e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 481e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) // Construct and initialize tab_restore_service_ if it's NULL. 491e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) // tab_restore_service_ may still be NULL, however, in incognito mode. 501e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) void EnsureTabRestoreService(); 511e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 521e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) // The callback to be notified when the list of recently closed tabs changes. 531e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) base::android::ScopedJavaGlobalRef<jobject> callback_; 541e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 551e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) // The profile whose recently closed tabs are being monitored. 561e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) Profile* profile_; 571e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 581e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) // TabRestoreService that we are observing. 591e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) TabRestoreService* tab_restore_service_; 601e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 611e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) DISALLOW_COPY_AND_ASSIGN(RecentlyClosedTabsBridge); 621e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)}; 631e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 641e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#endif // CHROME_BROWSER_ANDROID_RECENTLY_CLOSED_TABS_BRIDGE_H_ 65