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

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: Correcting indentation 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 | « no previous file | 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;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 private final EmptyTabModelObserver mTabModelObserver = new EmptyTabModelObs erver() { 49 private final EmptyTabModelObserver mTabModelObserver = new EmptyTabModelObs erver() {
50 @Override 50 @Override
51 public void didSelectTab(Tab tab, TabSelectionType type, int lastId) { 51 public void didSelectTab(Tab tab, TabSelectionType type, int lastId) {
52 assert tab instanceof ChromeShellTab; 52 assert tab instanceof ChromeShellTab;
53 setCurrentTab((ChromeShellTab) tab); 53 setCurrentTab((ChromeShellTab) tab);
54 hideTabSwitcher(); 54 hideTabSwitcher();
55 } 55 }
56 56
57 @Override 57 @Override
58 public void willCloseTab(Tab tab, boolean animate) { 58 public void willCloseTab(Tab tab, boolean animate) {
59 if (tab == mCurrentTab) setCurrentTab(null); 59 if (tab == mCurrentTab) {
60 setCurrentTab(null);
61 ensureTabExists();
62 }
60 } 63 }
61 }; 64 };
62 65
63 /** 66 /**
64 * @param context The Context the view is running in. 67 * @param context The Context the view is running in.
65 * @param attrs The attributes of the XML tag that is inflating the view. 68 * @param attrs The attributes of the XML tag that is inflating the view.
66 */ 69 */
67 public TabManager(Context context, AttributeSet attrs) { 70 public TabManager(Context context, AttributeSet attrs) {
68 super(context, attrs); 71 super(context, attrs);
69 } 72 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 * @return The currently visible {@link ChromeShellTab}. 121 * @return The currently visible {@link ChromeShellTab}.
119 */ 122 */
120 public ChromeShellTab getCurrentTab() { 123 public ChromeShellTab getCurrentTab() {
121 return mCurrentTab; 124 return mCurrentTab;
122 } 125 }
123 126
124 /** 127 /**
125 * Ensures that at least one tab exists, by opening a new one if necessary. 128 * Ensures that at least one tab exists, by opening a new one if necessary.
126 */ 129 */
127 public void ensureTabExists() { 130 public void ensureTabExists() {
128 if (mTabModelSelector.getCurrentModel().getCount() == 0) { 131 if (mTabModelSelector.getCurrentModel().getCount() == 1) {
Bernhard Bauer 2014/11/19 12:13:40 This also changes the semantics of existing code.
divya.bansal 2014/11/19 12:25:49 Yes thats true, actually in tabmodelbase.java getc
Bernhard Bauer 2014/11/19 12:54:39 I already told you what to do: in willCloseTab() (
divya.bansal 2014/11/19 14:48:39 Done.
129 createNewTab(); 132 createNewTab();
130 } 133 }
131 } 134 }
132 135
133 /** 136 /**
134 * Opens a new blank tab. 137 * Opens a new blank tab.
135 */ 138 */
136 public void createNewTab() { 139 public void createNewTab() {
137 createTab("about:blank", TabLaunchType.FROM_MENU_OR_OVERVIEW); 140 createTab("about:blank", TabLaunchType.FROM_MENU_OR_OVERVIEW);
138 } 141 }
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 LoadUrlParams loadUrlParams = new LoadUrlParams(url); 252 LoadUrlParams loadUrlParams = new LoadUrlParams(url);
250 loadUrlParams.setTransitionType(PageTransition.TYPED | PageTransition.FR OM_ADDRESS_BAR); 253 loadUrlParams.setTransitionType(PageTransition.TYPED | PageTransition.FR OM_ADDRESS_BAR);
251 Tab tab = mTabModelSelector.getCurrentTab(); 254 Tab tab = mTabModelSelector.getCurrentTab();
252 if (tab != null) { 255 if (tab != null) {
253 tab.loadUrl(loadUrlParams); 256 tab.loadUrl(loadUrlParams);
254 return tab; 257 return tab;
255 } 258 }
256 return createTab(url, TabLaunchType.FROM_KEYBOARD); 259 return createTab(url, TabLaunchType.FROM_KEYBOARD);
257 } 260 }
258 } 261 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698