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.app.ActivityManager; | 7 import android.app.ActivityManager; |
8 import android.app.Application; | 8 import android.app.Application; |
9 import android.app.PendingIntent; | 9 import android.app.PendingIntent; |
10 import android.content.Context; | 10 import android.content.Context; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 import org.chromium.chrome.browser.WarmupManager; | 45 import org.chromium.chrome.browser.WarmupManager; |
46 import org.chromium.chrome.browser.device.DeviceClassManager; | 46 import org.chromium.chrome.browser.device.DeviceClassManager; |
47 import org.chromium.chrome.browser.init.ChromeBrowserInitializer; | 47 import org.chromium.chrome.browser.init.ChromeBrowserInitializer; |
48 import org.chromium.chrome.browser.metrics.PageLoadMetrics; | 48 import org.chromium.chrome.browser.metrics.PageLoadMetrics; |
49 import org.chromium.chrome.browser.net.spdyproxy.DataReductionProxySettings; | 49 import org.chromium.chrome.browser.net.spdyproxy.DataReductionProxySettings; |
50 import org.chromium.chrome.browser.preferences.PrefServiceBridge; | 50 import org.chromium.chrome.browser.preferences.PrefServiceBridge; |
51 import org.chromium.chrome.browser.prerender.ExternalPrerenderHandler; | 51 import org.chromium.chrome.browser.prerender.ExternalPrerenderHandler; |
52 import org.chromium.chrome.browser.profiles.Profile; | 52 import org.chromium.chrome.browser.profiles.Profile; |
53 import org.chromium.chrome.browser.util.IntentUtils; | 53 import org.chromium.chrome.browser.util.IntentUtils; |
54 import org.chromium.chrome.browser.util.UrlUtilities; | 54 import org.chromium.chrome.browser.util.UrlUtilities; |
| 55 import org.chromium.content.browser.ChildProcessCreationParams; |
55 import org.chromium.content.browser.ChildProcessLauncher; | 56 import org.chromium.content.browser.ChildProcessLauncher; |
56 import org.chromium.content_public.browser.WebContents; | 57 import org.chromium.content_public.browser.WebContents; |
57 import org.chromium.content_public.common.Referrer; | 58 import org.chromium.content_public.common.Referrer; |
58 | 59 |
59 import java.io.BufferedReader; | 60 import java.io.BufferedReader; |
60 import java.io.FileReader; | 61 import java.io.FileReader; |
61 import java.io.IOException; | 62 import java.io.IOException; |
62 import java.util.List; | 63 import java.util.List; |
63 import java.util.concurrent.Callable; | 64 import java.util.concurrent.Callable; |
64 import java.util.concurrent.ExecutionException; | 65 import java.util.concurrent.ExecutionException; |
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
573 * Note that this methods accepts URLs that don't exactly match the initiall
y | 574 * Note that this methods accepts URLs that don't exactly match the initiall
y |
574 * prerendered URL. More precisely, the #fragment is ignored. In this case, | 575 * prerendered URL. More precisely, the #fragment is ignored. In this case, |
575 * the client needs to navigate to the correct URL after the WebContents | 576 * the client needs to navigate to the correct URL after the WebContents |
576 * swap. This can be tested using {@link UrlUtilities#urlsFragmentsDiffer()}
. | 577 * swap. This can be tested using {@link UrlUtilities#urlsFragmentsDiffer()}
. |
577 * | 578 * |
578 * @param session The Binder object identifying a session. | 579 * @param session The Binder object identifying a session. |
579 * @param url The URL the WebContents is for. | 580 * @param url The URL the WebContents is for. |
580 * @param referrer The referrer to use for |url|. | 581 * @param referrer The referrer to use for |url|. |
581 * @return The prerendered WebContents, or null. | 582 * @return The prerendered WebContents, or null. |
582 */ | 583 */ |
583 WebContents takePrerenderedUrl(CustomTabsSessionToken session, String url, S
tring referrer) { | 584 WebContents takePrerenderedUrl( |
| 585 CustomTabsSessionToken session, String url, String referrer, int chi
ldProcessParamId) { |
584 ThreadUtils.assertOnUiThread(); | 586 ThreadUtils.assertOnUiThread(); |
585 if (mSpeculation == null || session == null || !session.equals(mSpeculat
ion.session)) { | 587 if (mSpeculation == null || session == null || !session.equals(mSpeculat
ion.session) |
| 588 || childProcessParamId != ChildProcessCreationParams.DEFAULT_ID)
{ |
586 return null; | 589 return null; |
587 } | 590 } |
588 | 591 |
589 if (mSpeculation.prefetchOnly) { | 592 if (mSpeculation.prefetchOnly) { |
590 Profile profile = Profile.getLastUsedProfile(); | 593 Profile profile = Profile.getLastUsedProfile(); |
591 new ResourcePrefetchPredictor(profile).stopPrefetching(mSpeculation.
url); | 594 new ResourcePrefetchPredictor(profile).stopPrefetching(mSpeculation.
url); |
592 mSpeculation = null; | 595 mSpeculation = null; |
593 return null; | 596 return null; |
594 } | 597 } |
595 | 598 |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
939 if (IntentHandler.getExtraHeadersFromIntent(extrasIntent) != null) retur
n false; | 942 if (IntentHandler.getExtraHeadersFromIntent(extrasIntent) != null) retur
n false; |
940 if (mExternalPrerenderHandler == null) { | 943 if (mExternalPrerenderHandler == null) { |
941 mExternalPrerenderHandler = new ExternalPrerenderHandler(); | 944 mExternalPrerenderHandler = new ExternalPrerenderHandler(); |
942 } | 945 } |
943 Rect contentBounds = ExternalPrerenderHandler.estimateContentSize(mAppli
cation, true); | 946 Rect contentBounds = ExternalPrerenderHandler.estimateContentSize(mAppli
cation, true); |
944 String referrer = IntentHandler.getReferrerUrlIncludingExtraHeaders(extr
asIntent); | 947 String referrer = IntentHandler.getReferrerUrlIncludingExtraHeaders(extr
asIntent); |
945 if (referrer == null && getReferrerForSession(session) != null) { | 948 if (referrer == null && getReferrerForSession(session) != null) { |
946 referrer = getReferrerForSession(session).getUrl(); | 949 referrer = getReferrerForSession(session).getUrl(); |
947 } | 950 } |
948 if (referrer == null) referrer = ""; | 951 if (referrer == null) referrer = ""; |
949 Pair<WebContents, WebContents> webContentsPair = mExternalPrerenderHandl
er.addPrerender( | 952 Pair<WebContents, WebContents> webContentsPair = |
950 Profile.getLastUsedProfile(), url, referrer, | 953 mExternalPrerenderHandler.addPrerender(Profile.getLastUsedProfil
e(), url, referrer, |
951 contentBounds, | 954 contentBounds, shouldPrerenderOnCellularForSession(sessi
on), |
952 shouldPrerenderOnCellularForSession(session)); | 955 ChildProcessCreationParams.DEFAULT_ID); |
953 if (webContentsPair == null) return false; | 956 if (webContentsPair == null) return false; |
954 WebContents dummyWebContents = webContentsPair.first; | 957 WebContents dummyWebContents = webContentsPair.first; |
955 if (webContentsPair.second != null) { | 958 if (webContentsPair.second != null) { |
956 mClientManager.resetPostMessageHandlerForSession(session, webContent
sPair.second); | 959 mClientManager.resetPostMessageHandlerForSession(session, webContent
sPair.second); |
957 } | 960 } |
958 if (throttle) mClientManager.registerPrerenderRequest(uid, url); | 961 if (throttle) mClientManager.registerPrerenderRequest(uid, url); |
959 mSpeculation = SpeculationParams.forPrerender( | 962 mSpeculation = SpeculationParams.forPrerender( |
960 session, url, dummyWebContents, referrer, extras); | 963 session, url, dummyWebContents, referrer, extras); |
961 | 964 |
962 RecordHistogram.recordBooleanHistogram("CustomTabs.PrerenderSessionUsesD
efaultParameters", | 965 RecordHistogram.recordBooleanHistogram("CustomTabs.PrerenderSessionUsesD
efaultParameters", |
(...skipping 10 matching lines...) Expand all Loading... |
973 @VisibleForTesting | 976 @VisibleForTesting |
974 void ban(Context context, int uid) { | 977 void ban(Context context, int uid) { |
975 mClientManager.ban(uid); | 978 mClientManager.ban(uid); |
976 } | 979 } |
977 | 980 |
978 @VisibleForTesting | 981 @VisibleForTesting |
979 void setForcePrerender(boolean force) { | 982 void setForcePrerender(boolean force) { |
980 mForcePrerenderForTesting = force; | 983 mForcePrerenderForTesting = force; |
981 } | 984 } |
982 } | 985 } |
OLD | NEW |