Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(56)

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/ntp/RecentlyClosedBridge.java

Issue 2088443003: Shortcut ctrl+shift+T added on android. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Nit fixes based on review. Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.chrome.browser.ntp; 5 package org.chromium.chrome.browser.ntp;
6 6
7 import org.chromium.base.annotations.CalledByNative; 7 import org.chromium.base.annotations.CalledByNative;
8 import org.chromium.chrome.browser.profiles.Profile; 8 import org.chromium.chrome.browser.profiles.Profile;
9 import org.chromium.chrome.browser.tab.Tab; 9 import org.chromium.chrome.browser.tab.Tab;
10 10
11 import java.util.ArrayList; 11 import java.util.ArrayList;
12 import java.util.List; 12 import java.util.List;
13 13
14 /** 14 /**
15 * This class allows Java code to get and clear the list of recently closed tabs . 15 * This class allows Java code to get and clear the list of recently closed tabs .
16 */ 16 */
17 class RecentlyClosedBridge { 17 public class RecentlyClosedBridge {
18 private long mNativeRecentlyClosedTabsBridge; 18 private long mNativeRecentlyClosedTabsBridge;
19 19
20 /** 20 /**
21 * Callback interface for getting notified when the list of recently closed tabs is updated. 21 * Callback interface for getting notified when the list of recently closed tabs is updated.
22 */ 22 */
23 interface RecentlyClosedCallback { 23 interface RecentlyClosedCallback {
24 /** 24 /**
25 * This method will be called every time the list of recently closed tab s is updated. 25 * This method will be called every time the list of recently closed tab s is updated.
26 * 26 *
27 * It's a good place to call {@link RecentlyClosedBridge#getRecentlyClos edTabs()} to get the 27 * It's a good place to call {@link RecentlyClosedBridge#getRecentlyClos edTabs()} to get the
(...skipping 22 matching lines...) Expand all
50 private static void pushTab( 50 private static void pushTab(
51 List<RecentlyClosedTab> tabs, int id, String title, String url) { 51 List<RecentlyClosedTab> tabs, int id, String title, String url) {
52 RecentlyClosedTab tab = new RecentlyClosedTab(id, title, url); 52 RecentlyClosedTab tab = new RecentlyClosedTab(id, title, url);
53 tabs.add(tab); 53 tabs.add(tab);
54 } 54 }
55 55
56 /** 56 /**
57 * Initializes this class with the given profile. 57 * Initializes this class with the given profile.
58 * @param profile The Profile whose recently closed tabs will be queried. 58 * @param profile The Profile whose recently closed tabs will be queried.
59 */ 59 */
60 RecentlyClosedBridge(Profile profile) { 60 public RecentlyClosedBridge(Profile profile) {
61 mNativeRecentlyClosedTabsBridge = nativeInit(profile); 61 mNativeRecentlyClosedTabsBridge = nativeInit(profile);
62 } 62 }
63 63
64 /** 64 /**
65 * Cleans up the C++ side of this class. This instance must not be used afte r calling destroy(). 65 * Cleans up the C++ side of this class. This instance must not be used afte r calling destroy().
66 */ 66 */
67 void destroy() { 67 public void destroy() {
68 assert mNativeRecentlyClosedTabsBridge != 0; 68 assert mNativeRecentlyClosedTabsBridge != 0;
69 nativeDestroy(mNativeRecentlyClosedTabsBridge); 69 nativeDestroy(mNativeRecentlyClosedTabsBridge);
70 mNativeRecentlyClosedTabsBridge = 0; 70 mNativeRecentlyClosedTabsBridge = 0;
71 } 71 }
72 72
73 /** 73 /**
74 * Sets the callback to be called whenever the list of recently closed tabs changes. 74 * Sets the callback to be called whenever the list of recently closed tabs changes.
75 * @param callback The RecentlyClosedCallback to be notified, or null. 75 * @param callback The RecentlyClosedCallback to be notified, or null.
76 */ 76 */
77 void setRecentlyClosedCallback(RecentlyClosedCallback callback) { 77 void setRecentlyClosedCallback(RecentlyClosedCallback callback) {
(...skipping 21 matching lines...) Expand all
99 * the current tab or a new tab. 99 * the current tab or a new tab.
100 * @return Whether the tab was successfully opened. 100 * @return Whether the tab was successfully opened.
101 */ 101 */
102 boolean openRecentlyClosedTab(Tab tab, RecentlyClosedTab recentTab, 102 boolean openRecentlyClosedTab(Tab tab, RecentlyClosedTab recentTab,
103 int windowOpenDisposition) { 103 int windowOpenDisposition) {
104 return nativeOpenRecentlyClosedTab(mNativeRecentlyClosedTabsBridge, tab, recentTab.id, 104 return nativeOpenRecentlyClosedTab(mNativeRecentlyClosedTabsBridge, tab, recentTab.id,
105 windowOpenDisposition); 105 windowOpenDisposition);
106 } 106 }
107 107
108 /** 108 /**
109 * Opens the most recently closed tab in a new tab by reading data from the native tab restore
110 * service.
111 */
112 public void openRecentlyClosedTab() {
113 nativeOpenMostRecentlyClosedTab(mNativeRecentlyClosedTabsBridge);
114 }
115
116 /**
109 * Clears all recently closed tabs. 117 * Clears all recently closed tabs.
110 */ 118 */
111 void clearRecentlyClosedTabs() { 119 void clearRecentlyClosedTabs() {
112 nativeClearRecentlyClosedTabs(mNativeRecentlyClosedTabsBridge); 120 nativeClearRecentlyClosedTabs(mNativeRecentlyClosedTabsBridge);
113 } 121 }
114 122
115 private native long nativeInit(Profile profile); 123 private native long nativeInit(Profile profile);
116 private native void nativeDestroy(long nativeRecentlyClosedTabsBridge); 124 private native void nativeDestroy(long nativeRecentlyClosedTabsBridge);
117 private native void nativeSetRecentlyClosedCallback( 125 private native void nativeSetRecentlyClosedCallback(
118 long nativeRecentlyClosedTabsBridge, RecentlyClosedCallback callback ); 126 long nativeRecentlyClosedTabsBridge, RecentlyClosedCallback callback );
119 private native boolean nativeGetRecentlyClosedTabs( 127 private native boolean nativeGetRecentlyClosedTabs(
120 long nativeRecentlyClosedTabsBridge, List<RecentlyClosedTab> tabs, i nt maxTabCount); 128 long nativeRecentlyClosedTabsBridge, List<RecentlyClosedTab> tabs, i nt maxTabCount);
121 private native boolean nativeOpenRecentlyClosedTab(long nativeRecentlyClosed TabsBridge, 129 private native boolean nativeOpenRecentlyClosedTab(long nativeRecentlyClosed TabsBridge,
122 Tab tab, int recentTabId, int windowOpenDisposition); 130 Tab tab, int recentTabId, int windowOpenDisposition);
131 private native boolean nativeOpenMostRecentlyClosedTab(long nativeRecentlyCl osedTabsBridge);
123 private native void nativeClearRecentlyClosedTabs(long nativeRecentlyClosedT absBridge); 132 private native void nativeClearRecentlyClosedTabs(long nativeRecentlyClosedT absBridge);
124 } 133 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698