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; |
11 import android.util.AttributeSet; | 11 import android.util.AttributeSet; |
12 import android.view.KeyEvent; | 12 import android.view.KeyEvent; |
13 import android.view.MotionEvent; | 13 import android.view.MotionEvent; |
14 import android.view.View; | 14 import android.view.View; |
15 import android.view.inputmethod.EditorInfo; | 15 import android.view.inputmethod.EditorInfo; |
16 import android.view.inputmethod.InputMethodManager; | 16 import android.view.inputmethod.InputMethodManager; |
17 import android.widget.EditText; | 17 import android.widget.EditText; |
18 import android.widget.ImageButton; | 18 import android.widget.ImageButton; |
19 import android.widget.LinearLayout; | 19 import android.widget.LinearLayout; |
20 import android.widget.TextView; | 20 import android.widget.TextView; |
21 import android.widget.TextView.OnEditorActionListener; | 21 import android.widget.TextView.OnEditorActionListener; |
22 | 22 |
23 import org.chromium.base.ApiCompatibilityUtils; | 23 import org.chromium.base.ApiCompatibilityUtils; |
24 import org.chromium.base.CommandLine; | 24 import org.chromium.base.CommandLine; |
25 import org.chromium.chrome.browser.EmptyTabObserver; | 25 import org.chromium.chrome.browser.EmptyTabObserver; |
26 import org.chromium.chrome.browser.Tab; | 26 import org.chromium.chrome.browser.Tab; |
27 import org.chromium.chrome.browser.TabObserver; | 27 import org.chromium.chrome.browser.TabObserver; |
| 28 import org.chromium.chrome.browser.UrlUtilities; |
28 import org.chromium.chrome.browser.appmenu.AppMenuButtonHelper; | 29 import org.chromium.chrome.browser.appmenu.AppMenuButtonHelper; |
29 import org.chromium.chrome.browser.appmenu.AppMenuHandler; | 30 import org.chromium.chrome.browser.appmenu.AppMenuHandler; |
30 import org.chromium.chrome.shell.omnibox.SuggestionPopup; | 31 import org.chromium.chrome.shell.omnibox.SuggestionPopup; |
31 import org.chromium.content.common.ContentSwitches; | 32 import org.chromium.content.common.ContentSwitches; |
32 | 33 |
33 /** | 34 /** |
34 * A Toolbar {@link View} that shows the URL and navigation buttons. | 35 * A Toolbar {@link View} that shows the URL and navigation buttons. |
35 */ | 36 */ |
36 public class ChromeShellToolbar extends LinearLayout { | 37 public class ChromeShellToolbar extends LinearLayout { |
37 private static final long COMPLETED_PROGRESS_TIMEOUT_MS = 200; | 38 private static final long COMPLETED_PROGRESS_TIMEOUT_MS = 200; |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 @Override | 158 @Override |
158 public boolean onEditorAction(TextView v, int actionId, KeyEvent eve
nt) { | 159 public boolean onEditorAction(TextView v, int actionId, KeyEvent eve
nt) { |
159 if ((actionId != EditorInfo.IME_ACTION_GO) && (event == null | 160 if ((actionId != EditorInfo.IME_ACTION_GO) && (event == null |
160 || event.getKeyCode() != KeyEvent.KEYCODE_ENTER | 161 || event.getKeyCode() != KeyEvent.KEYCODE_ENTER |
161 || event.getAction() != KeyEvent.ACTION_DOWN)) { | 162 || event.getAction() != KeyEvent.ACTION_DOWN)) { |
162 return false; | 163 return false; |
163 } | 164 } |
164 | 165 |
165 // This will set |mTab| by calling showTab(). | 166 // This will set |mTab| by calling showTab(). |
166 // TODO(aurimas): Factor out initial tab creation to the activit
y level. | 167 // TODO(aurimas): Factor out initial tab creation to the activit
y level. |
167 Tab tab = mTabManager.openUrl(mUrlTextView.getText().toString())
; | 168 Tab tab = mTabManager.openUrl( |
| 169 UrlUtilities.fixupUrl(mUrlTextView.getText().toString())
); |
168 mUrlTextView.clearFocus(); | 170 mUrlTextView.clearFocus(); |
169 setKeyboardVisibilityForUrl(false); | 171 setKeyboardVisibilityForUrl(false); |
170 tab.getView().requestFocus(); | 172 tab.getView().requestFocus(); |
171 return true; | 173 return true; |
172 } | 174 } |
173 }); | 175 }); |
174 mUrlTextView.setOnFocusChangeListener(new OnFocusChangeListener() { | 176 mUrlTextView.setOnFocusChangeListener(new OnFocusChangeListener() { |
175 @Override | 177 @Override |
176 public void onFocusChange(View v, boolean hasFocus) { | 178 public void onFocusChange(View v, boolean hasFocus) { |
177 setKeyboardVisibilityForUrl(hasFocus); | 179 setKeyboardVisibilityForUrl(hasFocus); |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 public void onLoadProgressChanged(Tab tab, int progress) { | 276 public void onLoadProgressChanged(Tab tab, int progress) { |
275 if (tab == mTab) ChromeShellToolbar.this.onLoadProgressChanged(progr
ess); | 277 if (tab == mTab) ChromeShellToolbar.this.onLoadProgressChanged(progr
ess); |
276 } | 278 } |
277 | 279 |
278 @Override | 280 @Override |
279 public void onUpdateUrl(Tab tab, String url) { | 281 public void onUpdateUrl(Tab tab, String url) { |
280 if (tab == mTab) ChromeShellToolbar.this.onUpdateUrl(url); | 282 if (tab == mTab) ChromeShellToolbar.this.onUpdateUrl(url); |
281 } | 283 } |
282 } | 284 } |
283 } | 285 } |
OLD | NEW |