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