// Copyright 2014 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package org.chromium.chrome.browser.tabmodel; import org.chromium.base.VisibleForTesting; import org.chromium.chrome.browser.Tab; import org.chromium.chrome.browser.profiles.Profile; /** * Singleton class intended to stub out Tab model before it has been created. */ public class EmptyTabModel implements TabModel { /** * Used to mock TabModel. Application code should use getInstance() to construct an * EmptyTabModel. */ @VisibleForTesting protected EmptyTabModel() {} // "Initialization on demand holder idiom" private static class LazyHolder { private static final EmptyTabModel INSTANCE = new EmptyTabModel(); } /** * Get the singleton instance of EmptyTabModel. * @return the instance of EmptyTabModel */ public static EmptyTabModel getInstance() { return LazyHolder.INSTANCE; } @Override public Profile getProfile() { return null; } @Override public boolean isIncognito() { return false; } @Override public boolean closeTab(Tab tab) { return false; } @Override public Tab getNextTabIfClosed(int id) { return null; } @Override public void closeAllTabs() { } @Override public int getCount() { // We must return 0 to be consistent with getTab(i) return 0; } @Override public Tab getTabAt(int position) { return null; } @Override public int indexOf(Tab tab) { return INVALID_TAB_INDEX; } @Override public int index() { return INVALID_TAB_INDEX; } @Override public void setIndex(int i, TabSelectionType type) {} @Override public void moveTab(int id, int newIndex) {} @Override public void destroy() {} @Override public boolean isClosurePending(int tabId) { return false; } @Override public boolean closeTab(Tab tab, boolean animate, boolean uponExit, boolean canUndo) { return false; } @Override public TabList getComprehensiveModel() { return this; } @Override public void commitAllTabClosures() { } @Override public void commitTabClosure(int tabId) { } @Override public void cancelTabClosure(int tabId) { } @Override public boolean supportsPendingClosures() { return false; } @Override public void addTab(Tab tab, int index, TabLaunchType type) { assert false; } @Override public void addObserver(TabModelObserver observer) { } @Override public void removeObserver(TabModelObserver observer) { } }