| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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.app.Activity; | 7 import android.app.Activity; |
| 8 import android.content.Context; | 8 import android.content.Context; |
| 9 import android.graphics.drawable.ClipDrawable; | 9 import android.graphics.drawable.ClipDrawable; |
| 10 import android.text.TextUtils; | 10 import android.text.TextUtils; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 import android.widget.ImageButton; | 22 import android.widget.ImageButton; |
| 23 import android.widget.LinearLayout; | 23 import android.widget.LinearLayout; |
| 24 import android.widget.TextView; | 24 import android.widget.TextView; |
| 25 import android.widget.TextView.OnEditorActionListener; | 25 import android.widget.TextView.OnEditorActionListener; |
| 26 | 26 |
| 27 import org.chromium.base.annotations.CalledByNative; | 27 import org.chromium.base.annotations.CalledByNative; |
| 28 import org.chromium.base.annotations.JNINamespace; | 28 import org.chromium.base.annotations.JNINamespace; |
| 29 import org.chromium.content.browser.ActivityContentVideoViewEmbedder; | 29 import org.chromium.content.browser.ActivityContentVideoViewEmbedder; |
| 30 import org.chromium.content.browser.ContentVideoViewEmbedder; | 30 import org.chromium.content.browser.ContentVideoViewEmbedder; |
| 31 import org.chromium.content.browser.ContentView; | 31 import org.chromium.content.browser.ContentView; |
| 32 import org.chromium.content.browser.ContentViewClient; |
| 32 import org.chromium.content.browser.ContentViewCore; | 33 import org.chromium.content.browser.ContentViewCore; |
| 33 import org.chromium.content.browser.ContentViewRenderView; | 34 import org.chromium.content.browser.ContentViewRenderView; |
| 34 import org.chromium.content_public.browser.ActionModeCallbackHelper; | 35 import org.chromium.content_public.browser.ActionModeCallbackHelper; |
| 35 import org.chromium.content_public.browser.LoadUrlParams; | 36 import org.chromium.content_public.browser.LoadUrlParams; |
| 36 import org.chromium.content_public.browser.NavigationController; | 37 import org.chromium.content_public.browser.NavigationController; |
| 37 import org.chromium.content_public.browser.WebContents; | 38 import org.chromium.content_public.browser.WebContents; |
| 38 import org.chromium.ui.base.WindowAndroid; | 39 import org.chromium.ui.base.WindowAndroid; |
| 39 | 40 |
| 40 /** | 41 /** |
| 41 * Container for the various UI components that make up a shell window. | 42 * Container for the various UI components that make up a shell window. |
| 42 */ | 43 */ |
| 43 @JNINamespace("content") | 44 @JNINamespace("content") |
| 44 public class Shell extends LinearLayout { | 45 public class Shell extends LinearLayout { |
| 45 | 46 |
| 46 private static final long COMPLETED_PROGRESS_TIMEOUT_MS = 200; | 47 private static final long COMPLETED_PROGRESS_TIMEOUT_MS = 200; |
| 47 | 48 |
| 48 private final Runnable mClearProgressRunnable = new Runnable() { | 49 private final Runnable mClearProgressRunnable = new Runnable() { |
| 49 @Override | 50 @Override |
| 50 public void run() { | 51 public void run() { |
| 51 mProgressDrawable.setLevel(0); | 52 mProgressDrawable.setLevel(0); |
| 52 } | 53 } |
| 53 }; | 54 }; |
| 54 | 55 |
| 55 private ContentViewCore mContentViewCore; | 56 private ContentViewCore mContentViewCore; |
| 56 private WebContents mWebContents; | 57 private WebContents mWebContents; |
| 57 private NavigationController mNavigationController; | 58 private NavigationController mNavigationController; |
| 59 private ContentViewClient mContentViewClient; |
| 58 private EditText mUrlTextView; | 60 private EditText mUrlTextView; |
| 59 private ImageButton mPrevButton; | 61 private ImageButton mPrevButton; |
| 60 private ImageButton mNextButton; | 62 private ImageButton mNextButton; |
| 61 private ImageButton mStopReloadButton; | 63 private ImageButton mStopReloadButton; |
| 62 | 64 |
| 63 private ClipDrawable mProgressDrawable; | 65 private ClipDrawable mProgressDrawable; |
| 64 | 66 |
| 65 private long mNativeShell; | 67 private long mNativeShell; |
| 66 private ContentViewRenderView mContentViewRenderView; | 68 private ContentViewRenderView mContentViewRenderView; |
| 67 private WindowAndroid mWindow; | 69 private WindowAndroid mWindow; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 93 FrameLayout.LayoutParams.MATCH_PARENT)); | 95 FrameLayout.LayoutParams.MATCH_PARENT)); |
| 94 } | 96 } |
| 95 mContentViewRenderView = contentViewRenderView; | 97 mContentViewRenderView = contentViewRenderView; |
| 96 } | 98 } |
| 97 | 99 |
| 98 /** | 100 /** |
| 99 * Initializes the Shell for use. | 101 * Initializes the Shell for use. |
| 100 * | 102 * |
| 101 * @param nativeShell The pointer to the native Shell object. | 103 * @param nativeShell The pointer to the native Shell object. |
| 102 * @param window The owning window for this shell. | 104 * @param window The owning window for this shell. |
| 105 * @param client The {@link ContentViewClient} to be bound to any current or
new |
| 106 * {@link ContentViewCore}s associated with this shell. |
| 103 */ | 107 */ |
| 104 public void initialize(long nativeShell, WindowAndroid window) { | 108 public void initialize(long nativeShell, WindowAndroid window, ContentViewCl
ient client) { |
| 105 mNativeShell = nativeShell; | 109 mNativeShell = nativeShell; |
| 106 mWindow = window; | 110 mWindow = window; |
| 111 mContentViewClient = client; |
| 107 } | 112 } |
| 108 | 113 |
| 109 /** | 114 /** |
| 110 * Closes the shell and cleans up the native instance, which will handle des
troying all | 115 * Closes the shell and cleans up the native instance, which will handle des
troying all |
| 111 * dependencies. | 116 * dependencies. |
| 112 */ | 117 */ |
| 113 public void close() { | 118 public void close() { |
| 114 if (mNativeShell == 0) return; | 119 if (mNativeShell == 0) return; |
| 115 nativeCloseShell(mNativeShell); | 120 nativeCloseShell(mNativeShell); |
| 116 } | 121 } |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 */ | 296 */ |
| 292 @SuppressWarnings("unused") | 297 @SuppressWarnings("unused") |
| 293 @CalledByNative | 298 @CalledByNative |
| 294 private void initFromNativeTabContents(WebContents webContents) { | 299 private void initFromNativeTabContents(WebContents webContents) { |
| 295 Context context = getContext(); | 300 Context context = getContext(); |
| 296 mContentViewCore = new ContentViewCore(context, ""); | 301 mContentViewCore = new ContentViewCore(context, ""); |
| 297 ContentView cv = ContentView.createContentView(context, mContentViewCore
); | 302 ContentView cv = ContentView.createContentView(context, mContentViewCore
); |
| 298 mViewAndroidDelegate = new ShellViewAndroidDelegate(cv); | 303 mViewAndroidDelegate = new ShellViewAndroidDelegate(cv); |
| 299 mContentViewCore.initialize(mViewAndroidDelegate, cv, webContents, mWind
ow); | 304 mContentViewCore.initialize(mViewAndroidDelegate, cv, webContents, mWind
ow); |
| 300 mContentViewCore.setActionModeCallback(defaultActionCallback()); | 305 mContentViewCore.setActionModeCallback(defaultActionCallback()); |
| 306 mContentViewCore.setContentViewClient(mContentViewClient); |
| 301 mWebContents = mContentViewCore.getWebContents(); | 307 mWebContents = mContentViewCore.getWebContents(); |
| 302 mNavigationController = mWebContents.getNavigationController(); | 308 mNavigationController = mWebContents.getNavigationController(); |
| 303 if (getParent() != null) mContentViewCore.onShow(); | 309 if (getParent() != null) mContentViewCore.onShow(); |
| 304 if (mWebContents.getUrl() != null) { | 310 if (mWebContents.getUrl() != null) { |
| 305 mUrlTextView.setText(mWebContents.getUrl()); | 311 mUrlTextView.setText(mWebContents.getUrl()); |
| 306 } | 312 } |
| 307 ((FrameLayout) findViewById(R.id.contentview_holder)).addView(cv, | 313 ((FrameLayout) findViewById(R.id.contentview_holder)).addView(cv, |
| 308 new FrameLayout.LayoutParams( | 314 new FrameLayout.LayoutParams( |
| 309 FrameLayout.LayoutParams.MATCH_PARENT, | 315 FrameLayout.LayoutParams.MATCH_PARENT, |
| 310 FrameLayout.LayoutParams.MATCH_PARENT)); | 316 FrameLayout.LayoutParams.MATCH_PARENT)); |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 Context.INPUT_METHOD_SERVICE); | 412 Context.INPUT_METHOD_SERVICE); |
| 407 if (visible) { | 413 if (visible) { |
| 408 imm.showSoftInput(mUrlTextView, InputMethodManager.SHOW_IMPLICIT); | 414 imm.showSoftInput(mUrlTextView, InputMethodManager.SHOW_IMPLICIT); |
| 409 } else { | 415 } else { |
| 410 imm.hideSoftInputFromWindow(mUrlTextView.getWindowToken(), 0); | 416 imm.hideSoftInputFromWindow(mUrlTextView.getWindowToken(), 0); |
| 411 } | 417 } |
| 412 } | 418 } |
| 413 | 419 |
| 414 private static native void nativeCloseShell(long shellPtr); | 420 private static native void nativeCloseShell(long shellPtr); |
| 415 } | 421 } |
| OLD | NEW |