| 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.PendingIntent; | 7 import android.app.PendingIntent; |
| 8 import android.content.Context; | 8 import android.content.Context; |
| 9 import android.content.Intent; | 9 import android.content.Intent; |
| 10 import android.content.SharedPreferences; | 10 import android.content.SharedPreferences; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 import org.chromium.chrome.browser.tabmodel.ChromeTabCreator; | 67 import org.chromium.chrome.browser.tabmodel.ChromeTabCreator; |
| 68 import org.chromium.chrome.browser.tabmodel.EmptyTabModelObserver; | 68 import org.chromium.chrome.browser.tabmodel.EmptyTabModelObserver; |
| 69 import org.chromium.chrome.browser.tabmodel.TabModel.TabLaunchType; | 69 import org.chromium.chrome.browser.tabmodel.TabModel.TabLaunchType; |
| 70 import org.chromium.chrome.browser.tabmodel.TabModelObserver; | 70 import org.chromium.chrome.browser.tabmodel.TabModelObserver; |
| 71 import org.chromium.chrome.browser.tabmodel.TabModelSelector; | 71 import org.chromium.chrome.browser.tabmodel.TabModelSelector; |
| 72 import org.chromium.chrome.browser.tabmodel.TabModelSelectorImpl; | 72 import org.chromium.chrome.browser.tabmodel.TabModelSelectorImpl; |
| 73 import org.chromium.chrome.browser.tabmodel.TabReparentingParams; | 73 import org.chromium.chrome.browser.tabmodel.TabReparentingParams; |
| 74 import org.chromium.chrome.browser.toolbar.ToolbarControlContainer; | 74 import org.chromium.chrome.browser.toolbar.ToolbarControlContainer; |
| 75 import org.chromium.chrome.browser.util.ColorUtils; | 75 import org.chromium.chrome.browser.util.ColorUtils; |
| 76 import org.chromium.chrome.browser.util.UrlUtilities; | 76 import org.chromium.chrome.browser.util.UrlUtilities; |
| 77 import org.chromium.chrome.browser.vr_shell.VrShellDelegate; |
| 77 import org.chromium.chrome.browser.widget.findinpage.FindToolbarManager; | 78 import org.chromium.chrome.browser.widget.findinpage.FindToolbarManager; |
| 78 import org.chromium.components.dom_distiller.core.DomDistillerUrlUtils; | 79 import org.chromium.components.dom_distiller.core.DomDistillerUrlUtils; |
| 79 import org.chromium.content_public.browser.LoadUrlParams; | 80 import org.chromium.content_public.browser.LoadUrlParams; |
| 80 import org.chromium.content_public.browser.WebContents; | 81 import org.chromium.content_public.browser.WebContents; |
| 81 import org.chromium.ui.base.PageTransition; | 82 import org.chromium.ui.base.PageTransition; |
| 82 import org.chromium.ui.base.WindowAndroid; | 83 import org.chromium.ui.base.WindowAndroid; |
| 83 | 84 |
| 84 /** | 85 /** |
| 85 * The activity for custom tabs. It will be launched on top of a client's task. | 86 * The activity for custom tabs. It will be launched on top of a client's task. |
| 86 */ | 87 */ |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 | 122 |
| 122 private boolean mUsingPrerender; | 123 private boolean mUsingPrerender; |
| 123 private boolean mUsingHiddenTab; | 124 private boolean mUsingHiddenTab; |
| 124 | 125 |
| 125 private boolean mIsClosing; | 126 private boolean mIsClosing; |
| 126 | 127 |
| 127 // This boolean is used to do a hack in navigation history for | 128 // This boolean is used to do a hack in navigation history for |
| 128 // prerender and hidden tab loads with unmatching fragments. | 129 // prerender and hidden tab loads with unmatching fragments. |
| 129 private boolean mIsFirstLoad; | 130 private boolean mIsFirstLoad; |
| 130 | 131 |
| 132 private boolean mIsDaydreamIntent; |
| 133 |
| 131 private static class PageLoadMetricsObserver implements PageLoadMetrics.Obse
rver { | 134 private static class PageLoadMetricsObserver implements PageLoadMetrics.Obse
rver { |
| 132 private final CustomTabsConnection mConnection; | 135 private final CustomTabsConnection mConnection; |
| 133 private final CustomTabsSessionToken mSession; | 136 private final CustomTabsSessionToken mSession; |
| 134 private final Tab mTab; | 137 private final Tab mTab; |
| 135 | 138 |
| 136 public PageLoadMetricsObserver(CustomTabsConnection connection, | 139 public PageLoadMetricsObserver(CustomTabsConnection connection, |
| 137 CustomTabsSessionToken session, Tab tab) { | 140 CustomTabsSessionToken session, Tab tab) { |
| 138 mConnection = connection; | 141 mConnection = connection; |
| 139 mSession = session; | 142 mSession = session; |
| 140 mTab = tab; | 143 mTab = tab; |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 | 293 |
| 291 @Override | 294 @Override |
| 292 public boolean isCustomTab() { | 295 public boolean isCustomTab() { |
| 293 return true; | 296 return true; |
| 294 } | 297 } |
| 295 | 298 |
| 296 @Override | 299 @Override |
| 297 public void onStart() { | 300 public void onStart() { |
| 298 super.onStart(); | 301 super.onStart(); |
| 299 mIsClosing = false; | 302 mIsClosing = false; |
| 303 mIsDaydreamIntent = VrShellDelegate.isDaydreamVrIntent(getIntent()); |
| 300 CustomTabsConnection.getInstance(getApplication()) | 304 CustomTabsConnection.getInstance(getApplication()) |
| 301 .keepAliveForSession(mIntentDataProvider.getSession(), | 305 .keepAliveForSession(mIntentDataProvider.getSession(), |
| 302 mIntentDataProvider.getKeepAliveServiceIntent()); | 306 mIntentDataProvider.getKeepAliveServiceIntent()); |
| 303 } | 307 } |
| 304 | 308 |
| 305 @Override | 309 @Override |
| 306 public void onStop() { | 310 public void onStop() { |
| 307 super.onStop(); | 311 super.onStop(); |
| 308 CustomTabsConnection.getInstance(getApplication()) | 312 CustomTabsConnection.getInstance(getApplication()) |
| 309 .dontKeepAliveForSession(mIntentDataProvider.getSession()); | 313 .dontKeepAliveForSession(mIntentDataProvider.getSession()); |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 525 if (!mHasCreatedTabEarly && !successfulStateRestore) { | 529 if (!mHasCreatedTabEarly && !successfulStateRestore) { |
| 526 loadUrlInTab(mMainTab, new LoadUrlParams(url), | 530 loadUrlInTab(mMainTab, new LoadUrlParams(url), |
| 527 IntentHandler.getTimestampFromIntent(getIntent())); | 531 IntentHandler.getTimestampFromIntent(getIntent())); |
| 528 } | 532 } |
| 529 | 533 |
| 530 // Put Sync in the correct state by calling tab state initialized. crbug
.com/581811. | 534 // Put Sync in the correct state by calling tab state initialized. crbug
.com/581811. |
| 531 getTabModelSelector().markTabStateInitialized(); | 535 getTabModelSelector().markTabStateInitialized(); |
| 532 super.finishNativeInitialization(); | 536 super.finishNativeInitialization(); |
| 533 } | 537 } |
| 534 | 538 |
| 539 @Override |
| 540 public final boolean shouldAutoPresent() { |
| 541 return mIsDaydreamIntent; |
| 542 } |
| 543 |
| 535 /** | 544 /** |
| 536 * Encapsulates CustomTabsConnection#takeHiddenTab() | 545 * Encapsulates CustomTabsConnection#takeHiddenTab() |
| 537 * with additional initialization logic. | 546 * with additional initialization logic. |
| 538 */ | 547 */ |
| 539 private Tab getHiddenTab(CustomTabsConnection connection) { | 548 private Tab getHiddenTab(CustomTabsConnection connection) { |
| 540 String url = getUrlToLoad(); | 549 String url = getUrlToLoad(); |
| 541 String referrerUrl = connection.getReferrer(mSession, getIntent()); | 550 String referrerUrl = connection.getReferrer(mSession, getIntent()); |
| 542 Tab tab = connection.takeHiddenTab(mSession, url, referrerUrl); | 551 Tab tab = connection.takeHiddenTab(mSession, url, referrerUrl); |
| 543 mUsingHiddenTab = tab != null; | 552 mUsingHiddenTab = tab != null; |
| 544 if (!mUsingHiddenTab) return null; | 553 if (!mUsingHiddenTab) return null; |
| (...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1142 Intent intent = ChromeLauncherActivity.createCustomTabActivityIntent( | 1151 Intent intent = ChromeLauncherActivity.createCustomTabActivityIntent( |
| 1143 context, customTabIntent.intent, false); | 1152 context, customTabIntent.intent, false); |
| 1144 intent.setPackage(context.getPackageName()); | 1153 intent.setPackage(context.getPackageName()); |
| 1145 intent.putExtra(CustomTabIntentDataProvider.EXTRA_IS_INFO_PAGE, true); | 1154 intent.putExtra(CustomTabIntentDataProvider.EXTRA_IS_INFO_PAGE, true); |
| 1146 intent.putExtra(Browser.EXTRA_APPLICATION_ID, context.getPackageName()); | 1155 intent.putExtra(Browser.EXTRA_APPLICATION_ID, context.getPackageName()); |
| 1147 IntentHandler.addTrustedIntentExtras(intent); | 1156 IntentHandler.addTrustedIntentExtras(intent); |
| 1148 | 1157 |
| 1149 context.startActivity(intent); | 1158 context.startActivity(intent); |
| 1150 } | 1159 } |
| 1151 } | 1160 } |
| OLD | NEW |