| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 package org.chromium.content_shell; |
| 6 |
| 7 import android.content.Intent; |
| 8 import android.view.ViewGroup; |
| 9 |
| 10 import org.chromium.ui.base.ViewAndroidDelegate; |
| 11 |
| 12 /** |
| 13 * Implementation of the abstract class {@link ViewAndroidDelegate} for content
shell. |
| 14 * Extended for testing. |
| 15 */ |
| 16 public class ShellViewAndroidDelegate extends ViewAndroidDelegate { |
| 17 private final ViewGroup mContainerView; |
| 18 private ContentIntentHandler mContentIntentHandler; |
| 19 |
| 20 /** |
| 21 * Interface used to define/modify what {@link #startContentIntent} does. |
| 22 */ |
| 23 public interface ContentIntentHandler { |
| 24 /** |
| 25 * Called when intent url from content is received. |
| 26 * @param intentUrl intent url. |
| 27 */ |
| 28 void onIntentUrlReceived(String intentUrl); |
| 29 } |
| 30 |
| 31 public ShellViewAndroidDelegate(ViewGroup containerView) { |
| 32 mContainerView = containerView; |
| 33 } |
| 34 |
| 35 /** |
| 36 * Set the {@link ContentIntentHandler} for {@link #starContentIntent}. |
| 37 * @param handler Handler to inject to {@link #startContentIntent}. |
| 38 */ |
| 39 public void setContentIntentHandler(ContentIntentHandler handler) { |
| 40 mContentIntentHandler = handler; |
| 41 } |
| 42 |
| 43 @Override |
| 44 public void startContentIntent(Intent intent, String intentUrl, boolean isMa
inFrame) { |
| 45 if (mContentIntentHandler != null) mContentIntentHandler.onIntentUrlRece
ived(intentUrl); |
| 46 } |
| 47 |
| 48 @Override |
| 49 public ViewGroup getContainerView() { |
| 50 return mContainerView; |
| 51 } |
| 52 } |
| OLD | NEW |