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; | 5 package org.chromium.chrome.browser; |
6 | 6 |
7 import android.annotation.TargetApi; | 7 import android.annotation.TargetApi; |
8 import android.app.Activity; | 8 import android.app.Activity; |
9 import android.app.ActivityManager; | 9 import android.app.ActivityManager; |
10 import android.content.Context; | 10 import android.content.Context; |
(...skipping 1197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1208 || (type == TabLaunchType.FROM_EXTERNAL_APP && isAllowedToCloseT
ab) | 1208 || (type == TabLaunchType.FROM_EXTERNAL_APP && isAllowedToCloseT
ab) |
1209 || type == TabLaunchType.FROM_LONGPRESS_FOREGROUND | 1209 || type == TabLaunchType.FROM_LONGPRESS_FOREGROUND |
1210 || type == TabLaunchType.FROM_LONGPRESS_BACKGROUND | 1210 || type == TabLaunchType.FROM_LONGPRESS_BACKGROUND |
1211 || (type == TabLaunchType.FROM_RESTORE && parentId != Tab.INVALI
D_TAB_ID); | 1211 || (type == TabLaunchType.FROM_RESTORE && parentId != Tab.INVALI
D_TAB_ID); |
1212 | 1212 |
1213 // Minimize the app if either: | 1213 // Minimize the app if either: |
1214 // - we decided not to close the tab | 1214 // - we decided not to close the tab |
1215 // - we decided to close the tab, but it was opened by an external app,
so we will go | 1215 // - we decided to close the tab, but it was opened by an external app,
so we will go |
1216 // exit Chrome on top of closing the tab | 1216 // exit Chrome on top of closing the tab |
1217 final boolean minimizeApp = !shouldCloseTab || currentTab.isCreatedForEx
ternalApp(); | 1217 final boolean minimizeApp = !shouldCloseTab || currentTab.isCreatedForEx
ternalApp(); |
1218 | |
1219 if (minimizeApp) { | 1218 if (minimizeApp) { |
1220 if (shouldCloseTab) { | 1219 if (shouldCloseTab) { |
1221 recordBackPressedUma("Minimized and closed tab", BACK_PRESSED_MI
NIMIZED_TAB_CLOSED); | 1220 recordBackPressedUma("Minimized and closed tab", BACK_PRESSED_MI
NIMIZED_TAB_CLOSED); |
1222 mActivityStopMetrics.setStopReason(ActivityStopMetrics.STOP_REAS
ON_BACK_BUTTON); | 1221 mActivityStopMetrics.setStopReason(ActivityStopMetrics.STOP_REAS
ON_BACK_BUTTON); |
1223 sendToBackground(currentTab); | 1222 sendToBackground(currentTab); |
1224 return true; | 1223 return true; |
1225 } else { | 1224 } else { |
1226 recordBackPressedUma("Minimized, kept tab", BACK_PRESSED_MINIMIZ
ED_NO_TAB_CLOSED); | 1225 recordBackPressedUma("Minimized, kept tab", BACK_PRESSED_MINIMIZ
ED_NO_TAB_CLOSED); |
1227 mActivityStopMetrics.setStopReason(ActivityStopMetrics.STOP_REAS
ON_BACK_BUTTON); | 1226 mActivityStopMetrics.setStopReason(ActivityStopMetrics.STOP_REAS
ON_BACK_BUTTON); |
1228 sendToBackground(null); | 1227 sendToBackground(null); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1286 getToolbarManager().finishAnimations(); | 1285 getToolbarManager().finishAnimations(); |
1287 } | 1286 } |
1288 if (TextUtils.equals(externalAppId, getPackageName())) { | 1287 if (TextUtils.equals(externalAppId, getPackageName())) { |
1289 // If the intent was launched by chrome, open the new tab in the app
ropriate model. | 1288 // If the intent was launched by chrome, open the new tab in the app
ropriate model. |
1290 // Using FROM_LINK ensures the tab is parented to the current tab, w
hich allows | 1289 // Using FROM_LINK ensures the tab is parented to the current tab, w
hich allows |
1291 // the back button to close these tabs and restore selection to the
previous tab. | 1290 // the back button to close these tabs and restore selection to the
previous tab. |
1292 boolean isIncognito = IntentUtils.safeGetBooleanExtra(intent, | 1291 boolean isIncognito = IntentUtils.safeGetBooleanExtra(intent, |
1293 IntentHandler.EXTRA_OPEN_NEW_INCOGNITO_TAB, false); | 1292 IntentHandler.EXTRA_OPEN_NEW_INCOGNITO_TAB, false); |
1294 boolean fromLauncherShortcut = IntentUtils.safeGetBooleanExtra( | 1293 boolean fromLauncherShortcut = IntentUtils.safeGetBooleanExtra( |
1295 intent, IntentHandler.EXTRA_INVOKED_FROM_SHORTCUT, false); | 1294 intent, IntentHandler.EXTRA_INVOKED_FROM_SHORTCUT, false); |
1296 return getTabCreator(isIncognito).launchUrl( | 1295 LoadUrlParams loadUrlParams = new LoadUrlParams(url); |
1297 url, | 1296 loadUrlParams.setIntentReceivedTimestamp(mIntentHandlingTimeMs); |
| 1297 loadUrlParams.setVerbatimHeaders(headers); |
| 1298 return getTabCreator(isIncognito).createNewTab( |
| 1299 loadUrlParams, |
1298 fromLauncherShortcut ? TabLaunchType.FROM_EXTERNAL_APP | 1300 fromLauncherShortcut ? TabLaunchType.FROM_EXTERNAL_APP |
1299 : TabLaunchType.FROM_LINK, | 1301 : TabLaunchType.FROM_LINK, |
1300 intent, | 1302 null, |
1301 mIntentHandlingTimeMs); | 1303 intent); |
1302 } else { | 1304 } else { |
1303 return getTabCreator(false).launchUrlFromExternalApp(url, referer, h
eaders, | 1305 return getTabCreator(false).launchUrlFromExternalApp(url, referer, h
eaders, |
1304 externalAppId, forceNewTab, intent, mIntentHandlingTimeMs); | 1306 externalAppId, forceNewTab, intent, mIntentHandlingTimeMs); |
1305 } | 1307 } |
1306 } | 1308 } |
1307 | 1309 |
1308 private void toggleOverview() { | 1310 private void toggleOverview() { |
1309 Tab currentTab = getActivityTab(); | 1311 Tab currentTab = getActivityTab(); |
1310 ContentViewCore contentViewCore = | 1312 ContentViewCore contentViewCore = |
1311 currentTab != null ? currentTab.getContentViewCore() : null; | 1313 currentTab != null ? currentTab.getContentViewCore() : null; |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1559 } | 1561 } |
1560 // 3. Kill the other activity's task to remove it from Android recen
ts. | 1562 // 3. Kill the other activity's task to remove it from Android recen
ts. |
1561 otherActivityTask.finishAndRemoveTask(); | 1563 otherActivityTask.finishAndRemoveTask(); |
1562 } | 1564 } |
1563 | 1565 |
1564 // 4. Ask TabPersistentStore to merge state. | 1566 // 4. Ask TabPersistentStore to merge state. |
1565 RecordUserAction.record("Android.MergeState.Live"); | 1567 RecordUserAction.record("Android.MergeState.Live"); |
1566 mTabModelSelectorImpl.mergeState(); | 1568 mTabModelSelectorImpl.mergeState(); |
1567 } | 1569 } |
1568 } | 1570 } |
OLD | NEW |