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 public void showAddButton(boolean tabSwitcherStatus) { | |
Bernhard Bauer
2014/11/11 09:08:22
Please add a Javadoc comment.
divya.bansal
2014/11/11 09:29:51
Done.
| |
263 mAddButton.setVisibility(tabSwitcherStatus ? VISIBLE : GONE); | |
264 mStopReloadButton.setVisibility(tabSwitcherStatus ? GONE : VISIBLE); | |
265 } | |
266 | |
250 /** | 267 /** |
251 * @return Current tab that is shown by ChromeShell. | 268 * @return Current tab that is shown by ChromeShell. |
252 */ | 269 */ |
253 public ChromeShellTab getCurrentTab() { | 270 public ChromeShellTab getCurrentTab() { |
254 return mTab; | 271 return mTab; |
255 } | 272 } |
256 | 273 |
257 /** | 274 /** |
258 * Change the visibility of the software keyboard. | 275 * Change the visibility of the software keyboard. |
259 * @param visible Whether the keyboard should be shown or hidden. | 276 * @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) { | 296 public void onLoadProgressChanged(Tab tab, int progress) { |
280 if (tab == mTab) ChromeShellToolbar.this.onLoadProgressChanged(progr ess); | 297 if (tab == mTab) ChromeShellToolbar.this.onLoadProgressChanged(progr ess); |
281 } | 298 } |
282 | 299 |
283 @Override | 300 @Override |
284 public void onUpdateUrl(Tab tab, String url) { | 301 public void onUpdateUrl(Tab tab, String url) { |
285 if (tab == mTab) ChromeShellToolbar.this.onUpdateUrl(url); | 302 if (tab == mTab) ChromeShellToolbar.this.onUpdateUrl(url); |
286 } | 303 } |
287 } | 304 } |
288 } | 305 } |
OLD | NEW |