| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 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 | 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.content.Intent; | |
| 8 import android.view.ViewGroup; | 7 import android.view.ViewGroup; |
| 9 | 8 |
| 10 import org.chromium.ui.base.ViewAndroidDelegate; | 9 import org.chromium.ui.base.ViewAndroidDelegate; |
| 11 | 10 |
| 12 /** | 11 /** |
| 13 * Implementation of the abstract class {@link ViewAndroidDelegate} for content
shell. | 12 * Implementation of the abstract class {@link ViewAndroidDelegate} for content
shell. |
| 14 * Extended for testing. | 13 * Extended for testing. |
| 15 */ | 14 */ |
| 16 public class ShellViewAndroidDelegate extends ViewAndroidDelegate { | 15 public class ShellViewAndroidDelegate extends ViewAndroidDelegate { |
| 17 private final ViewGroup mContainerView; | 16 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 | 17 |
| 31 public ShellViewAndroidDelegate(ViewGroup containerView) { | 18 public ShellViewAndroidDelegate(ViewGroup containerView) { |
| 32 mContainerView = containerView; | 19 mContainerView = containerView; |
| 33 } | 20 } |
| 34 | 21 |
| 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 | 22 @Override |
| 49 public ViewGroup getContainerView() { | 23 public ViewGroup getContainerView() { |
| 50 return mContainerView; | 24 return mContainerView; |
| 51 } | 25 } |
| 52 } | 26 } |
| OLD | NEW |