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

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: tests 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.ViewRoot;
40 import org.chromium.ui.base.WindowAndroid; 41 import org.chromium.ui.base.WindowAndroid;
41 42
42 /** 43 /**
43 * Container for the various UI components that make up a shell window. 44 * Container for the various UI components that make up a shell window.
44 */ 45 */
45 @JNINamespace("content") 46 @JNINamespace("content")
46 public class Shell extends LinearLayout { 47 public class Shell extends LinearLayout {
47 48
48 private static final long COMPLETED_PROGRESS_TIMEOUT_MS = 200; 49 private static final long COMPLETED_PROGRESS_TIMEOUT_MS = 200;
49 50
50 private final Runnable mClearProgressRunnable = new Runnable() { 51 private final Runnable mClearProgressRunnable = new Runnable() {
51 @Override 52 @Override
52 public void run() { 53 public void run() {
53 mProgressDrawable.setLevel(0); 54 mProgressDrawable.setLevel(0);
54 } 55 }
55 }; 56 };
56 57
57 private ContentViewCore mContentViewCore; 58 private ContentViewCore mContentViewCore;
58 private WebContents mWebContents; 59 private WebContents mWebContents;
60 private ViewRoot mViewRoot;
59 private NavigationController mNavigationController; 61 private NavigationController mNavigationController;
60 private ContentViewClient mContentViewClient; 62 private ContentViewClient mContentViewClient;
61 private EditText mUrlTextView; 63 private EditText mUrlTextView;
62 private ImageButton mPrevButton; 64 private ImageButton mPrevButton;
63 private ImageButton mNextButton; 65 private ImageButton mNextButton;
64 private ImageButton mStopReloadButton; 66 private ImageButton mStopReloadButton;
65 67
66 private ClipDrawable mProgressDrawable; 68 private ClipDrawable mProgressDrawable;
67 69
68 private long mNativeShell; 70 private long mNativeShell;
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 @CalledByNative 296 @CalledByNative
295 private void initFromNativeTabContents(WebContents webContents) { 297 private void initFromNativeTabContents(WebContents webContents) {
296 Context context = getContext(); 298 Context context = getContext();
297 mContentViewCore = new ContentViewCore(context, ""); 299 mContentViewCore = new ContentViewCore(context, "");
298 ContentView cv = ContentView.createContentView(context, mContentViewCore ); 300 ContentView cv = ContentView.createContentView(context, mContentViewCore );
299 mContentViewCore.initialize(ViewAndroidDelegate.createBasicDelegate(cv), cv, 301 mContentViewCore.initialize(ViewAndroidDelegate.createBasicDelegate(cv), cv,
300 webContents, mWindow); 302 webContents, mWindow);
301 mContentViewCore.setActionModeCallback(defaultActionCallback()); 303 mContentViewCore.setActionModeCallback(defaultActionCallback());
302 mContentViewCore.setContentViewClient(mContentViewClient); 304 mContentViewCore.setContentViewClient(mContentViewClient);
303 mWebContents = mContentViewCore.getWebContents(); 305 mWebContents = mContentViewCore.getWebContents();
306 mViewRoot = ViewRoot.create(mWindow);
307 mWebContents.initViewRoot(mViewRoot);
304 mNavigationController = mWebContents.getNavigationController(); 308 mNavigationController = mWebContents.getNavigationController();
305 if (getParent() != null) mContentViewCore.onShow(); 309 if (getParent() != null) mContentViewCore.onShow();
306 if (mWebContents.getUrl() != null) { 310 if (mWebContents.getUrl() != null) {
307 mUrlTextView.setText(mWebContents.getUrl()); 311 mUrlTextView.setText(mWebContents.getUrl());
308 } 312 }
309 ((FrameLayout) findViewById(R.id.contentview_holder)).addView(cv, 313 ((FrameLayout) findViewById(R.id.contentview_holder)).addView(cv,
310 new FrameLayout.LayoutParams( 314 new FrameLayout.LayoutParams(
311 FrameLayout.LayoutParams.MATCH_PARENT, 315 FrameLayout.LayoutParams.MATCH_PARENT,
312 FrameLayout.LayoutParams.MATCH_PARENT)); 316 FrameLayout.LayoutParams.MATCH_PARENT));
313 cv.requestFocus(); 317 cv.requestFocus();
314 mContentViewRenderView.setCurrentContentViewCore(mContentViewCore); 318 mContentViewRenderView.setCurrentContent(mContentViewCore, mViewRoot);
315 } 319 }
316 320
317 /** 321 /**
318 * {link @ActionMode.Callback} that uses the default implementation in 322 * {link @ActionMode.Callback} that uses the default implementation in
319 * {@link SelectionPopupController}. 323 * {@link SelectionPopupController}.
320 */ 324 */
321 private ActionMode.Callback defaultActionCallback() { 325 private ActionMode.Callback defaultActionCallback() {
322 final ActionModeCallbackHelper helper = 326 final ActionModeCallbackHelper helper =
323 mContentViewCore.getActionModeCallbackHelper(); 327 mContentViewCore.getActionModeCallbackHelper();
324 328
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 361
358 @Override 362 @Override
359 public void exitFullscreenVideo() { 363 public void exitFullscreenVideo() {
360 super.exitFullscreenVideo(); 364 super.exitFullscreenVideo();
361 mContentViewRenderView.setOverlayVideoMode(false); 365 mContentViewRenderView.setOverlayVideoMode(false);
362 } 366 }
363 }; 367 };
364 } 368 }
365 369
366 /** 370 /**
371 * @return {@link ViewRoot} instance used to forward view/input events.
372 */
373 ViewRoot getViewRoot() {
374 return mViewRoot;
375 }
376
377 /**
367 * Enable/Disable navigation(Prev/Next) button if navigation is allowed/disa llowed 378 * Enable/Disable navigation(Prev/Next) button if navigation is allowed/disa llowed
368 * in respective direction. 379 * in respective direction.
369 * @param controlId Id of button to update 380 * @param controlId Id of button to update
370 * @param enabled enable/disable value 381 * @param enabled enable/disable value
371 */ 382 */
372 @CalledByNative 383 @CalledByNative
373 private void enableUiControl(int controlId, boolean enabled) { 384 private void enableUiControl(int controlId, boolean enabled) {
374 if (controlId == 0) { 385 if (controlId == 0) {
375 mPrevButton.setEnabled(enabled); 386 mPrevButton.setEnabled(enabled);
376 } else if (controlId == 1) { 387 } else if (controlId == 1) {
(...skipping 27 matching lines...) Expand all
404 Context.INPUT_METHOD_SERVICE); 415 Context.INPUT_METHOD_SERVICE);
405 if (visible) { 416 if (visible) {
406 imm.showSoftInput(mUrlTextView, InputMethodManager.SHOW_IMPLICIT); 417 imm.showSoftInput(mUrlTextView, InputMethodManager.SHOW_IMPLICIT);
407 } else { 418 } else {
408 imm.hideSoftInputFromWindow(mUrlTextView.getWindowToken(), 0); 419 imm.hideSoftInputFromWindow(mUrlTextView.getWindowToken(), 0);
409 } 420 }
410 } 421 }
411 422
412 private static native void nativeCloseShell(long shellPtr); 423 private static native void nativeCloseShell(long shellPtr);
413 } 424 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698