| 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.chrome.browser.tab; |
| 6 |
| 7 import android.content.ActivityNotFoundException; |
| 8 import android.content.Intent; |
| 9 import android.view.ViewGroup; |
| 10 |
| 11 import org.chromium.base.Log; |
| 12 import org.chromium.base.metrics.RecordUserAction; |
| 13 import org.chromium.ui.base.ViewAndroidDelegate; |
| 14 |
| 15 /** |
| 16 * Implementation of the abstract class {@link ViewAndroidDelegate} for Chrome. |
| 17 */ |
| 18 class TabViewAndroidDelegate extends ViewAndroidDelegate { |
| 19 /** Used for logging. */ |
| 20 private static final String TAG = "TabVAD"; |
| 21 |
| 22 private final Tab mTab; |
| 23 private final ViewGroup mContainerView; |
| 24 |
| 25 TabViewAndroidDelegate(Tab tab, ViewGroup containerView) { |
| 26 mTab = tab; |
| 27 mContainerView = containerView; |
| 28 } |
| 29 |
| 30 @Override |
| 31 public void onBackgroundColorChanged(int color) { |
| 32 mTab.onBackgroundColorChanged(color); |
| 33 } |
| 34 |
| 35 @Override |
| 36 public void onTopControlsChanged(float topControlsOffsetY, float topContentO
ffsetY) { |
| 37 mTab.onOffsetsChanged(topControlsOffsetY, Float.NaN, topContentOffsetY); |
| 38 } |
| 39 |
| 40 @Override |
| 41 public void onBottomControlsChanged(float bottomControlsOffsetY, float botto
mContentOffsetY) { |
| 42 mTab.onOffsetsChanged(Float.NaN, bottomControlsOffsetY, Float.NaN); |
| 43 } |
| 44 |
| 45 @Override |
| 46 public void onStartContentIntent(String intentUrl, boolean isMainFrame) { |
| 47 Intent intent; |
| 48 // Perform generic parsing of the URI to turn it into an Intent. |
| 49 try { |
| 50 intent = Intent.parseUri(intentUrl, Intent.URI_INTENT_SCHEME); |
| 51 |
| 52 String scheme = intent.getScheme(); |
| 53 if (!isAcceptableContentIntentScheme(scheme)) { |
| 54 Log.w(TAG, "Invalid scheme for URI %s", intentUrl); |
| 55 return; |
| 56 } |
| 57 |
| 58 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
| 59 } catch (Exception ex) { |
| 60 Log.w(TAG, "Bad URI %s", intentUrl, ex); |
| 61 return; |
| 62 } |
| 63 |
| 64 try { |
| 65 RecordUserAction.record("Android.ContentDetectorActivated"); |
| 66 mTab.getActivity().startActivity(intent); |
| 67 } catch (ActivityNotFoundException ex) { |
| 68 Log.w(TAG, "No application can handle %s", intentUrl); |
| 69 } |
| 70 } |
| 71 |
| 72 @Override |
| 73 public ViewGroup getContainerView() { |
| 74 return mContainerView; |
| 75 } |
| 76 } |
| OLD | NEW |