OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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.tab; | 5 package org.chromium.chrome.browser.tab; |
6 | 6 |
7 import android.app.Activity; | 7 import android.app.Activity; |
8 import android.content.Context; | 8 import android.content.Context; |
9 import android.content.Intent; | 9 import android.content.Intent; |
10 import android.content.res.Resources; | 10 import android.content.res.Resources; |
(...skipping 1471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1482 /** | 1482 /** |
1483 * Begins the tab reparenting process. Detaches the tab from its current act
ivity and fires | 1483 * Begins the tab reparenting process. Detaches the tab from its current act
ivity and fires |
1484 * an Intent to reparent the tab into its new host activity. | 1484 * an Intent to reparent the tab into its new host activity. |
1485 * | 1485 * |
1486 * @param intent An optional intent with the desired component, flags, or ex
tras to use when | 1486 * @param intent An optional intent with the desired component, flags, or ex
tras to use when |
1487 * launching the new host activity. This intent's URI and acti
on will be | 1487 * launching the new host activity. This intent's URI and acti
on will be |
1488 * overriden. This may be null if no intent customization is n
eeded. | 1488 * overriden. This may be null if no intent customization is n
eeded. |
1489 * @param startActivityOptions Options to pass to {@link Activity#startActiv
ity(Intent, Bundle)} | 1489 * @param startActivityOptions Options to pass to {@link Activity#startActiv
ity(Intent, Bundle)} |
1490 * @param finalizeCallback A callback that will be called after the tab is a
ttached to the new | 1490 * @param finalizeCallback A callback that will be called after the tab is a
ttached to the new |
1491 * host activity in {@link #attachAndFinishReparenti
ng}. | 1491 * host activity in {@link #attachAndFinishReparenti
ng}. |
| 1492 * @param stayInChrome Whether the user should stay in Chrome after the tab
is reparented. |
1492 * @return Whether reparenting succeeded. If false, the tab was not removed
and the intent was | 1493 * @return Whether reparenting succeeded. If false, the tab was not removed
and the intent was |
1493 * not fired. | 1494 * not fired. |
1494 */ | 1495 */ |
1495 public boolean detachAndStartReparenting(Intent intent, Bundle startActivity
Options, | 1496 public boolean detachAndStartReparenting(Intent intent, Bundle startActivity
Options, |
1496 Runnable finalizeCallback) { | 1497 Runnable finalizeCallback, boolean stayInChrome) { |
1497 ChromeActivity activity = getActivity(); | 1498 ChromeActivity activity = getActivity(); |
1498 if (activity == null) return false; | 1499 if (activity == null) return false; |
1499 | 1500 |
1500 if (intent == null) intent = new Intent(); | 1501 if (intent == null) intent = new Intent(); |
1501 intent.setPackage(activity.getPackageName()); | 1502 intent.setPackage(activity.getPackageName()); |
1502 intent.setAction(Intent.ACTION_VIEW); | 1503 intent.setAction(Intent.ACTION_VIEW); |
1503 if (TextUtils.isEmpty(intent.getDataString())) intent.setData(Uri.parse(
getUrl())); | 1504 if (TextUtils.isEmpty(intent.getDataString())) intent.setData(Uri.parse(
getUrl())); |
1504 if (isIncognito()) { | 1505 if (isIncognito()) { |
1505 intent.putExtra(IntentHandler.EXTRA_OPEN_NEW_INCOGNITO_TAB, true); | 1506 intent.putExtra(IntentHandler.EXTRA_OPEN_NEW_INCOGNITO_TAB, true); |
1506 } | 1507 } |
1507 IntentHandler.addTrustedIntentExtras(intent, activity); | 1508 IntentHandler.addTrustedIntentExtras(intent, activity); |
1508 | 1509 |
1509 boolean disabled = FieldTrialList.trialExists("TabReparenting") | 1510 boolean disabled = FieldTrialList.trialExists("TabReparenting") |
1510 && FieldTrialList.findFullName("TabReparenting").startsWith("Dis
abled"); | 1511 && FieldTrialList.findFullName("TabReparenting").startsWith("Dis
abled"); |
1511 if (!disabled) { | 1512 if (!disabled) { |
1512 TabModelSelector tabModelSelector = getTabModelSelector(); | 1513 TabModelSelector tabModelSelector = getTabModelSelector(); |
1513 if (tabModelSelector == null) return false; | 1514 if (tabModelSelector == null) return false; |
1514 mIsDetachedForReparenting = true; | 1515 mIsDetachedForReparenting = true; |
1515 | 1516 |
1516 // Add the tab to AsyncTabParamsManager before removing it from the
current model to | 1517 // Add the tab to AsyncTabParamsManager before removing it from the
current model to |
1517 // ensure the global count of tabs is correct. See crbug.com/611806. | 1518 // ensure the global count of tabs is correct. See crbug.com/611806. |
1518 intent.putExtra(IntentHandler.EXTRA_TAB_ID, mId); | 1519 intent.putExtra(IntentHandler.EXTRA_TAB_ID, mId); |
1519 AsyncTabParamsManager.add(mId, | 1520 AsyncTabParamsManager.add(mId, |
1520 new TabReparentingParams(this, intent, finalizeCallback)); | 1521 new TabReparentingParams(this, intent, finalizeCallback, sta
yInChrome)); |
1521 | 1522 |
1522 tabModelSelector.getModel(mIncognito).removeTab(this); | 1523 tabModelSelector.getModel(mIncognito).removeTab(this); |
1523 | 1524 |
1524 if (mContentViewCore != null) mContentViewCore.updateWindowAndroid(n
ull); | 1525 if (mContentViewCore != null) mContentViewCore.updateWindowAndroid(n
ull); |
1525 attachTabContentManager(null); | 1526 attachTabContentManager(null); |
1526 } | 1527 } |
1527 | 1528 |
1528 activity.startActivity(intent, startActivityOptions); | 1529 activity.startActivity(intent, startActivityOptions); |
1529 return true; | 1530 return true; |
1530 } | 1531 } |
(...skipping 1735 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3266 private native void nativeSetInterceptNavigationDelegate(long nativeTabAndro
id, | 3267 private native void nativeSetInterceptNavigationDelegate(long nativeTabAndro
id, |
3267 InterceptNavigationDelegate delegate); | 3268 InterceptNavigationDelegate delegate); |
3268 private native void nativeAttachToTabContentManager(long nativeTabAndroid, | 3269 private native void nativeAttachToTabContentManager(long nativeTabAndroid, |
3269 TabContentManager tabContentManager); | 3270 TabContentManager tabContentManager); |
3270 private native void nativeAttachOverlayContentViewCore(long nativeTabAndroid
, | 3271 private native void nativeAttachOverlayContentViewCore(long nativeTabAndroid
, |
3271 ContentViewCore content, boolean visible); | 3272 ContentViewCore content, boolean visible); |
3272 private native void nativeDetachOverlayContentViewCore(long nativeTabAndroid
, | 3273 private native void nativeDetachOverlayContentViewCore(long nativeTabAndroid
, |
3273 ContentViewCore content); | 3274 ContentViewCore content); |
3274 private native boolean nativeHasPrerenderedUrl(long nativeTabAndroid, String
url); | 3275 private native boolean nativeHasPrerenderedUrl(long nativeTabAndroid, String
url); |
3275 } | 3276 } |
OLD | NEW |