| 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 // TODO(aurimas): Remove this when crbug.com/174541 is fixed. |
| 150 mContentView.clearFocus(); |
| 151 mContentView.requestFocus(); |
| 149 } | 152 } |
| 150 | 153 |
| 151 /** | 154 /** |
| 152 * Given an URL, this performs minimal sanitizing to ensure it will be valid
. | 155 * Given an URL, this performs minimal sanitizing to ensure it will be valid
. |
| 153 * @param url The url to be sanitized. | 156 * @param url The url to be sanitized. |
| 154 * @return The sanitized URL. | 157 * @return The sanitized URL. |
| 155 */ | 158 */ |
| 156 public static String sanitizeUrl(String url) { | 159 public static String sanitizeUrl(String url) { |
| 157 if (url == null) return url; | 160 if (url == null) return url; |
| 158 if (url.startsWith("www.") || url.indexOf(":") == -1) url = "http://" +
url; | 161 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) { | 237 private void setKeyboardVisibilityForUrl(boolean visible) { |
| 235 InputMethodManager imm = (InputMethodManager) getContext().getSystemServ
ice( | 238 InputMethodManager imm = (InputMethodManager) getContext().getSystemServ
ice( |
| 236 Context.INPUT_METHOD_SERVICE); | 239 Context.INPUT_METHOD_SERVICE); |
| 237 if (visible) { | 240 if (visible) { |
| 238 imm.showSoftInput(mUrlTextView, InputMethodManager.SHOW_IMPLICIT); | 241 imm.showSoftInput(mUrlTextView, InputMethodManager.SHOW_IMPLICIT); |
| 239 } else { | 242 } else { |
| 240 imm.hideSoftInputFromWindow(mUrlTextView.getWindowToken(), 0); | 243 imm.hideSoftInputFromWindow(mUrlTextView.getWindowToken(), 0); |
| 241 } | 244 } |
| 242 } | 245 } |
| 243 } | 246 } |
| OLD | NEW |