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.ContentViewRenderView; | 25 import org.chromium.content.browser.ContentViewRenderView; |
26 import org.chromium.content.browser.LoadUrlParams; | 26 import org.chromium.content.browser.LoadUrlParams; |
| 27 import org.chromium.content.common.ProcessInitException; |
27 import org.chromium.ui.gfx.NativeWindow; | 28 import org.chromium.ui.gfx.NativeWindow; |
28 | 29 |
29 /** | 30 /** |
30 * Container for the various UI components that make up a shell window. | 31 * Container for the various UI components that make up a shell window. |
31 */ | 32 */ |
32 @JNINamespace("content") | 33 @JNINamespace("content") |
33 public class Shell extends LinearLayout { | 34 public class Shell extends LinearLayout { |
34 | 35 |
35 private static final long COMPLETED_PROGRESS_TIMEOUT_MS = 200; | 36 private static final long COMPLETED_PROGRESS_TIMEOUT_MS = 200; |
36 | 37 |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 private void setIsLoading(boolean loading) { | 206 private void setIsLoading(boolean loading) { |
206 mLoading = loading; | 207 mLoading = loading; |
207 } | 208 } |
208 | 209 |
209 /** | 210 /** |
210 * Initializes the ContentView based on the native tab contents pointer pass
ed in. | 211 * Initializes the ContentView based on the native tab contents pointer pass
ed in. |
211 * @param nativeTabContents The pointer to the native tab contents object. | 212 * @param nativeTabContents The pointer to the native tab contents object. |
212 */ | 213 */ |
213 @SuppressWarnings("unused") | 214 @SuppressWarnings("unused") |
214 @CalledByNative | 215 @CalledByNative |
215 private void initFromNativeTabContents(int nativeTabContents) { | 216 private void initFromNativeTabContents(int nativeTabContents) throws Process
InitException { |
216 mContentView = ContentView.newInstance( | 217 mContentView = ContentView.newInstance( |
217 getContext(), nativeTabContents, mWindow, ContentView.PERSONALIT
Y_CHROME); | 218 getContext(), nativeTabContents, mWindow, ContentView.PERSONALIT
Y_CHROME); |
218 if (mContentView.getUrl() != null) mUrlTextView.setText(mContentView.get
Url()); | 219 if (mContentView.getUrl() != null) mUrlTextView.setText(mContentView.get
Url()); |
219 ((FrameLayout) findViewById(R.id.contentview_holder)).addView(mContentVi
ew, | 220 ((FrameLayout) findViewById(R.id.contentview_holder)).addView(mContentVi
ew, |
220 new FrameLayout.LayoutParams( | 221 new FrameLayout.LayoutParams( |
221 FrameLayout.LayoutParams.MATCH_PARENT, | 222 FrameLayout.LayoutParams.MATCH_PARENT, |
222 FrameLayout.LayoutParams.MATCH_PARENT)); | 223 FrameLayout.LayoutParams.MATCH_PARENT)); |
223 mContentView.requestFocus(); | 224 mContentView.requestFocus(); |
224 mContentViewRenderView.setCurrentContentView(mContentView); | 225 mContentViewRenderView.setCurrentContentView(mContentView); |
225 } | 226 } |
226 | 227 |
227 /** | 228 /** |
228 * @return The {@link ContentView} currently shown by this Shell. | 229 * @return The {@link ContentView} currently shown by this Shell. |
229 */ | 230 */ |
230 public ContentView getContentView() { | 231 public ContentView getContentView() { |
231 return mContentView; | 232 return mContentView; |
232 } | 233 } |
233 | 234 |
234 private void setKeyboardVisibilityForUrl(boolean visible) { | 235 private void setKeyboardVisibilityForUrl(boolean visible) { |
235 InputMethodManager imm = (InputMethodManager) getContext().getSystemServ
ice( | 236 InputMethodManager imm = (InputMethodManager) getContext().getSystemServ
ice( |
236 Context.INPUT_METHOD_SERVICE); | 237 Context.INPUT_METHOD_SERVICE); |
237 if (visible) { | 238 if (visible) { |
238 imm.showSoftInput(mUrlTextView, InputMethodManager.SHOW_IMPLICIT); | 239 imm.showSoftInput(mUrlTextView, InputMethodManager.SHOW_IMPLICIT); |
239 } else { | 240 } else { |
240 imm.hideSoftInputFromWindow(mUrlTextView.getWindowToken(), 0); | 241 imm.hideSoftInputFromWindow(mUrlTextView.getWindowToken(), 0); |
241 } | 242 } |
242 } | 243 } |
243 } | 244 } |
OLD | NEW |