1 // Copyright 2014 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 package org.chromium.chrome.browser.tabmodel;
7 import com.google.common.annotations.VisibleForTesting;
9 import org.chromium.chrome.browser.Tab;
10 import org.chromium.chrome.browser.profiles.Profile;
13 * Singleton class intended to stub out Tab model before it has been created.
15 public class EmptyTabModel implements TabModel {
18 * Used to mock TabModel. Application code should use getInstance() to construct an
22 protected EmptyTabModel() {}
24 // "Initialization on demand holder idiom"
25 private static class LazyHolder {
26 private static final EmptyTabModel INSTANCE = new EmptyTabModel();
30 * Get the singleton instance of EmptyTabModel.
31 * @return the instance of EmptyTabModel
33 public static EmptyTabModel getInstance() {
34 return LazyHolder.INSTANCE;
38 public Profile getProfile() {
43 public boolean isIncognito() {
48 public boolean closeTab(Tab tab) {
53 public Tab getNextTabIfClosed(int id) {
58 public void closeAllTabs() {
62 public int getCount() {
63 // We must return 0 to be consistent with getTab(i)
68 public Tab getTabAt(int position) {
73 public int indexOf(Tab tab) {
74 return INVALID_TAB_INDEX;
79 return INVALID_TAB_INDEX;
83 public void setIndex(int i, TabSelectionType type) {}
86 public void moveTab(int id, int newIndex) {}
89 public void destroy() {}
92 public boolean isClosurePending(int tabId) {
97 public boolean closeTab(Tab tab, boolean animate, boolean uponExit, boolean canUndo) {
102 public TabList getComprehensiveModel() {
107 public void commitAllTabClosures() {
111 public void commitTabClosure(int tabId) {
115 public void cancelTabClosure(int tabId) {
119 public boolean supportsPendingClosures() {
124 public void addTab(Tab tab, int index, TabLaunchType type) {
129 public void addObserver(TabModelObserver observer) {
133 public void removeObserver(TabModelObserver observer) {