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

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: Move FloatingPaste into WebActionMode 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;
26 import org.chromium.content.browser.ActivityContentVideoViewEmbedder; 29 import org.chromium.content.browser.ActivityContentVideoViewEmbedder;
27 import org.chromium.content.browser.ContentVideoViewEmbedder; 30 import org.chromium.content.browser.ContentVideoViewEmbedder;
28 import org.chromium.content.browser.ContentView; 31 import org.chromium.content.browser.ContentView;
29 import org.chromium.content.browser.ContentViewClient; 32 import org.chromium.content.browser.ContentViewClient;
30 import org.chromium.content.browser.ContentViewCore; 33 import org.chromium.content.browser.ContentViewCore;
31 import org.chromium.content.browser.ContentViewRenderView; 34 import org.chromium.content.browser.ContentViewRenderView;
35 import org.chromium.content.browser.WebActionMode;
32 import org.chromium.content_public.browser.LoadUrlParams; 36 import org.chromium.content_public.browser.LoadUrlParams;
33 import org.chromium.content_public.browser.NavigationController; 37 import org.chromium.content_public.browser.NavigationController;
34 import org.chromium.content_public.browser.WebContents; 38 import org.chromium.content_public.browser.WebContents;
35 import org.chromium.ui.base.ViewAndroidDelegate; 39 import org.chromium.ui.base.ViewAndroidDelegate;
36 import org.chromium.ui.base.WindowAndroid; 40 import org.chromium.ui.base.WindowAndroid;
37 41
38 /** 42 /**
39 * 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.
40 */ 44 */
41 @JNINamespace("content") 45 @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. 290 * Initializes the ContentView based on the native tab contents pointer pass ed in.
287 * @param webContents A {@link WebContents} object. 291 * @param webContents A {@link WebContents} object.
288 */ 292 */
289 @SuppressWarnings("unused") 293 @SuppressWarnings("unused")
290 @CalledByNative 294 @CalledByNative
291 private void initFromNativeTabContents(WebContents webContents) { 295 private void initFromNativeTabContents(WebContents webContents) {
292 Context context = getContext(); 296 Context context = getContext();
293 mContentViewCore = new ContentViewCore(context, ""); 297 mContentViewCore = new ContentViewCore(context, "");
294 ContentView cv = ContentView.createContentView(context, mContentViewCore ); 298 ContentView cv = ContentView.createContentView(context, mContentViewCore );
295 mContentViewCore.initialize(ViewAndroidDelegate.createBasicDelegate(cv), cv, 299 mContentViewCore.initialize(ViewAndroidDelegate.createBasicDelegate(cv), cv,
296 webContents, mWindow); 300 webContents, mWindow, defaultActionCallback(mContentViewCore.get ActionMode()));
boliu 2016/10/26 00:20:57 getActionModeDelegate (basically the interface ver
Jinsuk Kim 2016/10/26 06:11:39 Done.
297 mContentViewCore.setContentViewClient(mContentViewClient); 301 mContentViewCore.setContentViewClient(mContentViewClient);
298 mWebContents = mContentViewCore.getWebContents(); 302 mWebContents = mContentViewCore.getWebContents();
299 mNavigationController = mWebContents.getNavigationController(); 303 mNavigationController = mWebContents.getNavigationController();
300 if (getParent() != null) mContentViewCore.onShow(); 304 if (getParent() != null) mContentViewCore.onShow();
301 if (mWebContents.getUrl() != null) { 305 if (mWebContents.getUrl() != null) {
302 mUrlTextView.setText(mWebContents.getUrl()); 306 mUrlTextView.setText(mWebContents.getUrl());
303 } 307 }
304 ((FrameLayout) findViewById(R.id.contentview_holder)).addView(cv, 308 ((FrameLayout) findViewById(R.id.contentview_holder)).addView(cv,
305 new FrameLayout.LayoutParams( 309 new FrameLayout.LayoutParams(
306 FrameLayout.LayoutParams.MATCH_PARENT, 310 FrameLayout.LayoutParams.MATCH_PARENT,
307 FrameLayout.LayoutParams.MATCH_PARENT)); 311 FrameLayout.LayoutParams.MATCH_PARENT));
308 cv.requestFocus(); 312 cv.requestFocus();
309 mContentViewRenderView.setCurrentContentViewCore(mContentViewCore); 313 mContentViewRenderView.setCurrentContentViewCore(mContentViewCore);
310 } 314 }
311 315
316 /**
317 * Default {link @ActionMode.Callback} that uses the implementation in {@lin k WebActionMode}.
318 */
319 private static ActionMode.Callback defaultActionCallback(final WebActionMode actionMode) {
320 return new ActionMode.Callback() {
321 @Override
322 public boolean onCreateActionMode(ActionMode mode, Menu menu) {
323 return actionMode.onCreateActionMode(mode, menu);
324 }
325
326 @Override
327 public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
328 return actionMode.onPrepareActionMode(mode, menu);
329 }
330
331 @Override
332 public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
333 return actionMode.onActionItemClicked(mode, item);
334 }
335
336 @Override
337 public void onDestroyActionMode(ActionMode mode) {
338 actionMode.onDestroyActionMode();
339 }
340 };
341 }
342
312 @CalledByNative 343 @CalledByNative
313 public ContentVideoViewEmbedder getContentVideoViewEmbedder() { 344 public ContentVideoViewEmbedder getContentVideoViewEmbedder() {
314 return new ActivityContentVideoViewEmbedder((Activity) getContext()) { 345 return new ActivityContentVideoViewEmbedder((Activity) getContext()) {
315 @Override 346 @Override
316 public void enterFullscreenVideo(View view, boolean isVideoLoaded) { 347 public void enterFullscreenVideo(View view, boolean isVideoLoaded) {
317 super.enterFullscreenVideo(view, isVideoLoaded); 348 super.enterFullscreenVideo(view, isVideoLoaded);
318 mContentViewRenderView.setOverlayVideoMode(true); 349 mContentViewRenderView.setOverlayVideoMode(true);
319 } 350 }
320 351
321 @Override 352 @Override
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 Context.INPUT_METHOD_SERVICE); 398 Context.INPUT_METHOD_SERVICE);
368 if (visible) { 399 if (visible) {
369 imm.showSoftInput(mUrlTextView, InputMethodManager.SHOW_IMPLICIT); 400 imm.showSoftInput(mUrlTextView, InputMethodManager.SHOW_IMPLICIT);
370 } else { 401 } else {
371 imm.hideSoftInputFromWindow(mUrlTextView.getWindowToken(), 0); 402 imm.hideSoftInputFromWindow(mUrlTextView.getWindowToken(), 0);
372 } 403 }
373 } 404 }
374 405
375 private static native void nativeCloseShell(long shellPtr); 406 private static native void nativeCloseShell(long shellPtr);
376 } 407 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698