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

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

Issue 683203006: Adding option for adding new tab in tab manager for chrome shell. (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
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.annotation.SuppressLint; 7 import android.annotation.SuppressLint;
8 import android.content.Context; 8 import android.content.Context;
9 import android.content.res.Configuration; 9 import android.content.res.Configuration;
10 import android.graphics.drawable.ClipDrawable; 10 import android.graphics.drawable.ClipDrawable;
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 private final TabObserver mTabObserver; 65 private final TabObserver mTabObserver;
66 66
67 private AppMenuHandler mMenuHandler; 67 private AppMenuHandler mMenuHandler;
68 private AppMenuButtonHelper mAppMenuButtonHelper; 68 private AppMenuButtonHelper mAppMenuButtonHelper;
69 69
70 private TabManager mTabManager; 70 private TabManager mTabManager;
71 71
72 private SuggestionPopup mSuggestionPopup; 72 private SuggestionPopup mSuggestionPopup;
73 73
74 private ImageButton mStopReloadButton; 74 private ImageButton mStopReloadButton;
75 private ImageButton mAddButton;
76
75 private int mProgress = 0; 77 private int mProgress = 0;
76 private boolean mLoading = true; 78 private boolean mLoading = true;
77 79
78 /** 80 /**
79 * @param context The Context the view is running in. 81 * @param context The Context the view is running in.
80 * @param attrs The attributes of the XML tag that is inflating the view. 82 * @param attrs The attributes of the XML tag that is inflating the view.
81 */ 83 */
82 public ChromeShellToolbar(Context context, AttributeSet attrs) { 84 public ChromeShellToolbar(Context context, AttributeSet attrs) {
83 super(context, attrs); 85 super(context, attrs);
84 // When running performance benchmark, we don't want to observe the tab 86 // When running performance benchmark, we don't want to observe the tab
85 // invalidation which would interfere with browser's processing content 87 // invalidation which would interfere with browser's processing content
86 // frame. See crbug.com/394976. 88 // frame. See crbug.com/394976.
87 if (CommandLine.getInstance().hasSwitch( 89 if (CommandLine.getInstance().hasSwitch(
88 ContentSwitches.RUNNING_PERFORMANCE_BENCHMARK)) { 90 ContentSwitches.RUNNING_PERFORMANCE_BENCHMARK)) {
89 mTabObserver = new EmptyTabObserver(); 91 mTabObserver = new EmptyTabObserver();
90 } else { 92 } else {
91 mTabObserver = new TabObserverImpl(); 93 mTabObserver = new TabObserverImpl();
92 } 94 }
93 } 95 }
94 96
95 /** 97 /**
96 * The toolbar will visually represent the state of {@code tab}. 98 * The toolbar will visually represent the state of {@code tab}.
97 * @param tab The Tab that should be represented. 99 * @param tab The Tab that should be represented.
98 */ 100 */
99 public void showTab(ChromeShellTab tab) { 101 public void showTab(ChromeShellTab tab) {
100 if (mTab != null) mTab.removeObserver(mTabObserver); 102 if (mTab != null) mTab.removeObserver(mTabObserver);
101 103
104 mAddButton.setVisibility(GONE);
Bernhard Bauer 2014/11/04 12:22:10 So, are we not going to show the stop/reload butto
divya.bansal 2014/11/05 09:04:22 Done. Showing the add button when tabswitcher is s
105
102 mTab = tab; 106 mTab = tab;
103 107
104 if (mTab != null) { 108 if (mTab != null) {
105 mTab.addObserver(mTabObserver); 109 mTab.addObserver(mTabObserver);
106 mUrlTextView.setText(mTab.getWebContents().getUrl()); 110 mUrlTextView.setText(mTab.getWebContents().getUrl());
107 } 111 }
108 } 112 }
109 113
110 /** 114 /**
111 * Set the TabManager responsible for activating the tab switcher. 115 * Set the TabManager responsible for activating the tab switcher.
(...skipping 24 matching lines...) Expand all
136 140
137 @Override 141 @Override
138 protected void onFinishInflate() { 142 protected void onFinishInflate() {
139 super.onFinishInflate(); 143 super.onFinishInflate();
140 144
141 mProgressDrawable = (ClipDrawable) findViewById(R.id.toolbar).getBackgro und(); 145 mProgressDrawable = (ClipDrawable) findViewById(R.id.toolbar).getBackgro und();
142 initializeUrlField(); 146 initializeUrlField();
143 initializeTabSwitcherButton(); 147 initializeTabSwitcherButton();
144 initializeMenuButton(); 148 initializeMenuButton();
145 initializeStopReloadButton(); 149 initializeStopReloadButton();
150 initializeAddButton();
146 } 151 }
147 152
148 void setMenuHandler(AppMenuHandler menuHandler) { 153 void setMenuHandler(AppMenuHandler menuHandler) {
149 mMenuHandler = menuHandler; 154 mMenuHandler = menuHandler;
150 ImageButton menuButton = (ImageButton) findViewById(R.id.menu_button); 155 ImageButton menuButton = (ImageButton) findViewById(R.id.menu_button);
151 mAppMenuButtonHelper = new AppMenuButtonHelper(menuButton, mMenuHandler) ; 156 mAppMenuButtonHelper = new AppMenuButtonHelper(menuButton, mMenuHandler) ;
152 } 157 }
153 158
154 private void initializeUrlField() { 159 private void initializeUrlField() {
155 mUrlTextView = (EditText) findViewById(R.id.url); 160 mUrlTextView = (EditText) findViewById(R.id.url);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 mSuggestionPopup = new SuggestionPopup(getContext(), mUrlTextView, this) ; 204 mSuggestionPopup = new SuggestionPopup(getContext(), mUrlTextView, this) ;
200 mUrlTextView.addTextChangedListener(mSuggestionPopup); 205 mUrlTextView.addTextChangedListener(mSuggestionPopup);
201 } 206 }
202 207
203 private void initializeTabSwitcherButton() { 208 private void initializeTabSwitcherButton() {
204 ImageButton tabSwitcherButton = (ImageButton) findViewById(R.id.tab_swit cher); 209 ImageButton tabSwitcherButton = (ImageButton) findViewById(R.id.tab_swit cher);
205 tabSwitcherButton.setOnClickListener(new OnClickListener() { 210 tabSwitcherButton.setOnClickListener(new OnClickListener() {
206 @Override 211 @Override
207 public void onClick(View v) { 212 public void onClick(View v) {
208 if (mTabManager != null) mTabManager.toggleTabSwitcher(); 213 if (mTabManager != null) mTabManager.toggleTabSwitcher();
214 mAddButton.setVisibility(mTabManager.isTabSwitcherVisible() ? VI SIBLE : GONE);
215 mStopReloadButton.setVisibility(mTabManager.isTabSwitcherVisible ()
216 ? GONE : VISIBLE);
209 } 217 }
210 }); 218 });
211 } 219 }
212 220
213 private void initializeMenuButton() { 221 private void initializeMenuButton() {
214 ImageButton menuButton = (ImageButton) findViewById(R.id.menu_button); 222 ImageButton menuButton = (ImageButton) findViewById(R.id.menu_button);
215 menuButton.setOnClickListener(new OnClickListener() { 223 menuButton.setOnClickListener(new OnClickListener() {
216 @Override 224 @Override
217 public void onClick(View view) { 225 public void onClick(View view) {
218 if (mMenuHandler != null) mMenuHandler.showAppMenu(view, false, false); 226 if (mMenuHandler != null) mMenuHandler.showAppMenu(view, false, false);
(...skipping 16 matching lines...) Expand all
235 if (mTab == null) return; 243 if (mTab == null) return;
236 if (mLoading) { 244 if (mLoading) {
237 mTab.getWebContents().stop(); 245 mTab.getWebContents().stop();
238 } else { 246 } else {
239 mTab.getWebContents().getNavigationController().reload(true) ; 247 mTab.getWebContents().getNavigationController().reload(true) ;
240 } 248 }
241 } 249 }
242 }); 250 });
243 } 251 }
244 252
253 private void initializeAddButton() {
254 mAddButton = (ImageButton) findViewById(R.id.add_button);
255 mAddButton.setOnClickListener(new OnClickListener() {
256 @Override
257 public void onClick(View v) {
258 mTabManager.createNewTab();
259 }
260 });
261 }
262
245 /** 263 /**
246 * @return Current tab that is shown by ChromeShell. 264 * @return Current tab that is shown by ChromeShell.
247 */ 265 */
248 public ChromeShellTab getCurrentTab() { 266 public ChromeShellTab getCurrentTab() {
249 return mTab; 267 return mTab;
250 } 268 }
251 269
252 /** 270 /**
253 * Change the visibility of the software keyboard. 271 * Change the visibility of the software keyboard.
254 * @param visible Whether the keyboard should be shown or hidden. 272 * @param visible Whether the keyboard should be shown or hidden.
(...skipping 19 matching lines...) Expand all
274 public void onLoadProgressChanged(Tab tab, int progress) { 292 public void onLoadProgressChanged(Tab tab, int progress) {
275 if (tab == mTab) ChromeShellToolbar.this.onLoadProgressChanged(progr ess); 293 if (tab == mTab) ChromeShellToolbar.this.onLoadProgressChanged(progr ess);
276 } 294 }
277 295
278 @Override 296 @Override
279 public void onUpdateUrl(Tab tab, String url) { 297 public void onUpdateUrl(Tab tab, String url) {
280 if (tab == mTab) ChromeShellToolbar.this.onUpdateUrl(url); 298 if (tab == mTab) ChromeShellToolbar.this.onUpdateUrl(url);
281 } 299 }
282 } 300 }
283 } 301 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698