| 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.CompositorProvider; |
| 24 import org.chromium.content.browser.ContentView; | 25 import org.chromium.content.browser.ContentView; |
| 25 import org.chromium.content.browser.ContentViewRenderView; | 26 import org.chromium.content.browser.ContentViewRenderView; |
| 26 import org.chromium.content.browser.LoadUrlParams; | 27 import org.chromium.content.browser.LoadUrlParams; |
| 27 import org.chromium.ui.WindowAndroid; | 28 import org.chromium.ui.WindowAndroid; |
| 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 { |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 mLoading = loading; | 210 mLoading = loading; |
| 210 } | 211 } |
| 211 | 212 |
| 212 /** | 213 /** |
| 213 * Initializes the ContentView based on the native tab contents pointer pass
ed in. | 214 * Initializes the ContentView based on the native tab contents pointer pass
ed in. |
| 214 * @param nativeTabContents The pointer to the native tab contents object. | 215 * @param nativeTabContents The pointer to the native tab contents object. |
| 215 */ | 216 */ |
| 216 @SuppressWarnings("unused") | 217 @SuppressWarnings("unused") |
| 217 @CalledByNative | 218 @CalledByNative |
| 218 private void initFromNativeTabContents(int nativeTabContents) { | 219 private void initFromNativeTabContents(int nativeTabContents) { |
| 219 mContentView = ContentView.newInstance(getContext(), nativeTabContents,
mWindow); | 220 CompositorProvider compositorProvider = mContentViewRenderView; |
| 221 mContentView = ContentView.newInstance(getContext(), nativeTabContents,
mWindow, |
| 222 compositorProvider); |
| 220 if (mContentView.getUrl() != null) mUrlTextView.setText(mContentView.get
Url()); | 223 if (mContentView.getUrl() != null) mUrlTextView.setText(mContentView.get
Url()); |
| 221 ((FrameLayout) findViewById(R.id.contentview_holder)).addView(mContentVi
ew, | 224 ((FrameLayout) findViewById(R.id.contentview_holder)).addView(mContentVi
ew, |
| 222 new FrameLayout.LayoutParams( | 225 new FrameLayout.LayoutParams( |
| 223 FrameLayout.LayoutParams.MATCH_PARENT, | 226 FrameLayout.LayoutParams.MATCH_PARENT, |
| 224 FrameLayout.LayoutParams.MATCH_PARENT)); | 227 FrameLayout.LayoutParams.MATCH_PARENT)); |
| 225 mContentView.requestFocus(); | 228 mContentView.requestFocus(); |
| 226 mContentViewRenderView.setCurrentContentView(mContentView); | 229 mContentViewRenderView.setCurrentContentView(mContentView); |
| 227 } | 230 } |
| 228 | 231 |
| 229 /** | 232 /** |
| 230 * @return The {@link ContentView} currently shown by this Shell. | 233 * @return The {@link ContentView} currently shown by this Shell. |
| 231 */ | 234 */ |
| 232 public ContentView getContentView() { | 235 public ContentView getContentView() { |
| 233 return mContentView; | 236 return mContentView; |
| 234 } | 237 } |
| 235 | 238 |
| 236 private void setKeyboardVisibilityForUrl(boolean visible) { | 239 private void setKeyboardVisibilityForUrl(boolean visible) { |
| 237 InputMethodManager imm = (InputMethodManager) getContext().getSystemServ
ice( | 240 InputMethodManager imm = (InputMethodManager) getContext().getSystemServ
ice( |
| 238 Context.INPUT_METHOD_SERVICE); | 241 Context.INPUT_METHOD_SERVICE); |
| 239 if (visible) { | 242 if (visible) { |
| 240 imm.showSoftInput(mUrlTextView, InputMethodManager.SHOW_IMPLICIT); | 243 imm.showSoftInput(mUrlTextView, InputMethodManager.SHOW_IMPLICIT); |
| 241 } else { | 244 } else { |
| 242 imm.hideSoftInputFromWindow(mUrlTextView.getWindowToken(), 0); | 245 imm.hideSoftInputFromWindow(mUrlTextView.getWindowToken(), 0); |
| 243 } | 246 } |
| 244 } | 247 } |
| 245 } | 248 } |
| OLD | NEW |