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; |
11 import android.view.KeyEvent; | 11 import android.view.KeyEvent; |
12 import android.view.View; | 12 import android.view.View; |
13 import android.view.inputmethod.EditorInfo; | 13 import android.view.inputmethod.EditorInfo; |
14 import android.view.inputmethod.InputMethodManager; | 14 import android.view.inputmethod.InputMethodManager; |
15 import android.widget.EditText; | 15 import android.widget.EditText; |
16 import android.widget.FrameLayout; | 16 import android.widget.FrameLayout; |
17 import android.widget.ImageButton; | 17 import android.widget.ImageButton; |
18 import android.widget.LinearLayout; | 18 import android.widget.LinearLayout; |
19 import android.widget.TextView; | 19 import android.widget.TextView; |
20 import android.widget.TextView.OnEditorActionListener; | 20 import android.widget.TextView.OnEditorActionListener; |
21 | 21 |
22 import org.chromium.base.CalledByNative; | 22 import org.chromium.base.CalledByNative; |
23 import org.chromium.base.JNINamespace; | 23 import org.chromium.base.JNINamespace; |
24 import org.chromium.content.browser.ContentView; | 24 import org.chromium.content.browser.ContentView; |
| 25 import org.chromium.content.browser.LoadUrlParams; |
25 | 26 |
26 /** | 27 /** |
27 * Container for the various UI components that make up a shell window. | 28 * Container for the various UI components that make up a shell window. |
28 */ | 29 */ |
29 @JNINamespace("content") | 30 @JNINamespace("content") |
30 public class Shell extends LinearLayout { | 31 public class Shell extends LinearLayout { |
31 | 32 |
32 private static final long COMPLETED_PROGRESS_TIMEOUT_MS = 200; | 33 private static final long COMPLETED_PROGRESS_TIMEOUT_MS = 200; |
33 | 34 |
34 private Runnable mClearProgressRunnable = new Runnable() { | 35 private Runnable mClearProgressRunnable = new Runnable() { |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 * make it valid. | 110 * make it valid. |
110 * | 111 * |
111 * @param url The URL to be loaded by the shell. | 112 * @param url The URL to be loaded by the shell. |
112 */ | 113 */ |
113 public void loadUrl(String url) { | 114 public void loadUrl(String url) { |
114 if (url == null) return; | 115 if (url == null) return; |
115 | 116 |
116 if (TextUtils.equals(url, mContentView.getUrl())) { | 117 if (TextUtils.equals(url, mContentView.getUrl())) { |
117 mContentView.reload(); | 118 mContentView.reload(); |
118 } else { | 119 } else { |
119 mContentView.loadUrlWithoutUrlSanitization(sanitizeUrl(url)); | 120 mContentView.loadUrl(new LoadUrlParams(sanitizeUrl(url))); |
120 } | 121 } |
121 mUrlTextView.clearFocus(); | 122 mUrlTextView.clearFocus(); |
122 } | 123 } |
123 | 124 |
124 /** | 125 /** |
125 * Given an URL, this performs minimal sanitizing to ensure it will be valid
. | 126 * Given an URL, this performs minimal sanitizing to ensure it will be valid
. |
126 * @param url The url to be sanitized. | 127 * @param url The url to be sanitized. |
127 * @return The sanitized URL. | 128 * @return The sanitized URL. |
128 */ | 129 */ |
129 public static String sanitizeUrl(String url) { | 130 public static String sanitizeUrl(String url) { |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 private void setKeyboardVisibilityForUrl(boolean visible) { | 192 private void setKeyboardVisibilityForUrl(boolean visible) { |
192 InputMethodManager imm = (InputMethodManager) getContext().getSystemServ
ice( | 193 InputMethodManager imm = (InputMethodManager) getContext().getSystemServ
ice( |
193 Context.INPUT_METHOD_SERVICE); | 194 Context.INPUT_METHOD_SERVICE); |
194 if (visible) { | 195 if (visible) { |
195 imm.showSoftInput(mUrlTextView, InputMethodManager.SHOW_IMPLICIT); | 196 imm.showSoftInput(mUrlTextView, InputMethodManager.SHOW_IMPLICIT); |
196 } else { | 197 } else { |
197 imm.hideSoftInputFromWindow(mUrlTextView.getWindowToken(), 0); | 198 imm.hideSoftInputFromWindow(mUrlTextView.getWindowToken(), 0); |
198 } | 199 } |
199 } | 200 } |
200 } | 201 } |
OLD | NEW |