Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(404)

Side by Side Diff: content/shell/android/java/src/org/chromium/content_shell/Shell.java

Issue 2595263002: Introduce ViewRoot forwarding input/view events to native (Closed)
Patch Set: unittest Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 19 matching lines...) Expand all
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.ContentViewClient;
33 import org.chromium.content.browser.ContentViewCore; 33 import org.chromium.content.browser.ContentViewCore;
34 import org.chromium.content.browser.ContentViewRenderView; 34 import org.chromium.content.browser.ContentViewRenderView;
35 import org.chromium.content_public.browser.ActionModeCallbackHelper; 35 import org.chromium.content_public.browser.ActionModeCallbackHelper;
36 import org.chromium.content_public.browser.LoadUrlParams; 36 import org.chromium.content_public.browser.LoadUrlParams;
37 import org.chromium.content_public.browser.NavigationController; 37 import org.chromium.content_public.browser.NavigationController;
38 import org.chromium.content_public.browser.WebContents; 38 import org.chromium.content_public.browser.WebContents;
39 import org.chromium.ui.base.ViewAndroidDelegate; 39 import org.chromium.ui.base.ViewAndroidDelegate;
40 import org.chromium.ui.base.WindowAndroid; 40 import org.chromium.ui.base.ViewRoot;
41 41
42 /** 42 /**
43 * Container for the various UI components that make up a shell window. 43 * Container for the various UI components that make up a shell window.
44 */ 44 */
45 @JNINamespace("content") 45 @JNINamespace("content")
46 public class Shell extends LinearLayout { 46 public class Shell extends LinearLayout {
47 47
48 private static final long COMPLETED_PROGRESS_TIMEOUT_MS = 200; 48 private static final long COMPLETED_PROGRESS_TIMEOUT_MS = 200;
49 49
50 private final Runnable mClearProgressRunnable = new Runnable() { 50 private final Runnable mClearProgressRunnable = new Runnable() {
51 @Override 51 @Override
52 public void run() { 52 public void run() {
53 mProgressDrawable.setLevel(0); 53 mProgressDrawable.setLevel(0);
54 } 54 }
55 }; 55 };
56 56
57 private ContentViewCore mContentViewCore; 57 private ContentViewCore mContentViewCore;
58 private WebContents mWebContents; 58 private WebContents mWebContents;
59 private NavigationController mNavigationController; 59 private NavigationController mNavigationController;
60 private ContentViewClient mContentViewClient; 60 private ContentViewClient mContentViewClient;
61 private EditText mUrlTextView; 61 private EditText mUrlTextView;
62 private ImageButton mPrevButton; 62 private ImageButton mPrevButton;
63 private ImageButton mNextButton; 63 private ImageButton mNextButton;
64 private ImageButton mStopReloadButton; 64 private ImageButton mStopReloadButton;
65 65
66 private ClipDrawable mProgressDrawable; 66 private ClipDrawable mProgressDrawable;
67 67
68 private long mNativeShell; 68 private long mNativeShell;
69 private ContentViewRenderView mContentViewRenderView; 69 private ContentViewRenderView mContentViewRenderView;
70 private WindowAndroid mWindow; 70 private ViewRoot mViewRoot;
71 71
72 private boolean mLoading; 72 private boolean mLoading;
73 private boolean mIsFullscreen; 73 private boolean mIsFullscreen;
74 74
75 /** 75 /**
76 * Constructor for inflating via XML. 76 * Constructor for inflating via XML.
77 */ 77 */
78 public Shell(Context context, AttributeSet attrs) { 78 public Shell(Context context, AttributeSet attrs) {
79 super(context, attrs); 79 super(context, attrs);
80 } 80 }
(...skipping 13 matching lines...) Expand all
94 FrameLayout.LayoutParams.MATCH_PARENT, 94 FrameLayout.LayoutParams.MATCH_PARENT,
95 FrameLayout.LayoutParams.MATCH_PARENT)); 95 FrameLayout.LayoutParams.MATCH_PARENT));
96 } 96 }
97 mContentViewRenderView = contentViewRenderView; 97 mContentViewRenderView = contentViewRenderView;
98 } 98 }
99 99
100 /** 100 /**
101 * Initializes the Shell for use. 101 * Initializes the Shell for use.
102 * 102 *
103 * @param nativeShell The pointer to the native Shell object. 103 * @param nativeShell The pointer to the native Shell object.
104 * @param window The owning window for this shell. 104 * @param viewRoot {@link ViewRoot} used to forward events to native.
105 * @param client The {@link ContentViewClient} to be bound to any current or new 105 * @param client The {@link ContentViewClient} to be bound to any current or new
106 * {@link ContentViewCore}s associated with this shell. 106 * {@link ContentViewCore}s associated with this shell.
107 */ 107 */
108 public void initialize(long nativeShell, WindowAndroid window, ContentViewCl ient client) { 108 public void initialize(long nativeShell, ViewRoot viewRoot, ContentViewClien t client) {
109 mNativeShell = nativeShell; 109 mNativeShell = nativeShell;
110 mWindow = window; 110 mViewRoot = viewRoot;
111 mContentViewClient = client; 111 mContentViewClient = client;
112 } 112 }
113 113
114 /** 114 /**
115 * 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
116 * dependencies. 116 * dependencies.
117 */ 117 */
118 public void close() { 118 public void close() {
119 if (mNativeShell == 0) return; 119 if (mNativeShell == 0) return;
120 nativeCloseShell(mNativeShell); 120 nativeCloseShell(mNativeShell);
121 } 121 }
122 122
123 @CalledByNative 123 @CalledByNative
124 private void onNativeDestroyed() { 124 private void onNativeDestroyed() {
125 mWindow = null;
126 mNativeShell = 0; 125 mNativeShell = 0;
127 mContentViewCore.destroy(); 126 mContentViewCore.destroy();
128 } 127 }
129 128
130 /** 129 /**
131 * @return Whether the Shell has been destroyed. 130 * @return Whether the Shell has been destroyed.
132 * @see #onNativeDestroyed() 131 * @see #onNativeDestroyed()
133 */ 132 */
134 public boolean isDestroyed() { 133 public boolean isDestroyed() {
135 return mNativeShell == 0; 134 return mNativeShell == 0;
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 * Initializes the ContentView based on the native tab contents pointer pass ed in. 289 * Initializes the ContentView based on the native tab contents pointer pass ed in.
291 * @param webContents A {@link WebContents} object. 290 * @param webContents A {@link WebContents} object.
292 */ 291 */
293 @SuppressWarnings("unused") 292 @SuppressWarnings("unused")
294 @CalledByNative 293 @CalledByNative
295 private void initFromNativeTabContents(WebContents webContents) { 294 private void initFromNativeTabContents(WebContents webContents) {
296 Context context = getContext(); 295 Context context = getContext();
297 mContentViewCore = new ContentViewCore(context, ""); 296 mContentViewCore = new ContentViewCore(context, "");
298 ContentView cv = ContentView.createContentView(context, mContentViewCore ); 297 ContentView cv = ContentView.createContentView(context, mContentViewCore );
299 mContentViewCore.initialize(ViewAndroidDelegate.createBasicDelegate(cv), cv, 298 mContentViewCore.initialize(ViewAndroidDelegate.createBasicDelegate(cv), cv,
300 webContents, mWindow); 299 webContents, mViewRoot);
301 mContentViewCore.setActionModeCallback(defaultActionCallback()); 300 mContentViewCore.setActionModeCallback(defaultActionCallback());
302 mContentViewCore.setContentViewClient(mContentViewClient); 301 mContentViewCore.setContentViewClient(mContentViewClient);
303 mWebContents = mContentViewCore.getWebContents(); 302 mWebContents = mContentViewCore.getWebContents();
304 mNavigationController = mWebContents.getNavigationController(); 303 mNavigationController = mWebContents.getNavigationController();
305 if (getParent() != null) mContentViewCore.onShow(); 304 if (getParent() != null) mContentViewCore.onShow();
306 if (mWebContents.getUrl() != null) { 305 if (mWebContents.getUrl() != null) {
307 mUrlTextView.setText(mWebContents.getUrl()); 306 mUrlTextView.setText(mWebContents.getUrl());
308 } 307 }
309 ((FrameLayout) findViewById(R.id.contentview_holder)).addView(cv, 308 ((FrameLayout) findViewById(R.id.contentview_holder)).addView(cv,
310 new FrameLayout.LayoutParams( 309 new FrameLayout.LayoutParams(
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 Context.INPUT_METHOD_SERVICE); 403 Context.INPUT_METHOD_SERVICE);
405 if (visible) { 404 if (visible) {
406 imm.showSoftInput(mUrlTextView, InputMethodManager.SHOW_IMPLICIT); 405 imm.showSoftInput(mUrlTextView, InputMethodManager.SHOW_IMPLICIT);
407 } else { 406 } else {
408 imm.hideSoftInputFromWindow(mUrlTextView.getWindowToken(), 0); 407 imm.hideSoftInputFromWindow(mUrlTextView.getWindowToken(), 0);
409 } 408 }
410 } 409 }
411 410
412 private static native void nativeCloseShell(long shellPtr); 411 private static native void nativeCloseShell(long shellPtr);
413 } 412 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698