| Index: content/public/android/java/src/org/chromium/content/browser/ContentViewAndroidDelegate.java
|
| diff --git a/content/public/android/java/src/org/chromium/content/browser/ContentViewAndroidDelegate.java b/content/public/android/java/src/org/chromium/content/browser/ContentViewAndroidDelegate.java
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..240020b7263604fb06d488800aa9827b603b9cd6
|
| --- /dev/null
|
| +++ b/content/public/android/java/src/org/chromium/content/browser/ContentViewAndroidDelegate.java
|
| @@ -0,0 +1,52 @@
|
| +// Copyright 2017 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +package org.chromium.content.browser;
|
| +
|
| +import android.content.Intent;
|
| +import android.view.ViewGroup;
|
| +
|
| +import org.chromium.ui.base.ViewAndroidDelegate;
|
| +
|
| +/**
|
| + * Implementation of the abstract class {@link ViewAndroidDelegate} for content.
|
| + * Extended for content shell and testing.
|
| + */
|
| +public class ContentViewAndroidDelegate extends ViewAndroidDelegate {
|
| + private final ViewGroup mContainerView;
|
| + private ContentIntentHandler mContentIntentHandler;
|
| +
|
| + /**
|
| + * Interface used to define/modify what {@link #startContentIntent} does.
|
| + */
|
| + public interface ContentIntentHandler {
|
| + /**
|
| + * Called when intent url from content is received.
|
| + * @param intentUrl intent url.
|
| + */
|
| + void onIntentUrlReceived(String intentUrl);
|
| + }
|
| +
|
| + public ContentViewAndroidDelegate(ViewGroup containerView) {
|
| + mContainerView = containerView;
|
| + }
|
| +
|
| + /**
|
| + * Set the {@link ContentIntentHandler} for {@link #starContentIntent}.
|
| + * @param handler Handler to inject to {@link #startContentIntent}.
|
| + */
|
| + public void setContentIntentHandler(ContentIntentHandler handler) {
|
| + mContentIntentHandler = handler;
|
| + }
|
| +
|
| + @Override
|
| + public void startContentIntent(Intent intent, String intentUrl, boolean isMainFrame) {
|
| + if (mContentIntentHandler != null) mContentIntentHandler.onIntentUrlReceived(intentUrl);
|
| + }
|
| +
|
| + @Override
|
| + public ViewGroup getContainerView() {
|
| + return mContainerView;
|
| + }
|
| +}
|
|
|