Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 66 private final TabObserver mTabObserver; | 66 private final TabObserver mTabObserver; |
| 67 | 67 |
| 68 private AppMenuHandler mMenuHandler; | 68 private AppMenuHandler mMenuHandler; |
| 69 private AppMenuButtonHelper mAppMenuButtonHelper; | 69 private AppMenuButtonHelper mAppMenuButtonHelper; |
| 70 | 70 |
| 71 private TabManager mTabManager; | 71 private TabManager mTabManager; |
| 72 | 72 |
| 73 private SuggestionPopup mSuggestionPopup; | 73 private SuggestionPopup mSuggestionPopup; |
| 74 | 74 |
| 75 private ImageButton mStopReloadButton; | 75 private ImageButton mStopReloadButton; |
| 76 private ImageButton mAddButton; | |
| 76 private int mProgress = 0; | 77 private int mProgress = 0; |
| 77 private boolean mLoading = true; | 78 private boolean mLoading = true; |
| 78 | 79 |
| 79 /** | 80 /** |
| 80 * @param context The Context the view is running in. | 81 * @param context The Context the view is running in. |
| 81 * @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. |
| 82 */ | 83 */ |
| 83 public ChromeShellToolbar(Context context, AttributeSet attrs) { | 84 public ChromeShellToolbar(Context context, AttributeSet attrs) { |
| 84 super(context, attrs); | 85 super(context, attrs); |
| 85 // 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 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 137 | 138 |
| 138 @Override | 139 @Override |
| 139 protected void onFinishInflate() { | 140 protected void onFinishInflate() { |
| 140 super.onFinishInflate(); | 141 super.onFinishInflate(); |
| 141 | 142 |
| 142 mProgressDrawable = (ClipDrawable) findViewById(R.id.toolbar).getBackgro und(); | 143 mProgressDrawable = (ClipDrawable) findViewById(R.id.toolbar).getBackgro und(); |
| 143 initializeUrlField(); | 144 initializeUrlField(); |
| 144 initializeTabSwitcherButton(); | 145 initializeTabSwitcherButton(); |
| 145 initializeMenuButton(); | 146 initializeMenuButton(); |
| 146 initializeStopReloadButton(); | 147 initializeStopReloadButton(); |
| 148 initializeAddButton(); | |
| 147 } | 149 } |
| 148 | 150 |
| 149 void setMenuHandler(AppMenuHandler menuHandler) { | 151 void setMenuHandler(AppMenuHandler menuHandler) { |
| 150 mMenuHandler = menuHandler; | 152 mMenuHandler = menuHandler; |
| 151 ImageButton menuButton = (ImageButton) findViewById(R.id.menu_button); | 153 ImageButton menuButton = (ImageButton) findViewById(R.id.menu_button); |
| 152 mAppMenuButtonHelper = new AppMenuButtonHelper(menuButton, mMenuHandler) ; | 154 mAppMenuButtonHelper = new AppMenuButtonHelper(menuButton, mMenuHandler) ; |
| 153 } | 155 } |
| 154 | 156 |
| 155 private void initializeUrlField() { | 157 private void initializeUrlField() { |
| 156 mUrlTextView = (EditText) findViewById(R.id.url); | 158 mUrlTextView = (EditText) findViewById(R.id.url); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 240 if (mTab == null) return; | 242 if (mTab == null) return; |
| 241 if (mLoading) { | 243 if (mLoading) { |
| 242 mTab.getWebContents().stop(); | 244 mTab.getWebContents().stop(); |
| 243 } else { | 245 } else { |
| 244 mTab.getWebContents().getNavigationController().reload(true) ; | 246 mTab.getWebContents().getNavigationController().reload(true) ; |
| 245 } | 247 } |
| 246 } | 248 } |
| 247 }); | 249 }); |
| 248 } | 250 } |
| 249 | 251 |
| 252 private void initializeAddButton() { | |
| 253 mAddButton = (ImageButton) findViewById(R.id.add_button); | |
| 254 mAddButton.setOnClickListener(new OnClickListener() { | |
| 255 @Override | |
| 256 public void onClick(View v) { | |
| 257 mTabManager.createNewTab(); | |
| 258 } | |
| 259 }); | |
| 260 } | |
| 261 | |
| 262 /** | |
| 263 * Shows the add button and hides the stop/reload button. | |
|
Bernhard Bauer
2014/11/12 10:00:13
Technically, this can also do the opposite... Add
divya.bansal
2014/11/12 10:18:04
Done.
| |
| 264 * @param visibility The visibility status of the tab switcher. | |
|
Bernhard Bauer
2014/11/12 10:00:13
Replace "tab switcher" with "add button".
divya.bansal
2014/11/12 10:18:04
Done.
| |
| 265 */ | |
| 266 public void showAddButton(boolean visibility) { | |
| 267 mAddButton.setVisibility(visibility ? VISIBLE : GONE); | |
| 268 mStopReloadButton.setVisibility(visibility ? GONE : VISIBLE); | |
| 269 } | |
| 270 | |
| 250 /** | 271 /** |
| 251 * @return Current tab that is shown by ChromeShell. | 272 * @return Current tab that is shown by ChromeShell. |
| 252 */ | 273 */ |
| 253 public ChromeShellTab getCurrentTab() { | 274 public ChromeShellTab getCurrentTab() { |
| 254 return mTab; | 275 return mTab; |
| 255 } | 276 } |
| 256 | 277 |
| 257 /** | 278 /** |
| 258 * Change the visibility of the software keyboard. | 279 * Change the visibility of the software keyboard. |
| 259 * @param visible Whether the keyboard should be shown or hidden. | 280 * @param visible Whether the keyboard should be shown or hidden. |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 279 public void onLoadProgressChanged(Tab tab, int progress) { | 300 public void onLoadProgressChanged(Tab tab, int progress) { |
| 280 if (tab == mTab) ChromeShellToolbar.this.onLoadProgressChanged(progr ess); | 301 if (tab == mTab) ChromeShellToolbar.this.onLoadProgressChanged(progr ess); |
| 281 } | 302 } |
| 282 | 303 |
| 283 @Override | 304 @Override |
| 284 public void onUpdateUrl(Tab tab, String url) { | 305 public void onUpdateUrl(Tab tab, String url) { |
| 285 if (tab == mTab) ChromeShellToolbar.this.onUpdateUrl(url); | 306 if (tab == mTab) ChromeShellToolbar.this.onUpdateUrl(url); |
| 286 } | 307 } |
| 287 } | 308 } |
| 288 } | 309 } |
| OLD | NEW |