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

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

Issue 2353063005: Refactor ContentViewClient (1/6) (Closed)
Patch Set: cast to activity Created 4 years, 2 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.content.Context; 8 import android.content.Context;
8 import android.graphics.drawable.ClipDrawable; 9 import android.graphics.drawable.ClipDrawable;
9 import android.text.TextUtils; 10 import android.text.TextUtils;
10 import android.util.AttributeSet; 11 import android.util.AttributeSet;
11 import android.view.KeyEvent; 12 import android.view.KeyEvent;
12 import android.view.View; 13 import android.view.View;
13 import android.view.ViewGroup; 14 import android.view.ViewGroup;
14 import android.view.inputmethod.EditorInfo; 15 import android.view.inputmethod.EditorInfo;
15 import android.view.inputmethod.InputMethodManager; 16 import android.view.inputmethod.InputMethodManager;
16 import android.widget.EditText; 17 import android.widget.EditText;
17 import android.widget.FrameLayout; 18 import android.widget.FrameLayout;
18 import android.widget.ImageButton; 19 import android.widget.ImageButton;
19 import android.widget.LinearLayout; 20 import android.widget.LinearLayout;
20 import android.widget.TextView; 21 import android.widget.TextView;
21 import android.widget.TextView.OnEditorActionListener; 22 import android.widget.TextView.OnEditorActionListener;
22 23
23 import org.chromium.base.annotations.CalledByNative; 24 import org.chromium.base.annotations.CalledByNative;
24 import org.chromium.base.annotations.JNINamespace; 25 import org.chromium.base.annotations.JNINamespace;
26 import org.chromium.content.browser.ActivityContentVideoViewEmbedder;
27 import org.chromium.content.browser.ContentVideoViewEmbedder;
25 import org.chromium.content.browser.ContentView; 28 import org.chromium.content.browser.ContentView;
26 import org.chromium.content.browser.ContentViewClient; 29 import org.chromium.content.browser.ContentViewClient;
27 import org.chromium.content.browser.ContentViewCore; 30 import org.chromium.content.browser.ContentViewCore;
28 import org.chromium.content.browser.ContentViewRenderView; 31 import org.chromium.content.browser.ContentViewRenderView;
29 import org.chromium.content_public.browser.LoadUrlParams; 32 import org.chromium.content_public.browser.LoadUrlParams;
30 import org.chromium.content_public.browser.NavigationController; 33 import org.chromium.content_public.browser.NavigationController;
31 import org.chromium.content_public.browser.WebContents; 34 import org.chromium.content_public.browser.WebContents;
32 import org.chromium.ui.base.ViewAndroidDelegate; 35 import org.chromium.ui.base.ViewAndroidDelegate;
33 import org.chromium.ui.base.WindowAndroid; 36 import org.chromium.ui.base.WindowAndroid;
34 37
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 } 283 }
281 284
282 /** 285 /**
283 * Initializes the ContentView based on the native tab contents pointer pass ed in. 286 * Initializes the ContentView based on the native tab contents pointer pass ed in.
284 * @param webContents A {@link WebContents} object. 287 * @param webContents A {@link WebContents} object.
285 */ 288 */
286 @SuppressWarnings("unused") 289 @SuppressWarnings("unused")
287 @CalledByNative 290 @CalledByNative
288 private void initFromNativeTabContents(WebContents webContents) { 291 private void initFromNativeTabContents(WebContents webContents) {
289 Context context = getContext(); 292 Context context = getContext();
290 mContentViewCore = new ContentViewCore(context); 293 mContentViewCore = new ContentViewCore(context, "");
291 ContentView cv = ContentView.createContentView(context, mContentViewCore ); 294 ContentView cv = ContentView.createContentView(context, mContentViewCore );
292 mContentViewCore.initialize(ViewAndroidDelegate.createBasicDelegate(cv), cv, 295 mContentViewCore.initialize(ViewAndroidDelegate.createBasicDelegate(cv), cv,
293 webContents, mWindow); 296 webContents, mWindow);
294 mContentViewCore.setContentViewClient(mContentViewClient); 297 mContentViewCore.setContentViewClient(mContentViewClient);
295 mWebContents = mContentViewCore.getWebContents(); 298 mWebContents = mContentViewCore.getWebContents();
296 mNavigationController = mWebContents.getNavigationController(); 299 mNavigationController = mWebContents.getNavigationController();
297 if (getParent() != null) mContentViewCore.onShow(); 300 if (getParent() != null) mContentViewCore.onShow();
298 if (mWebContents.getUrl() != null) { 301 if (mWebContents.getUrl() != null) {
299 mUrlTextView.setText(mWebContents.getUrl()); 302 mUrlTextView.setText(mWebContents.getUrl());
300 } 303 }
301 ((FrameLayout) findViewById(R.id.contentview_holder)).addView(cv, 304 ((FrameLayout) findViewById(R.id.contentview_holder)).addView(cv,
302 new FrameLayout.LayoutParams( 305 new FrameLayout.LayoutParams(
303 FrameLayout.LayoutParams.MATCH_PARENT, 306 FrameLayout.LayoutParams.MATCH_PARENT,
304 FrameLayout.LayoutParams.MATCH_PARENT)); 307 FrameLayout.LayoutParams.MATCH_PARENT));
305 cv.requestFocus(); 308 cv.requestFocus();
306 mContentViewRenderView.setCurrentContentViewCore(mContentViewCore); 309 mContentViewRenderView.setCurrentContentViewCore(mContentViewCore);
307 } 310 }
308 311
312 @CalledByNative
313 public ContentVideoViewEmbedder getContentVideoViewEmbedder() {
314 return new ActivityContentVideoViewEmbedder((Activity) getContext()) {
315 @Override
316 public void enterFullscreenVideo(View view, boolean isVideoLoaded) {
317 super.enterFullscreenVideo(view, isVideoLoaded);
318 mContentViewRenderView.setOverlayVideoMode(true);
319 }
320
321 @Override
322 public void exitFullscreenVideo() {
323 super.exitFullscreenVideo();
324 mContentViewRenderView.setOverlayVideoMode(false);
325 }
326 };
327 }
328
309 /** 329 /**
310 * Enable/Disable navigation(Prev/Next) button if navigation is allowed/disa llowed 330 * Enable/Disable navigation(Prev/Next) button if navigation is allowed/disa llowed
311 * in respective direction. 331 * in respective direction.
312 * @param controlId Id of button to update 332 * @param controlId Id of button to update
313 * @param enabled enable/disable value 333 * @param enabled enable/disable value
314 */ 334 */
315 @CalledByNative 335 @CalledByNative
316 private void enableUiControl(int controlId, boolean enabled) { 336 private void enableUiControl(int controlId, boolean enabled) {
317 if (controlId == 0) { 337 if (controlId == 0) {
318 mPrevButton.setEnabled(enabled); 338 mPrevButton.setEnabled(enabled);
(...skipping 28 matching lines...) Expand all
347 Context.INPUT_METHOD_SERVICE); 367 Context.INPUT_METHOD_SERVICE);
348 if (visible) { 368 if (visible) {
349 imm.showSoftInput(mUrlTextView, InputMethodManager.SHOW_IMPLICIT); 369 imm.showSoftInput(mUrlTextView, InputMethodManager.SHOW_IMPLICIT);
350 } else { 370 } else {
351 imm.hideSoftInputFromWindow(mUrlTextView.getWindowToken(), 0); 371 imm.hideSoftInputFromWindow(mUrlTextView.getWindowToken(), 0);
352 } 372 }
353 } 373 }
354 374
355 private static native void nativeCloseShell(long shellPtr); 375 private static native void nativeCloseShell(long shellPtr);
356 } 376 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698