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

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

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

Powered by Google App Engine
This is Rietveld 408576698