OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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.content_shell; | 5 package org.chromium.content_shell; |
6 | 6 |
7 import android.content.Context; | 7 import android.content.Context; |
8 import android.graphics.drawable.ClipDrawable; | 8 import android.graphics.drawable.ClipDrawable; |
9 import android.text.TextUtils; | 9 import android.text.TextUtils; |
10 import android.util.AttributeSet; | 10 import android.util.AttributeSet; |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
139 */ | 139 */ |
140 public void loadUrl(String url) { | 140 public void loadUrl(String url) { |
141 if (url == null) return; | 141 if (url == null) return; |
142 | 142 |
143 if (TextUtils.equals(url, mContentView.getUrl())) { | 143 if (TextUtils.equals(url, mContentView.getUrl())) { |
144 mContentView.reload(); | 144 mContentView.reload(); |
145 } else { | 145 } else { |
146 mContentView.loadUrl(new LoadUrlParams(sanitizeUrl(url))); | 146 mContentView.loadUrl(new LoadUrlParams(sanitizeUrl(url))); |
147 } | 147 } |
148 mUrlTextView.clearFocus(); | 148 mUrlTextView.clearFocus(); |
149 mContentView.clearFocus(); | |
Ted C
2013/02/06 00:59:00
why is clearFocus/requestFocus required? Add comm
aurimas (slooooooooow)
2013/02/06 02:25:44
Done.
| |
150 mContentView.requestFocus(); | |
149 } | 151 } |
150 | 152 |
151 /** | 153 /** |
152 * Given an URL, this performs minimal sanitizing to ensure it will be valid . | 154 * Given an URL, this performs minimal sanitizing to ensure it will be valid . |
153 * @param url The url to be sanitized. | 155 * @param url The url to be sanitized. |
154 * @return The sanitized URL. | 156 * @return The sanitized URL. |
155 */ | 157 */ |
156 public static String sanitizeUrl(String url) { | 158 public static String sanitizeUrl(String url) { |
157 if (url == null) return url; | 159 if (url == null) return url; |
158 if (url.startsWith("www.") || url.indexOf(":") == -1) url = "http://" + url; | 160 if (url.startsWith("www.") || url.indexOf(":") == -1) url = "http://" + url; |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
234 private void setKeyboardVisibilityForUrl(boolean visible) { | 236 private void setKeyboardVisibilityForUrl(boolean visible) { |
235 InputMethodManager imm = (InputMethodManager) getContext().getSystemServ ice( | 237 InputMethodManager imm = (InputMethodManager) getContext().getSystemServ ice( |
236 Context.INPUT_METHOD_SERVICE); | 238 Context.INPUT_METHOD_SERVICE); |
237 if (visible) { | 239 if (visible) { |
238 imm.showSoftInput(mUrlTextView, InputMethodManager.SHOW_IMPLICIT); | 240 imm.showSoftInput(mUrlTextView, InputMethodManager.SHOW_IMPLICIT); |
239 } else { | 241 } else { |
240 imm.hideSoftInputFromWindow(mUrlTextView.getWindowToken(), 0); | 242 imm.hideSoftInputFromWindow(mUrlTextView.getWindowToken(), 0); |
241 } | 243 } |
242 } | 244 } |
243 } | 245 } |
OLD | NEW |