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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/tabmodel/EmptyTabModel.java

Issue 270883002: Upstream base implementations of TabModel, TabModelSelector, and TabModelObserver. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync Created 6 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/tabmodel/EmptyTabModelObserver.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/java/src/org/chromium/chrome/browser/tabmodel/EmptyTabModel.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/tabmodel/EmptyTabModel.java b/chrome/android/java/src/org/chromium/chrome/browser/tabmodel/EmptyTabModel.java
new file mode 100644
index 0000000000000000000000000000000000000000..2013fa5a2284a9cbb661cc930d8e431c7662f35d
--- /dev/null
+++ b/chrome/android/java/src/org/chromium/chrome/browser/tabmodel/EmptyTabModel.java
@@ -0,0 +1,136 @@
+// 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 com.google.common.annotations.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) {
+ }
+
+}
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/tabmodel/EmptyTabModelObserver.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698