| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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.chrome.browser.customtabs; | 5 package org.chromium.chrome.browser.customtabs; |
| 6 | 6 |
| 7 import android.content.Context; | 7 import android.content.Context; |
| 8 import android.content.Intent; | 8 import android.content.Intent; |
| 9 import android.content.pm.ResolveInfo; | 9 import android.content.pm.ResolveInfo; |
| 10 import android.os.IBinder; | 10 import android.os.IBinder; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 import org.chromium.chrome.R; | 21 import org.chromium.chrome.R; |
| 22 import org.chromium.chrome.browser.ChromeActivity; | 22 import org.chromium.chrome.browser.ChromeActivity; |
| 23 import org.chromium.chrome.browser.UrlUtilities; | 23 import org.chromium.chrome.browser.UrlUtilities; |
| 24 import org.chromium.chrome.browser.WebContentsFactory; | 24 import org.chromium.chrome.browser.WebContentsFactory; |
| 25 import org.chromium.chrome.browser.banners.AppBannerManager; | 25 import org.chromium.chrome.browser.banners.AppBannerManager; |
| 26 import org.chromium.chrome.browser.contextmenu.ChromeContextMenuPopulator; | 26 import org.chromium.chrome.browser.contextmenu.ChromeContextMenuPopulator; |
| 27 import org.chromium.chrome.browser.contextmenu.ContextMenuParams; | 27 import org.chromium.chrome.browser.contextmenu.ContextMenuParams; |
| 28 import org.chromium.chrome.browser.contextmenu.ContextMenuPopulator; | 28 import org.chromium.chrome.browser.contextmenu.ContextMenuPopulator; |
| 29 import org.chromium.chrome.browser.externalnav.ExternalNavigationDelegateImpl; | 29 import org.chromium.chrome.browser.externalnav.ExternalNavigationDelegateImpl; |
| 30 import org.chromium.chrome.browser.externalnav.ExternalNavigationHandler; | 30 import org.chromium.chrome.browser.externalnav.ExternalNavigationHandler; |
| 31 import org.chromium.chrome.browser.ssl.ConnectionSecurityLevel; |
| 31 import org.chromium.chrome.browser.tab.ChromeTab; | 32 import org.chromium.chrome.browser.tab.ChromeTab; |
| 32 import org.chromium.chrome.browser.tab.EmptyTabObserver; | 33 import org.chromium.chrome.browser.tab.EmptyTabObserver; |
| 33 import org.chromium.chrome.browser.tab.Tab; | 34 import org.chromium.chrome.browser.tab.Tab; |
| 34 import org.chromium.chrome.browser.tab.TabIdManager; | 35 import org.chromium.chrome.browser.tab.TabIdManager; |
| 35 import org.chromium.chrome.browser.tabmodel.TabModel.TabLaunchType; | 36 import org.chromium.chrome.browser.tabmodel.TabModel.TabLaunchType; |
| 36 import org.chromium.content_public.browser.LoadUrlParams; | 37 import org.chromium.content_public.browser.LoadUrlParams; |
| 37 import org.chromium.content_public.browser.WebContents; | 38 import org.chromium.content_public.browser.WebContents; |
| 38 import org.chromium.ui.base.WindowAndroid; | 39 import org.chromium.ui.base.WindowAndroid; |
| 39 | 40 |
| 40 import java.util.concurrent.TimeUnit; | 41 import java.util.concurrent.TimeUnit; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 71 @Override | 72 @Override |
| 72 public void onLoadUrl(Tab tab, LoadUrlParams params, int loadType) { | 73 public void onLoadUrl(Tab tab, LoadUrlParams params, int loadType) { |
| 73 mCustomTabsConnection.registerLaunch(mSession, params.getUrl()); | 74 mCustomTabsConnection.registerLaunch(mSession, params.getUrl()); |
| 74 } | 75 } |
| 75 | 76 |
| 76 @Override | 77 @Override |
| 77 public void onPageLoadStarted(Tab tab, String url) { | 78 public void onPageLoadStarted(Tab tab, String url) { |
| 78 if (mCurrentState == STATE_WAITING_LOAD_START) { | 79 if (mCurrentState == STATE_WAITING_LOAD_START) { |
| 79 mPageLoadStartedTimestamp = SystemClock.elapsedRealtime(); | 80 mPageLoadStartedTimestamp = SystemClock.elapsedRealtime(); |
| 80 mCurrentState = STATE_WAITING_LOAD_FINISH; | 81 mCurrentState = STATE_WAITING_LOAD_FINISH; |
| 82 } else if (mCurrentState == STATE_WAITING_LOAD_FINISH) { |
| 83 mCustomTabsConnection.notifyNavigationEvent( |
| 84 mSession, CustomTabsCallback.NAVIGATION_ABORTED); |
| 85 mPageLoadStartedTimestamp = SystemClock.elapsedRealtime(); |
| 81 } | 86 } |
| 82 mCustomTabsConnection.notifyNavigationEvent( | 87 mCustomTabsConnection.notifyNavigationEvent( |
| 83 mSession, CustomTabsCallback.NAVIGATION_STARTED); | 88 mSession, CustomTabsCallback.NAVIGATION_STARTED); |
| 84 } | 89 } |
| 85 | 90 |
| 86 @Override | 91 @Override |
| 92 public void onShown(Tab tab) { |
| 93 mCustomTabsConnection.notifyNavigationEvent( |
| 94 mSession, CustomTabsCallback.TAB_SHOWN); |
| 95 } |
| 96 |
| 97 @Override |
| 98 public void onHidden(Tab tab) { |
| 99 mCustomTabsConnection.notifyNavigationEvent( |
| 100 mSession, CustomTabsCallback.TAB_HIDDEN); |
| 101 } |
| 102 |
| 103 @Override |
| 87 public void onPageLoadFinished(Tab tab) { | 104 public void onPageLoadFinished(Tab tab) { |
| 88 long pageLoadFinishedTimestamp = SystemClock.elapsedRealtime(); | 105 long pageLoadFinishedTimestamp = SystemClock.elapsedRealtime(); |
| 89 mCustomTabsConnection.notifyNavigationEvent( | 106 mCustomTabsConnection.notifyNavigationEvent( |
| 90 mSession, CustomTabsCallback.NAVIGATION_FINISHED); | 107 mSession, CustomTabsCallback.NAVIGATION_FINISHED); |
| 91 // Both histograms (commit and PLT) are reported here, to make sure | 108 // Both histograms (commit and PLT) are reported here, to make sure |
| 92 // that they are always recorded together, and that we only record | 109 // that they are always recorded together, and that we only record |
| 93 // commits for successful navigations. | 110 // commits for successful navigations. |
| 94 if (mCurrentState == STATE_WAITING_LOAD_FINISH && mIntentReceivedTim
estamp > 0) { | 111 if (mCurrentState == STATE_WAITING_LOAD_FINISH && mIntentReceivedTim
estamp > 0) { |
| 95 long timeToPageLoadStartedMs = mPageLoadStartedTimestamp - mInte
ntReceivedTimestamp; | 112 long timeToPageLoadStartedMs = mPageLoadStartedTimestamp - mInte
ntReceivedTimestamp; |
| 96 long timeToPageLoadFinishedMs = | 113 long timeToPageLoadFinishedMs = |
| 97 pageLoadFinishedTimestamp - mIntentReceivedTimestamp; | 114 pageLoadFinishedTimestamp - mIntentReceivedTimestamp; |
| 98 // Same bounds and bucket count as "Startup.FirstCommitNavigatio
nTime" | 115 // Same bounds and bucket count as "Startup.FirstCommitNavigatio
nTime" |
| 99 RecordHistogram.recordCustomTimesHistogram( | 116 RecordHistogram.recordCustomTimesHistogram( |
| 100 "CustomTabs.IntentToFirstCommitNavigationTime", timeToPa
geLoadStartedMs, | 117 "CustomTabs.IntentToFirstCommitNavigationTime", timeToPa
geLoadStartedMs, |
| 101 1, TimeUnit.MINUTES.toMillis(1), TimeUnit.MILLISECONDS,
225); | 118 1, TimeUnit.MINUTES.toMillis(1), TimeUnit.MILLISECONDS,
225); |
| 102 // Same bounds and bucket count as PLT histograms. | 119 // Same bounds and bucket count as PLT histograms. |
| 103 RecordHistogram.recordCustomTimesHistogram("CustomTabs.IntentToP
ageLoadedTime", | 120 RecordHistogram.recordCustomTimesHistogram("CustomTabs.IntentToP
ageLoadedTime", |
| 104 timeToPageLoadFinishedMs, 10, TimeUnit.MINUTES.toMillis(
10), | 121 timeToPageLoadFinishedMs, 10, TimeUnit.MINUTES.toMillis(
10), |
| 105 TimeUnit.MILLISECONDS, 100); | 122 TimeUnit.MILLISECONDS, 100); |
| 106 } | 123 } |
| 107 resetPageLoadTracking(); | 124 resetPageLoadTracking(); |
| 108 } | 125 } |
| 109 | 126 |
| 110 @Override | 127 @Override |
| 128 public void onDidAttachInterstitialPage(Tab tab) { |
| 129 if (tab.getSecurityLevel() != ConnectionSecurityLevel.SECURITY_ERROR
) return; |
| 130 resetPageLoadTracking(); |
| 131 mCustomTabsConnection.notifyNavigationEvent( |
| 132 mSession, CustomTabsCallback.NAVIGATION_FAILED); |
| 133 } |
| 134 |
| 135 @Override |
| 111 public void onPageLoadFailed(Tab tab, int errorCode) { | 136 public void onPageLoadFailed(Tab tab, int errorCode) { |
| 112 resetPageLoadTracking(); | 137 resetPageLoadTracking(); |
| 138 mCustomTabsConnection.notifyNavigationEvent( |
| 139 mSession, CustomTabsCallback.NAVIGATION_FAILED); |
| 113 } | 140 } |
| 114 | 141 |
| 115 private void resetPageLoadTracking() { | 142 private void resetPageLoadTracking() { |
| 116 mCurrentState = STATE_RESET; | 143 mCurrentState = STATE_RESET; |
| 117 mIntentReceivedTimestamp = -1; | 144 mIntentReceivedTimestamp = -1; |
| 118 } | 145 } |
| 119 } | 146 } |
| 120 | 147 |
| 121 private ExternalNavigationHandler mNavigationHandler; | 148 private ExternalNavigationHandler mNavigationHandler; |
| 122 private CustomTabNavigationDelegate mNavigationDelegate; | 149 private CustomTabNavigationDelegate mNavigationDelegate; |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 // See http://crbug.com/369574. | 326 // See http://crbug.com/369574. |
| 300 if (e.getCause() != null && e.getCause() instanceof TransactionTooLa
rgeException) { | 327 if (e.getCause() != null && e.getCause() instanceof TransactionTooLa
rgeException) { |
| 301 Log.e(TAG, "Could not resolve Activity for intent " + intent.toS
tring(), e); | 328 Log.e(TAG, "Could not resolve Activity for intent " + intent.toS
tring(), e); |
| 302 } else { | 329 } else { |
| 303 throw e; | 330 throw e; |
| 304 } | 331 } |
| 305 } | 332 } |
| 306 } | 333 } |
| 307 | 334 |
| 308 } | 335 } |
| OLD | NEW |