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

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

Issue 2407303005: Let embedder provide select action mode (Closed)
Patch Set: more comments addressed Created 4 years, 1 month 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;
11 import android.util.AttributeSet; 11 import android.util.AttributeSet;
12 import android.view.ActionMode;
12 import android.view.KeyEvent; 13 import android.view.KeyEvent;
14 import android.view.Menu;
15 import android.view.MenuItem;
13 import android.view.View; 16 import android.view.View;
14 import android.view.ViewGroup; 17 import android.view.ViewGroup;
15 import android.view.inputmethod.EditorInfo; 18 import android.view.inputmethod.EditorInfo;
16 import android.view.inputmethod.InputMethodManager; 19 import android.view.inputmethod.InputMethodManager;
17 import android.widget.EditText; 20 import android.widget.EditText;
18 import android.widget.FrameLayout; 21 import android.widget.FrameLayout;
19 import android.widget.ImageButton; 22 import android.widget.ImageButton;
20 import android.widget.LinearLayout; 23 import android.widget.LinearLayout;
21 import android.widget.TextView; 24 import android.widget.TextView;
22 import android.widget.TextView.OnEditorActionListener; 25 import android.widget.TextView.OnEditorActionListener;
23 26
24 import org.chromium.base.annotations.CalledByNative; 27 import org.chromium.base.annotations.CalledByNative;
25 import org.chromium.base.annotations.JNINamespace; 28 import org.chromium.base.annotations.JNINamespace;
29 import org.chromium.content.browser.ActionModeCallbackHelper;
26 import org.chromium.content.browser.ActivityContentVideoViewEmbedder; 30 import org.chromium.content.browser.ActivityContentVideoViewEmbedder;
27 import org.chromium.content.browser.ContentVideoViewEmbedder; 31 import org.chromium.content.browser.ContentVideoViewEmbedder;
28 import org.chromium.content.browser.ContentView; 32 import org.chromium.content.browser.ContentView;
29 import org.chromium.content.browser.ContentViewClient; 33 import org.chromium.content.browser.ContentViewClient;
30 import org.chromium.content.browser.ContentViewCore; 34 import org.chromium.content.browser.ContentViewCore;
31 import org.chromium.content.browser.ContentViewRenderView; 35 import org.chromium.content.browser.ContentViewRenderView;
36 import org.chromium.content.browser.WebActionMode;
32 import org.chromium.content_public.browser.LoadUrlParams; 37 import org.chromium.content_public.browser.LoadUrlParams;
33 import org.chromium.content_public.browser.NavigationController; 38 import org.chromium.content_public.browser.NavigationController;
34 import org.chromium.content_public.browser.WebContents; 39 import org.chromium.content_public.browser.WebContents;
35 import org.chromium.ui.base.ViewAndroidDelegate; 40 import org.chromium.ui.base.ViewAndroidDelegate;
36 import org.chromium.ui.base.WindowAndroid; 41 import org.chromium.ui.base.WindowAndroid;
37 42
38 /** 43 /**
39 * 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.
40 */ 45 */
41 @JNINamespace("content") 46 @JNINamespace("content")
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 * Initializes the ContentView based on the native tab contents pointer pass ed in. 291 * Initializes the ContentView based on the native tab contents pointer pass ed in.
287 * @param webContents A {@link WebContents} object. 292 * @param webContents A {@link WebContents} object.
288 */ 293 */
289 @SuppressWarnings("unused") 294 @SuppressWarnings("unused")
290 @CalledByNative 295 @CalledByNative
291 private void initFromNativeTabContents(WebContents webContents) { 296 private void initFromNativeTabContents(WebContents webContents) {
292 Context context = getContext(); 297 Context context = getContext();
293 mContentViewCore = new ContentViewCore(context, ""); 298 mContentViewCore = new ContentViewCore(context, "");
294 ContentView cv = ContentView.createContentView(context, mContentViewCore ); 299 ContentView cv = ContentView.createContentView(context, mContentViewCore );
295 mContentViewCore.initialize(ViewAndroidDelegate.createBasicDelegate(cv), cv, 300 mContentViewCore.initialize(ViewAndroidDelegate.createBasicDelegate(cv), cv,
296 webContents, mWindow); 301 webContents, mWindow, defaultActionCallback());
297 mContentViewCore.setContentViewClient(mContentViewClient); 302 mContentViewCore.setContentViewClient(mContentViewClient);
298 mWebContents = mContentViewCore.getWebContents(); 303 mWebContents = mContentViewCore.getWebContents();
299 mNavigationController = mWebContents.getNavigationController(); 304 mNavigationController = mWebContents.getNavigationController();
300 if (getParent() != null) mContentViewCore.onShow(); 305 if (getParent() != null) mContentViewCore.onShow();
301 if (mWebContents.getUrl() != null) { 306 if (mWebContents.getUrl() != null) {
302 mUrlTextView.setText(mWebContents.getUrl()); 307 mUrlTextView.setText(mWebContents.getUrl());
303 } 308 }
304 ((FrameLayout) findViewById(R.id.contentview_holder)).addView(cv, 309 ((FrameLayout) findViewById(R.id.contentview_holder)).addView(cv,
305 new FrameLayout.LayoutParams( 310 new FrameLayout.LayoutParams(
306 FrameLayout.LayoutParams.MATCH_PARENT, 311 FrameLayout.LayoutParams.MATCH_PARENT,
307 FrameLayout.LayoutParams.MATCH_PARENT)); 312 FrameLayout.LayoutParams.MATCH_PARENT));
308 cv.requestFocus(); 313 cv.requestFocus();
309 mContentViewRenderView.setCurrentContentViewCore(mContentViewCore); 314 mContentViewRenderView.setCurrentContentViewCore(mContentViewCore);
310 } 315 }
311 316
317 /**
318 * Default {link @ActionMode.Callback} that uses the implementation in {@lin k WebActionMode}.
319 */
320 private ActionMode.Callback defaultActionCallback() {
321 final ActionModeCallbackHelper helper =
322 mContentViewCore.getActionModeCallbackHelper();
323
324 return new ActionMode.Callback() {
325 @Override
326 public boolean onCreateActionMode(ActionMode mode, Menu menu) {
327 return helper.onCreateActionMode(mode, menu);
328 }
329
330 @Override
331 public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
332 return helper.onPrepareActionMode(mode, menu);
333 }
334
335 @Override
336 public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
337 return helper.onActionItemClicked(mode, item);
338 }
339
340 @Override
341 public void onDestroyActionMode(ActionMode mode) {
342 helper.onDestroyActionMode();
343 }
344 };
345 }
346
312 @CalledByNative 347 @CalledByNative
313 public ContentVideoViewEmbedder getContentVideoViewEmbedder() { 348 public ContentVideoViewEmbedder getContentVideoViewEmbedder() {
314 return new ActivityContentVideoViewEmbedder((Activity) getContext()) { 349 return new ActivityContentVideoViewEmbedder((Activity) getContext()) {
315 @Override 350 @Override
316 public void enterFullscreenVideo(View view, boolean isVideoLoaded) { 351 public void enterFullscreenVideo(View view, boolean isVideoLoaded) {
317 super.enterFullscreenVideo(view, isVideoLoaded); 352 super.enterFullscreenVideo(view, isVideoLoaded);
318 mContentViewRenderView.setOverlayVideoMode(true); 353 mContentViewRenderView.setOverlayVideoMode(true);
319 } 354 }
320 355
321 @Override 356 @Override
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 Context.INPUT_METHOD_SERVICE); 402 Context.INPUT_METHOD_SERVICE);
368 if (visible) { 403 if (visible) {
369 imm.showSoftInput(mUrlTextView, InputMethodManager.SHOW_IMPLICIT); 404 imm.showSoftInput(mUrlTextView, InputMethodManager.SHOW_IMPLICIT);
370 } else { 405 } else {
371 imm.hideSoftInputFromWindow(mUrlTextView.getWindowToken(), 0); 406 imm.hideSoftInputFromWindow(mUrlTextView.getWindowToken(), 0);
372 } 407 }
373 } 408 }
374 409
375 private static native void nativeCloseShell(long shellPtr); 410 private static native void nativeCloseShell(long shellPtr);
376 } 411 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698