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 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
511 if (referrerUrl == null) { | 511 if (referrerUrl == null) { |
512 Referrer referrer = customTabsConnection.getReferrerForSession(mSess
ion); | 512 Referrer referrer = customTabsConnection.getReferrerForSession(mSess
ion); |
513 if (referrer != null) referrerUrl = referrer.getUrl(); | 513 if (referrer != null) referrerUrl = referrer.getUrl(); |
514 } | 514 } |
515 Tab tab = new Tab(TabIdManager.getInstance().generateValidId(Tab.INVALID
_TAB_ID), | 515 Tab tab = new Tab(TabIdManager.getInstance().generateValidId(Tab.INVALID
_TAB_ID), |
516 Tab.INVALID_TAB_ID, false, this, getWindowAndroid(), | 516 Tab.INVALID_TAB_ID, false, this, getWindowAndroid(), |
517 TabLaunchType.FROM_EXTERNAL_APP, null, null); | 517 TabLaunchType.FROM_EXTERNAL_APP, null, null); |
518 tab.setAppAssociatedWith(customTabsConnection.getClientPackageNameForSes
sion(mSession)); | 518 tab.setAppAssociatedWith(customTabsConnection.getClientPackageNameForSes
sion(mSession)); |
519 | 519 |
520 mPrerenderedUrl = customTabsConnection.getPrerenderedUrl(mSession); | 520 mPrerenderedUrl = customTabsConnection.getPrerenderedUrl(mSession); |
| 521 CustomTabDelegateFactory delegateFactory = |
| 522 new CustomTabDelegateFactory(mIntentDataProvider.shouldEnableUrl
BarHiding(), |
| 523 mIntentDataProvider.isOpenedByChrome(), |
| 524 getFullscreenManager().getBrowserVisibilityDelegate()); |
521 int webContentsStateOnLaunch = WEBCONTENTS_STATE_NO_WEBCONTENTS; | 525 int webContentsStateOnLaunch = WEBCONTENTS_STATE_NO_WEBCONTENTS; |
522 WebContents webContents = | 526 WebContents webContents = customTabsConnection.takePrerenderedUrl( |
523 customTabsConnection.takePrerenderedUrl(mSession, url, referrerU
rl); | 527 mSession, url, referrerUrl, delegateFactory.getChildProcessParam
Id()); |
524 mHasPrerendered = webContents != null; | 528 mHasPrerendered = webContents != null; |
525 if (mHasPrerendered) webContentsStateOnLaunch = WEBCONTENTS_STATE_PREREN
DERED_WEBCONTENTS; | 529 if (mHasPrerendered) webContentsStateOnLaunch = WEBCONTENTS_STATE_PREREN
DERED_WEBCONTENTS; |
526 if (!mHasPrerendered) { | 530 if (!mHasPrerendered) { |
527 webContents = WarmupManager.getInstance().takeSpareWebContents(false
, false); | 531 webContents = WarmupManager.getInstance().takeSpareWebContents( |
| 532 false, false, delegateFactory.getChildProcessParamId()); |
528 if (webContents != null) webContentsStateOnLaunch = WEBCONTENTS_STAT
E_SPARE_WEBCONTENTS; | 533 if (webContents != null) webContentsStateOnLaunch = WEBCONTENTS_STAT
E_SPARE_WEBCONTENTS; |
529 } | 534 } |
530 RecordHistogram.recordEnumeratedHistogram("CustomTabs.WebContentsStateOn
Launch", | 535 RecordHistogram.recordEnumeratedHistogram("CustomTabs.WebContentsStateOn
Launch", |
531 webContentsStateOnLaunch, WEBCONTENTS_STATE_MAX); | 536 webContentsStateOnLaunch, WEBCONTENTS_STATE_MAX); |
532 if (webContents == null) webContents = WebContentsFactory.createWebConte
nts(false, false); | 537 if (webContents == null) { |
| 538 webContents = WebContentsFactory.createWebContents( |
| 539 delegateFactory.getChildProcessParamId(), false, false); |
| 540 } |
533 if (!mHasPrerendered) { | 541 if (!mHasPrerendered) { |
534 customTabsConnection.resetPostMessageHandlerForSession(mSession, web
Contents); | 542 customTabsConnection.resetPostMessageHandlerForSession(mSession, web
Contents); |
535 } | 543 } |
536 tab.initialize( | 544 tab.initialize(webContents, getTabContentManager(), delegateFactory, fal
se, false); |
537 webContents, getTabContentManager(), | |
538 new CustomTabDelegateFactory( | |
539 mIntentDataProvider.shouldEnableUrlBarHiding(), | |
540 mIntentDataProvider.isOpenedByChrome(), | |
541 getFullscreenManager().getBrowserVisibilityDelegate()), | |
542 false, false); | |
543 initializeMainTab(tab); | 545 initializeMainTab(tab); |
544 return tab; | 546 return tab; |
545 } | 547 } |
546 | 548 |
547 private void initializeMainTab(Tab tab) { | 549 private void initializeMainTab(Tab tab) { |
548 tab.getTabRedirectHandler().updateIntent(getIntent()); | 550 tab.getTabRedirectHandler().updateIntent(getIntent()); |
549 tab.getView().requestFocus(); | 551 tab.getView().requestFocus(); |
550 mTabObserver = new CustomTabObserver( | 552 mTabObserver = new CustomTabObserver( |
551 getApplication(), mSession, mIntentDataProvider.isOpenedByChrome
()); | 553 getApplication(), mSession, mIntentDataProvider.isOpenedByChrome
()); |
552 | 554 |
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1069 Intent intent = ChromeLauncherActivity.createCustomTabActivityIntent( | 1071 Intent intent = ChromeLauncherActivity.createCustomTabActivityIntent( |
1070 context, customTabIntent.intent, false); | 1072 context, customTabIntent.intent, false); |
1071 intent.setPackage(context.getPackageName()); | 1073 intent.setPackage(context.getPackageName()); |
1072 intent.putExtra(CustomTabIntentDataProvider.EXTRA_IS_INFO_PAGE, true); | 1074 intent.putExtra(CustomTabIntentDataProvider.EXTRA_IS_INFO_PAGE, true); |
1073 intent.putExtra(Browser.EXTRA_APPLICATION_ID, context.getPackageName()); | 1075 intent.putExtra(Browser.EXTRA_APPLICATION_ID, context.getPackageName()); |
1074 IntentHandler.addTrustedIntentExtras(intent); | 1076 IntentHandler.addTrustedIntentExtras(intent); |
1075 | 1077 |
1076 context.startActivity(intent); | 1078 context.startActivity(intent); |
1077 } | 1079 } |
1078 } | 1080 } |
OLD | NEW |