Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2017 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 package org.chromium.chrome.browser.ntp; | |
| 6 | |
| 7 import org.chromium.chrome.browser.tab.Tab; | |
| 8 | |
| 9 import java.util.ArrayList; | |
| 10 import java.util.List; | |
| 11 | |
| 12 /** | |
| 13 * A fake implementation of {@link RecentlyClosedTabManager} for testing purpose s. | |
| 14 */ | |
| 15 public class FakeRecentlyClosedTabManager implements RecentlyClosedTabManager { | |
| 16 private RecentlyClosedCallback mCallback; | |
| 17 private List<RecentlyClosedTab> mTabs = new ArrayList<>(); | |
| 18 | |
| 19 @Override | |
| 20 public void setRecentlyClosedCallback(RecentlyClosedCallback callback) { | |
| 21 mCallback = callback; | |
| 22 } | |
| 23 | |
| 24 @Override | |
| 25 public List<RecentlyClosedTab> getRecentlyClosedTabs(int maxTabCount) { | |
| 26 List<RecentlyClosedTab> tabs = new ArrayList<>(); | |
| 27 for (int i = 0; i < maxTabCount && i < mTabs.size(); i++) { | |
| 28 tabs.add(mTabs.get(i)); | |
| 29 } | |
| 30 return tabs; | |
|
Bernhard Bauer
2017/01/04 11:54:16
Could you do `mTabs.subList(0, Math.min(maxTabCoun
Michael van Ouwerkerk
2017/01/05 11:02:14
Perhaps, but: "The returned List is backed by this
Bernhard Bauer
2017/01/05 17:47:37
I'm okay with the code as it is, but that does bri
Michael van Ouwerkerk
2017/01/06 11:11:11
From the subList docs: https://docs.oracle.com/jav
| |
| 31 } | |
| 32 | |
| 33 @Override | |
| 34 public boolean openRecentlyClosedTab( | |
| 35 Tab tab, RecentlyClosedTab recentTab, int windowOpenDisposition) { | |
| 36 return false; | |
| 37 } | |
| 38 | |
| 39 @Override | |
| 40 public void openRecentlyClosedTab() {} | |
| 41 | |
| 42 @Override | |
| 43 public void clearRecentlyClosedTabs() { | |
| 44 mTabs.clear(); | |
| 45 if (mCallback != null) mCallback.onUpdated(); | |
| 46 } | |
| 47 | |
| 48 public void setRecentlyClosedTabs(List<RecentlyClosedTab> tabs) { | |
| 49 mTabs = new ArrayList<>(tabs); | |
| 50 if (mCallback != null) mCallback.onUpdated(); | |
| 51 } | |
| 52 } | |
| OLD | NEW |