| OLD | NEW |
| 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_public.browser.ActionModeCallbackHelper; |
| 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 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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); |
| 301 mContentViewCore.setActionModeCallback(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 * {link @ActionMode.Callback} that uses the default implementation in |
| 319 * {@link SelectionPopupController}. |
| 320 */ |
| 321 private ActionMode.Callback defaultActionCallback() { |
| 322 final ActionModeCallbackHelper helper = |
| 323 mContentViewCore.getActionModeCallbackHelper(); |
| 324 |
| 325 return new ActionMode.Callback() { |
| 326 @Override |
| 327 public boolean onCreateActionMode(ActionMode mode, Menu menu) { |
| 328 helper.onCreateActionMode(mode, menu); |
| 329 return true; |
| 330 } |
| 331 |
| 332 @Override |
| 333 public boolean onPrepareActionMode(ActionMode mode, Menu menu) { |
| 334 return helper.onPrepareActionMode(mode, menu); |
| 335 } |
| 336 |
| 337 @Override |
| 338 public boolean onActionItemClicked(ActionMode mode, MenuItem item) { |
| 339 return helper.onActionItemClicked(mode, item); |
| 340 } |
| 341 |
| 342 @Override |
| 343 public void onDestroyActionMode(ActionMode mode) { |
| 344 helper.onDestroyActionMode(); |
| 345 } |
| 346 }; |
| 347 } |
| 348 |
| 312 @CalledByNative | 349 @CalledByNative |
| 313 public ContentVideoViewEmbedder getContentVideoViewEmbedder() { | 350 public ContentVideoViewEmbedder getContentVideoViewEmbedder() { |
| 314 return new ActivityContentVideoViewEmbedder((Activity) getContext()) { | 351 return new ActivityContentVideoViewEmbedder((Activity) getContext()) { |
| 315 @Override | 352 @Override |
| 316 public void enterFullscreenVideo(View view, boolean isVideoLoaded) { | 353 public void enterFullscreenVideo(View view, boolean isVideoLoaded) { |
| 317 super.enterFullscreenVideo(view, isVideoLoaded); | 354 super.enterFullscreenVideo(view, isVideoLoaded); |
| 318 mContentViewRenderView.setOverlayVideoMode(true); | 355 mContentViewRenderView.setOverlayVideoMode(true); |
| 319 } | 356 } |
| 320 | 357 |
| 321 @Override | 358 @Override |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 Context.INPUT_METHOD_SERVICE); | 404 Context.INPUT_METHOD_SERVICE); |
| 368 if (visible) { | 405 if (visible) { |
| 369 imm.showSoftInput(mUrlTextView, InputMethodManager.SHOW_IMPLICIT); | 406 imm.showSoftInput(mUrlTextView, InputMethodManager.SHOW_IMPLICIT); |
| 370 } else { | 407 } else { |
| 371 imm.hideSoftInputFromWindow(mUrlTextView.getWindowToken(), 0); | 408 imm.hideSoftInputFromWindow(mUrlTextView.getWindowToken(), 0); |
| 372 } | 409 } |
| 373 } | 410 } |
| 374 | 411 |
| 375 private static native void nativeCloseShell(long shellPtr); | 412 private static native void nativeCloseShell(long shellPtr); |
| 376 } | 413 } |
| OLD | NEW |