protected void addAccessibilityApis() {
    Context context = mContentViewCore.getContext();
    if (context != null) {
      // Enabled, we should try to add if we have to.
      if (mTextToSpeech == null) {
        mTextToSpeech = new TextToSpeechWrapper(mContentViewCore.getContainerView(), context);
        mContentViewCore.addJavascriptInterface(mTextToSpeech, ALIAS_ACCESSIBILITY_JS_INTERFACE);
      }

      if (mVibrator == null) {
        mVibrator = new VibratorWrapper(context);
        mContentViewCore.addJavascriptInterface(mVibrator, ALIAS_ACCESSIBILITY_JS_INTERFACE_2);
      }
    }
  }
  /**
   * Starts showing a context menu for {@code view} based on {@code params}.
   *
   * @param contentViewCore The {@link ContentViewCore} to show the menu to.
   * @param params The {@link ContextMenuParams} that indicate what menu items to show.
   */
  @CalledByNative
  private void showContextMenu(ContentViewCore contentViewCore, ContextMenuParams params) {
    final View view = contentViewCore.getContainerView();

    if (!shouldShowMenu(params)
        || view == null
        || view.getVisibility() != View.VISIBLE
        || view.getParent() == null) {
      return;
    }

    mCurrentContextMenuParams = params;

    view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
    view.setOnCreateContextMenuListener(this);
    view.showContextMenu();
  }
 @Override
 public void onContentViewCoreAdded(ContentViewCore content) {
   // TODO(dtrainor): Look into rolling this into onContentChanged().
   initializeContentViewCore(content);
   setSizeOfUnattachedView(content.getContainerView());
 }
  private void updateContentOverlayVisibility(boolean show) {
    if (mView == null) return;

    sCachedCVCList.clear();
    if (mLayoutManager != null) {
      mLayoutManager.getActiveLayout().getAllContentViewCores(sCachedCVCList);
    }
    if (show) {
      if (mView.getParent() != this) {
        // Make sure the view isn't a child of something else before we attempt to add it.
        if (mView.getParent() != null && mView.getParent() instanceof ViewGroup) {
          ((ViewGroup) mView.getParent()).removeView(mView);
        }

        for (int i = 0; i < sCachedCVCList.size(); i++) {
          ContentViewCore content = sCachedCVCList.get(i);
          assert content.isAlive();
          content.getContainerView().setVisibility(View.VISIBLE);
          if (mFullscreenManager != null) {
            mFullscreenManager.updateContentViewViewportSize(content);
          }
        }

        FrameLayout.LayoutParams layoutParams =
            new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
        if (mView.getLayoutParams() instanceof MarginLayoutParams) {
          MarginLayoutParams existingLayoutParams = (MarginLayoutParams) mView.getLayoutParams();
          layoutParams.leftMargin = existingLayoutParams.leftMargin;
          layoutParams.rightMargin = existingLayoutParams.rightMargin;
          layoutParams.topMargin = existingLayoutParams.topMargin;
          layoutParams.bottomMargin = existingLayoutParams.bottomMargin;
        }
        addView(mView, layoutParams);

        setFocusable(false);
        setFocusableInTouchMode(false);

        // Claim focus for the new view unless the user is currently using the URL bar.
        if (mUrlBar == null || !mUrlBar.hasFocus()) mView.requestFocus();
      }
    } else {
      if (mView.getParent() == this) {
        setFocusable(true);
        setFocusableInTouchMode(true);

        for (int i = 0; i < sCachedCVCList.size(); i++) {
          ContentViewCore content = sCachedCVCList.get(i);
          if (content.isAlive()) content.getContainerView().setVisibility(View.INVISIBLE);
        }

        if (hasFocus()) {
          InputMethodManager manager =
              (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
          if (manager.isActive(this)) {
            manager.hideSoftInputFromWindow(getWindowToken(), 0, null);
          }
        }
        removeView(mView);
      }
    }
    sCachedCVCList.clear();
  }
 @Override
 public View getViewForInteraction() {
   ContentViewCore content = mSearchPanel.getContentViewCore();
   if (content != null) return content.getContainerView();
   return super.getViewForInteraction();
 }