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

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

Issue 2688113002: Make ViewRoot the top of the ViewAndroid tree (Closed)
Patch Set: - Created 3 years, 10 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 18 matching lines...) Expand all
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.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.WindowAndroid; 39 import org.chromium.ui.base.ViewRoot;
40 40
41 /** 41 /**
42 * 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.
43 */ 43 */
44 @JNINamespace("content") 44 @JNINamespace("content")
45 public class Shell extends LinearLayout { 45 public class Shell extends LinearLayout {
46 46
47 private static final long COMPLETED_PROGRESS_TIMEOUT_MS = 200; 47 private static final long COMPLETED_PROGRESS_TIMEOUT_MS = 200;
48 48
49 private final Runnable mClearProgressRunnable = new Runnable() { 49 private final Runnable mClearProgressRunnable = new Runnable() {
50 @Override 50 @Override
51 public void run() { 51 public void run() {
52 mProgressDrawable.setLevel(0); 52 mProgressDrawable.setLevel(0);
53 } 53 }
54 }; 54 };
55 55
56 private ContentViewCore mContentViewCore; 56 private ContentViewCore mContentViewCore;
57 private WebContents mWebContents; 57 private WebContents mWebContents;
58 private NavigationController mNavigationController; 58 private NavigationController mNavigationController;
59 private ContentViewClient mContentViewClient; 59 private ContentViewClient mContentViewClient;
60 private EditText mUrlTextView; 60 private EditText mUrlTextView;
61 private ImageButton mPrevButton; 61 private ImageButton mPrevButton;
62 private ImageButton mNextButton; 62 private ImageButton mNextButton;
63 private ImageButton mStopReloadButton; 63 private ImageButton mStopReloadButton;
64 64
65 private ClipDrawable mProgressDrawable; 65 private ClipDrawable mProgressDrawable;
66 66
67 private long mNativeShell; 67 private long mNativeShell;
68 private ContentViewRenderView mContentViewRenderView; 68 private ContentViewRenderView mContentViewRenderView;
69 private WindowAndroid mWindow; 69 private ViewRoot mViewRoot;
70 private ShellViewAndroidDelegate mViewAndroidDelegate; 70 private ShellViewAndroidDelegate mViewAndroidDelegate;
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);
(...skipping 14 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 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 * Initializes the ContentView based on the native tab contents pointer pass ed in. 293 * Initializes the ContentView based on the native tab contents pointer pass ed in.
295 * @param webContents A {@link WebContents} object. 294 * @param webContents A {@link WebContents} object.
296 */ 295 */
297 @SuppressWarnings("unused") 296 @SuppressWarnings("unused")
298 @CalledByNative 297 @CalledByNative
299 private void initFromNativeTabContents(WebContents webContents) { 298 private void initFromNativeTabContents(WebContents webContents) {
300 Context context = getContext(); 299 Context context = getContext();
301 mContentViewCore = new ContentViewCore(context, ""); 300 mContentViewCore = new ContentViewCore(context, "");
302 ContentView cv = ContentView.createContentView(context, mContentViewCore ); 301 ContentView cv = ContentView.createContentView(context, mContentViewCore );
303 mViewAndroidDelegate = new ShellViewAndroidDelegate(cv); 302 mViewAndroidDelegate = new ShellViewAndroidDelegate(cv);
304 mContentViewCore.initialize(mViewAndroidDelegate, cv, webContents, mWind ow); 303 mContentViewCore.initialize(mViewAndroidDelegate, cv, webContents, mView Root);
305 mContentViewCore.setActionModeCallback(defaultActionCallback()); 304 mContentViewCore.setActionModeCallback(defaultActionCallback());
306 mContentViewCore.setContentViewClient(mContentViewClient); 305 mContentViewCore.setContentViewClient(mContentViewClient);
307 mWebContents = mContentViewCore.getWebContents(); 306 mWebContents = mContentViewCore.getWebContents();
308 mNavigationController = mWebContents.getNavigationController(); 307 mNavigationController = mWebContents.getNavigationController();
309 if (getParent() != null) mContentViewCore.onShow(); 308 if (getParent() != null) mContentViewCore.onShow();
310 if (mWebContents.getUrl() != null) { 309 if (mWebContents.getUrl() != null) {
311 mUrlTextView.setText(mWebContents.getUrl()); 310 mUrlTextView.setText(mWebContents.getUrl());
312 } 311 }
313 ((FrameLayout) findViewById(R.id.contentview_holder)).addView(cv, 312 ((FrameLayout) findViewById(R.id.contentview_holder)).addView(cv,
314 new FrameLayout.LayoutParams( 313 new FrameLayout.LayoutParams(
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 Context.INPUT_METHOD_SERVICE); 407 Context.INPUT_METHOD_SERVICE);
409 if (visible) { 408 if (visible) {
410 imm.showSoftInput(mUrlTextView, InputMethodManager.SHOW_IMPLICIT); 409 imm.showSoftInput(mUrlTextView, InputMethodManager.SHOW_IMPLICIT);
411 } else { 410 } else {
412 imm.hideSoftInputFromWindow(mUrlTextView.getWindowToken(), 0); 411 imm.hideSoftInputFromWindow(mUrlTextView.getWindowToken(), 0);
413 } 412 }
414 } 413 }
415 414
416 private static native void nativeCloseShell(long shellPtr); 415 private static native void nativeCloseShell(long shellPtr);
417 } 416 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698