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

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

Issue 2682593002: Refactor ContentViewClient (4/6) (Closed)
Patch Set: rebased & fix tests 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 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.ContentViewAndroidDelegate;
32 import org.chromium.content.browser.ContentViewClient; 33 import org.chromium.content.browser.ContentViewClient;
33 import org.chromium.content.browser.ContentViewCore; 34 import org.chromium.content.browser.ContentViewCore;
34 import org.chromium.content.browser.ContentViewRenderView; 35 import org.chromium.content.browser.ContentViewRenderView;
35 import org.chromium.content_public.browser.ActionModeCallbackHelper; 36 import org.chromium.content_public.browser.ActionModeCallbackHelper;
36 import org.chromium.content_public.browser.LoadUrlParams; 37 import org.chromium.content_public.browser.LoadUrlParams;
37 import org.chromium.content_public.browser.NavigationController; 38 import org.chromium.content_public.browser.NavigationController;
38 import org.chromium.content_public.browser.WebContents; 39 import org.chromium.content_public.browser.WebContents;
39 import org.chromium.ui.base.ViewAndroidDelegate;
40 import org.chromium.ui.base.WindowAndroid; 40 import org.chromium.ui.base.WindowAndroid;
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
(...skipping 11 matching lines...) Expand all
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 WindowAndroid mWindow;
71 private ContentViewAndroidDelegate mViewAndroidDelegate;
71 72
72 private boolean mLoading; 73 private boolean mLoading;
73 private boolean mIsFullscreen; 74 private boolean mIsFullscreen;
74 75
75 /** 76 /**
76 * Constructor for inflating via XML. 77 * Constructor for inflating via XML.
77 */ 78 */
78 public Shell(Context context, AttributeSet attrs) { 79 public Shell(Context context, AttributeSet attrs) {
79 super(context, attrs); 80 super(context, attrs);
80 } 81 }
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 private void setIsLoading(boolean loading) { 280 private void setIsLoading(boolean loading) {
280 mLoading = loading; 281 mLoading = loading;
281 if (mLoading) { 282 if (mLoading) {
282 mStopReloadButton 283 mStopReloadButton
283 .setImageResource(android.R.drawable.ic_menu_close_clear_can cel); 284 .setImageResource(android.R.drawable.ic_menu_close_clear_can cel);
284 } else { 285 } else {
285 mStopReloadButton.setImageResource(R.drawable.ic_refresh); 286 mStopReloadButton.setImageResource(R.drawable.ic_refresh);
286 } 287 }
287 } 288 }
288 289
290 public ContentViewAndroidDelegate getViewAndroidDelegate() {
291 return mViewAndroidDelegate;
292 }
293
289 /** 294 /**
290 * Initializes the ContentView based on the native tab contents pointer pass ed in. 295 * Initializes the ContentView based on the native tab contents pointer pass ed in.
291 * @param webContents A {@link WebContents} object. 296 * @param webContents A {@link WebContents} object.
292 */ 297 */
293 @SuppressWarnings("unused") 298 @SuppressWarnings("unused")
294 @CalledByNative 299 @CalledByNative
295 private void initFromNativeTabContents(WebContents webContents) { 300 private void initFromNativeTabContents(WebContents webContents) {
296 Context context = getContext(); 301 Context context = getContext();
297 mContentViewCore = new ContentViewCore(context, ""); 302 mContentViewCore = new ContentViewCore(context, "");
298 ContentView cv = ContentView.createContentView(context, mContentViewCore ); 303 ContentView cv = ContentView.createContentView(context, mContentViewCore );
299 mContentViewCore.initialize(ViewAndroidDelegate.createBasicDelegate(cv), cv, 304 mViewAndroidDelegate = new ContentViewAndroidDelegate(cv);
300 webContents, mWindow); 305 mContentViewCore.initialize(mViewAndroidDelegate, cv, webContents, mWind ow);
301 mContentViewCore.setActionModeCallback(defaultActionCallback()); 306 mContentViewCore.setActionModeCallback(defaultActionCallback());
302 mContentViewCore.setContentViewClient(mContentViewClient); 307 mContentViewCore.setContentViewClient(mContentViewClient);
303 mWebContents = mContentViewCore.getWebContents(); 308 mWebContents = mContentViewCore.getWebContents();
304 mNavigationController = mWebContents.getNavigationController(); 309 mNavigationController = mWebContents.getNavigationController();
305 if (getParent() != null) mContentViewCore.onShow(); 310 if (getParent() != null) mContentViewCore.onShow();
306 if (mWebContents.getUrl() != null) { 311 if (mWebContents.getUrl() != null) {
307 mUrlTextView.setText(mWebContents.getUrl()); 312 mUrlTextView.setText(mWebContents.getUrl());
308 } 313 }
309 ((FrameLayout) findViewById(R.id.contentview_holder)).addView(cv, 314 ((FrameLayout) findViewById(R.id.contentview_holder)).addView(cv,
310 new FrameLayout.LayoutParams( 315 new FrameLayout.LayoutParams(
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 Context.INPUT_METHOD_SERVICE); 409 Context.INPUT_METHOD_SERVICE);
405 if (visible) { 410 if (visible) {
406 imm.showSoftInput(mUrlTextView, InputMethodManager.SHOW_IMPLICIT); 411 imm.showSoftInput(mUrlTextView, InputMethodManager.SHOW_IMPLICIT);
407 } else { 412 } else {
408 imm.hideSoftInputFromWindow(mUrlTextView.getWindowToken(), 0); 413 imm.hideSoftInputFromWindow(mUrlTextView.getWindowToken(), 0);
409 } 414 }
410 } 415 }
411 416
412 private static native void nativeCloseShell(long shellPtr); 417 private static native void nativeCloseShell(long shellPtr);
413 } 418 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698