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

Side by Side Diff: chrome/android/shell/java/src/org/chromium/chrome/shell/TabManager.java

Issue 738693002: Opening new "about:blank" tab if all tabs are closed in tab switcher mode. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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
« no previous file with comments | « chrome/android/shell/java/src/org/chromium/chrome/shell/ChromeShellActivity.java ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 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.shell; 5 package org.chromium.chrome.shell;
6 6
7 import android.content.Context; 7 import android.content.Context;
8 import android.util.AttributeSet; 8 import android.util.AttributeSet;
9 import android.view.LayoutInflater; 9 import android.view.LayoutInflater;
10 import android.view.View; 10 import android.view.View;
11 import android.view.ViewGroup; 11 import android.view.ViewGroup;
12 import android.view.ViewParent; 12 import android.view.ViewParent;
13 import android.view.inputmethod.InputMethodManager; 13 import android.view.inputmethod.InputMethodManager;
14 import android.widget.FrameLayout; 14 import android.widget.FrameLayout;
15 import android.widget.LinearLayout; 15 import android.widget.LinearLayout;
16 16
17 import org.chromium.base.VisibleForTesting;
17 import org.chromium.chrome.browser.EmptyTabObserver; 18 import org.chromium.chrome.browser.EmptyTabObserver;
18 import org.chromium.chrome.browser.Tab; 19 import org.chromium.chrome.browser.Tab;
19 import org.chromium.chrome.browser.tabmodel.EmptyTabModelObserver; 20 import org.chromium.chrome.browser.tabmodel.EmptyTabModelObserver;
20 import org.chromium.chrome.browser.tabmodel.TabModel.TabLaunchType; 21 import org.chromium.chrome.browser.tabmodel.TabModel.TabLaunchType;
21 import org.chromium.chrome.browser.tabmodel.TabModel.TabSelectionType; 22 import org.chromium.chrome.browser.tabmodel.TabModel.TabSelectionType;
22 import org.chromium.chrome.browser.widget.accessibility.AccessibilityTabModelWra pper; 23 import org.chromium.chrome.browser.widget.accessibility.AccessibilityTabModelWra pper;
23 import org.chromium.content.browser.ContentVideoViewClient; 24 import org.chromium.content.browser.ContentVideoViewClient;
24 import org.chromium.content.browser.ContentViewCore; 25 import org.chromium.content.browser.ContentViewCore;
25 import org.chromium.content.browser.ContentViewRenderView; 26 import org.chromium.content.browser.ContentViewRenderView;
26 import org.chromium.content_public.browser.LoadUrlParams; 27 import org.chromium.content_public.browser.LoadUrlParams;
(...skipping 23 matching lines...) Expand all
50 @Override 51 @Override
51 public void didSelectTab(Tab tab, TabSelectionType type, int lastId) { 52 public void didSelectTab(Tab tab, TabSelectionType type, int lastId) {
52 assert tab instanceof ChromeShellTab; 53 assert tab instanceof ChromeShellTab;
53 setCurrentTab((ChromeShellTab) tab); 54 setCurrentTab((ChromeShellTab) tab);
54 hideTabSwitcher(); 55 hideTabSwitcher();
55 } 56 }
56 57
57 @Override 58 @Override
58 public void willCloseTab(Tab tab, boolean animate) { 59 public void willCloseTab(Tab tab, boolean animate) {
59 if (tab == mCurrentTab) setCurrentTab(null); 60 if (tab == mCurrentTab) setCurrentTab(null);
61 if (mTabModelSelector.getCurrentModel().getCount() == 1) {
62 createNewTab();
63 }
60 } 64 }
61 }; 65 };
62 66
63 /** 67 /**
64 * @param context The Context the view is running in. 68 * @param context The Context the view is running in.
65 * @param attrs The attributes of the XML tag that is inflating the view. 69 * @param attrs The attributes of the XML tag that is inflating the view.
66 */ 70 */
67 public TabManager(Context context, AttributeSet attrs) { 71 public TabManager(Context context, AttributeSet attrs) {
68 super(context, attrs); 72 super(context, attrs);
69 } 73 }
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 createTab("about:blank", TabLaunchType.FROM_MENU_OR_OVERVIEW); 141 createTab("about:blank", TabLaunchType.FROM_MENU_OR_OVERVIEW);
138 } 142 }
139 143
140 /** 144 /**
141 * Closes all current tabs. 145 * Closes all current tabs.
142 */ 146 */
143 public void closeAllTabs() { 147 public void closeAllTabs() {
144 mTabModelSelector.getCurrentModel().closeAllTabs(); 148 mTabModelSelector.getCurrentModel().closeAllTabs();
145 } 149 }
146 150
151 @VisibleForTesting
152 public void closeTab() {
153 mTabModelSelector.getCurrentModel().closeTab(mCurrentTab);
154 }
155
147 /** 156 /**
148 * Creates a {@link ChromeShellTab} with a URL specified by {@code url}. 157 * Creates a {@link ChromeShellTab} with a URL specified by {@code url}.
149 * @param url The URL the new {@link ChromeShellTab} should start with. 158 * @param url The URL the new {@link ChromeShellTab} should start with.
150 * @return The newly created tab, or null if the content view is uninitializ ed. 159 * @return The newly created tab, or null if the content view is uninitializ ed.
151 */ 160 */
152 public Tab createTab(String url, TabLaunchType type) { 161 public Tab createTab(String url, TabLaunchType type) {
153 if (!isContentViewRenderViewInitialized()) return null; 162 if (!isContentViewRenderViewInitialized()) return null;
154 163
155 LoadUrlParams loadUrlParams = new LoadUrlParams(url); 164 LoadUrlParams loadUrlParams = new LoadUrlParams(url);
156 Tab tab = mTabModelSelector.openNewTab(loadUrlParams, type, null, false) ; 165 Tab tab = mTabModelSelector.openNewTab(loadUrlParams, type, null, false) ;
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 LoadUrlParams loadUrlParams = new LoadUrlParams(url); 258 LoadUrlParams loadUrlParams = new LoadUrlParams(url);
250 loadUrlParams.setTransitionType(PageTransition.TYPED | PageTransition.FR OM_ADDRESS_BAR); 259 loadUrlParams.setTransitionType(PageTransition.TYPED | PageTransition.FR OM_ADDRESS_BAR);
251 Tab tab = mTabModelSelector.getCurrentTab(); 260 Tab tab = mTabModelSelector.getCurrentTab();
252 if (tab != null) { 261 if (tab != null) {
253 tab.loadUrl(loadUrlParams); 262 tab.loadUrl(loadUrlParams);
254 return tab; 263 return tab;
255 } 264 }
256 return createTab(url, TabLaunchType.FROM_KEYBOARD); 265 return createTab(url, TabLaunchType.FROM_KEYBOARD);
257 } 266 }
258 } 267 }
OLDNEW
« no previous file with comments | « chrome/android/shell/java/src/org/chromium/chrome/shell/ChromeShellActivity.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698