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.content.Context; | 7 import android.content.Context; |
8 import android.content.res.Configuration; | 8 import android.content.res.Configuration; |
9 import android.graphics.drawable.ClipDrawable; | 9 import android.graphics.drawable.ClipDrawable; |
10 import android.util.AttributeSet; | 10 import android.util.AttributeSet; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 private ClipDrawable mProgressDrawable; | 45 private ClipDrawable mProgressDrawable; |
46 | 46 |
47 private ChromeShellTab mTab; | 47 private ChromeShellTab mTab; |
48 private final TabObserver mTabObserver; | 48 private final TabObserver mTabObserver; |
49 | 49 |
50 private AppMenuHandler mMenuHandler; | 50 private AppMenuHandler mMenuHandler; |
51 private AppMenuButtonHelper mAppMenuButtonHelper; | 51 private AppMenuButtonHelper mAppMenuButtonHelper; |
52 | 52 |
53 private SuggestionPopup mSuggestionPopup; | 53 private SuggestionPopup mSuggestionPopup; |
54 | 54 |
55 private ImageButton mStopButton; | 55 private ImageButton mStopReloadButton; |
56 private ImageButton mReloadButton; | 56 private boolean mLoading = true; |
57 | 57 |
58 /** | 58 /** |
59 * @param context The Context the view is running in. | 59 * @param context The Context the view is running in. |
60 * @param attrs The attributes of the XML tag that is inflating the view. | 60 * @param attrs The attributes of the XML tag that is inflating the view. |
61 */ | 61 */ |
62 public ChromeShellToolbar(Context context, AttributeSet attrs) { | 62 public ChromeShellToolbar(Context context, AttributeSet attrs) { |
63 super(context, attrs); | 63 super(context, attrs); |
64 // When running performance benchmark, we don't want to observe the tab | 64 // When running performance benchmark, we don't want to observe the tab |
65 // invalidation which would interfere with browser's processing content | 65 // invalidation which would interfere with browser's processing content |
66 // frame. See crbug.com/394976. | 66 // frame. See crbug.com/394976. |
(...skipping 16 matching lines...) Expand all Loading... |
83 mUrlTextView.setText(mTab.getContentViewCore().getUrl()); | 83 mUrlTextView.setText(mTab.getContentViewCore().getUrl()); |
84 } | 84 } |
85 | 85 |
86 private void onUpdateUrl(String url) { | 86 private void onUpdateUrl(String url) { |
87 mUrlTextView.setText(url); | 87 mUrlTextView.setText(url); |
88 } | 88 } |
89 | 89 |
90 private void onLoadProgressChanged(int progress) { | 90 private void onLoadProgressChanged(int progress) { |
91 removeCallbacks(mClearProgressRunnable); | 91 removeCallbacks(mClearProgressRunnable); |
92 mProgressDrawable.setLevel(100 * progress); | 92 mProgressDrawable.setLevel(100 * progress); |
93 boolean isLoading = progress != 100; | 93 mLoading = progress != 100; |
94 mStopButton.setVisibility(isLoading ? VISIBLE : GONE); | 94 if (mLoading) { |
95 mReloadButton.setVisibility(isLoading ? GONE : VISIBLE); | 95 mStopReloadButton.setImageResource(R.drawable.btn_stop_normal); |
96 if (!isLoading) postDelayed(mClearProgressRunnable, COMPLETED_PROGRESS_T
IMEOUT_MS); | 96 } else { |
| 97 mStopReloadButton.setImageResource(R.drawable.btn_reload_normal); |
| 98 postDelayed(mClearProgressRunnable, COMPLETED_PROGRESS_TIMEOUT_MS); |
| 99 } |
97 } | 100 } |
98 | 101 |
99 /** | 102 /** |
100 * Closes the suggestion popup. | 103 * Closes the suggestion popup. |
101 */ | 104 */ |
102 public void hideSuggestions() { | 105 public void hideSuggestions() { |
103 if (mSuggestionPopup != null) mSuggestionPopup.hideSuggestions(); | 106 if (mSuggestionPopup != null) mSuggestionPopup.hideSuggestions(); |
104 } | 107 } |
105 | 108 |
106 @Override | 109 @Override |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 }); | 178 }); |
176 menuButton.setOnTouchListener(new OnTouchListener() { | 179 menuButton.setOnTouchListener(new OnTouchListener() { |
177 @Override | 180 @Override |
178 public boolean onTouch(View view, MotionEvent event) { | 181 public boolean onTouch(View view, MotionEvent event) { |
179 return mAppMenuButtonHelper != null && mAppMenuButtonHelper.onTo
uch(view, event); | 182 return mAppMenuButtonHelper != null && mAppMenuButtonHelper.onTo
uch(view, event); |
180 } | 183 } |
181 }); | 184 }); |
182 } | 185 } |
183 | 186 |
184 private void initializeStopReloadButton() { | 187 private void initializeStopReloadButton() { |
185 mStopButton = (ImageButton)findViewById(R.id.stop); | 188 mStopReloadButton = (ImageButton)findViewById(R.id.stop_reload_button); |
186 mStopButton.setOnClickListener(new OnClickListener() { | 189 mStopReloadButton.setOnClickListener(new OnClickListener() { |
187 @Override | 190 @Override |
188 public void onClick(View v) { | 191 public void onClick(View v) { |
189 mTab.getContentViewCore().stopLoading(); | 192 if (mLoading) { |
190 } | 193 mTab.getContentViewCore().stopLoading(); |
191 }); | 194 } else { |
192 mReloadButton = (ImageButton)findViewById(R.id.reload); | 195 mTab.getContentViewCore().reload(true); |
193 mReloadButton.setOnClickListener(new OnClickListener() { | 196 } |
194 @Override | |
195 public void onClick(View v) { | |
196 mTab.getContentViewCore().reload(true); | |
197 } | 197 } |
198 }); | 198 }); |
199 } | 199 } |
200 | 200 |
201 /** | 201 /** |
202 * @return Current tab that is shown by ChromeShell. | 202 * @return Current tab that is shown by ChromeShell. |
203 */ | 203 */ |
204 public ChromeShellTab getCurrentTab() { | 204 public ChromeShellTab getCurrentTab() { |
205 return mTab; | 205 return mTab; |
206 } | 206 } |
(...skipping 23 matching lines...) Expand all Loading... |
230 public void onLoadProgressChanged(Tab tab, int progress) { | 230 public void onLoadProgressChanged(Tab tab, int progress) { |
231 if (tab == mTab) ChromeShellToolbar.this.onLoadProgressChanged(progr
ess); | 231 if (tab == mTab) ChromeShellToolbar.this.onLoadProgressChanged(progr
ess); |
232 } | 232 } |
233 | 233 |
234 @Override | 234 @Override |
235 public void onUpdateUrl(Tab tab, String url) { | 235 public void onUpdateUrl(Tab tab, String url) { |
236 if (tab == mTab) ChromeShellToolbar.this.onUpdateUrl(url); | 236 if (tab == mTab) ChromeShellToolbar.this.onUpdateUrl(url); |
237 } | 237 } |
238 } | 238 } |
239 } | 239 } |
OLD | NEW |