| 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.SuppressLint; | 7 import android.annotation.SuppressLint; |
| 8 import android.annotation.TargetApi; | 8 import android.annotation.TargetApi; |
| 9 import android.app.Activity; | 9 import android.app.Activity; |
| 10 import android.app.ActivityManager; | 10 import android.app.ActivityManager; |
| (...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 443 | 443 |
| 444 super.onPauseWithNative(); | 444 super.onPauseWithNative(); |
| 445 } | 445 } |
| 446 | 446 |
| 447 @Override | 447 @Override |
| 448 public void onStopWithNative() { | 448 public void onStopWithNative() { |
| 449 super.onStopWithNative(); | 449 super.onStopWithNative(); |
| 450 | 450 |
| 451 if (getActivityTab() != null) getActivityTab().setIsAllowedToReturnToExt
ernalApp(false); | 451 if (getActivityTab() != null) getActivityTab().setIsAllowedToReturnToExt
ernalApp(false); |
| 452 | 452 |
| 453 if (mVrShellDelegate.isVrInitialized()) { | |
| 454 mVrShellDelegate.close(); | |
| 455 } | |
| 456 mTabModelSelectorImpl.saveState(); | 453 mTabModelSelectorImpl.saveState(); |
| 457 StartupMetrics.getInstance().recordHistogram(true); | 454 StartupMetrics.getInstance().recordHistogram(true); |
| 458 mActivityStopMetrics.onStopWithNative(this); | 455 mActivityStopMetrics.onStopWithNative(this); |
| 459 } | 456 } |
| 460 | 457 |
| 461 @Override | 458 @Override |
| 462 public void onStart() { | 459 public void onStart() { |
| 463 super.onStart(); | 460 super.onStart(); |
| 464 StartupMetrics.getInstance().updateIntent(getIntent()); | 461 StartupMetrics.getInstance().updateIntent(getIntent()); |
| 465 } | 462 } |
| 466 | 463 |
| 467 @Override | 464 @Override |
| 468 public void onStartWithNative() { | 465 public void onStartWithNative() { |
| 469 super.onStartWithNative(); | 466 super.onStartWithNative(); |
| 470 // If we don't have a current tab, show the overview mode. | 467 // If we don't have a current tab, show the overview mode. |
| 471 if (getActivityTab() == null) mLayoutManager.showOverview(false); | 468 if (getActivityTab() == null) mLayoutManager.showOverview(false); |
| 472 | 469 |
| 473 resetSavedInstanceState(); | 470 resetSavedInstanceState(); |
| 474 } | 471 } |
| 475 | 472 |
| 476 @Override | 473 @Override |
| 477 public void onNewIntentWithNative(Intent intent) { | 474 public void onNewIntentWithNative(Intent intent) { |
| 478 try { | 475 try { |
| 479 TraceEvent.begin("ChromeTabbedActivity.onNewIntentWithNative"); | 476 TraceEvent.begin("ChromeTabbedActivity.onNewIntentWithNative"); |
| 480 | 477 |
| 481 super.onNewIntentWithNative(intent); | 478 super.onNewIntentWithNative(intent); |
| 482 if (CommandLine.getInstance().hasSwitch(ContentSwitches.ENABLE_TEST_
INTENTS)) { | 479 if (CommandLine.getInstance().hasSwitch(ContentSwitches.ENABLE_TEST_
INTENTS)) { |
| 483 handleDebugIntent(intent); | 480 handleDebugIntent(intent); |
| 484 } | 481 } |
| 485 if (!mVrShellDelegate.isInVR() && mVrShellDelegate.isVrIntent(intent
)) { | 482 if (mVrShellDelegate.isVrIntent(intent)) mVrShellDelegate.enterVRFro
mIntent(intent); |
| 486 mVrShellDelegate.enterVRIfNecessary(false); | |
| 487 } | |
| 488 } finally { | 483 } finally { |
| 489 TraceEvent.end("ChromeTabbedActivity.onNewIntentWithNative"); | 484 TraceEvent.end("ChromeTabbedActivity.onNewIntentWithNative"); |
| 490 } | 485 } |
| 491 } | 486 } |
| 492 | 487 |
| 493 @Override | 488 @Override |
| 494 public ChromeTabCreator getTabCreator(boolean incognito) { | 489 public ChromeTabCreator getTabCreator(boolean incognito) { |
| 495 TabCreator tabCreator = super.getTabCreator(incognito); | 490 TabCreator tabCreator = super.getTabCreator(incognito); |
| 496 assert tabCreator instanceof ChromeTabCreator; | 491 assert tabCreator instanceof ChromeTabCreator; |
| 497 return (ChromeTabCreator) tabCreator; | 492 return (ChromeTabCreator) tabCreator; |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 721 } else { | 716 } else { |
| 722 if (data != null && data.getBooleanExtra( | 717 if (data != null && data.getBooleanExtra( |
| 723 FirstRunActivity.RESULT_CLOSE_APP, false)) { | 718 FirstRunActivity.RESULT_CLOSE_APP, false)) { |
| 724 getTabModelSelector().closeAllTabs(true); | 719 getTabModelSelector().closeAllTabs(true); |
| 725 finish(); | 720 finish(); |
| 726 } else { | 721 } else { |
| 727 launchFirstRunExperience(); | 722 launchFirstRunExperience(); |
| 728 } | 723 } |
| 729 } | 724 } |
| 730 return true; | 725 return true; |
| 726 } else if (requestCode == VrShellDelegate.EXIT_VR_RESULT) { |
| 727 mVrShellDelegate.onExitVRResult(resultCode); |
| 728 return true; |
| 731 } | 729 } |
| 732 return false; | 730 return false; |
| 733 } | 731 } |
| 734 | 732 |
| 735 @Override | 733 @Override |
| 736 public void onAccessibilityModeChanged(boolean enabled) { | 734 public void onAccessibilityModeChanged(boolean enabled) { |
| 737 super.onAccessibilityModeChanged(enabled); | 735 super.onAccessibilityModeChanged(enabled); |
| 738 | 736 |
| 739 if (mLayoutManager != null) { | 737 if (mLayoutManager != null) { |
| 740 mLayoutManager.setEnableAnimations( | 738 mLayoutManager.setEnableAnimations( |
| (...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1233 MultiWindowUtils.onMultiInstanceModeStarted(); | 1231 MultiWindowUtils.onMultiInstanceModeStarted(); |
| 1234 | 1232 |
| 1235 tab.detachAndStartReparenting(intent, null, null); | 1233 tab.detachAndStartReparenting(intent, null, null); |
| 1236 } | 1234 } |
| 1237 | 1235 |
| 1238 @Override | 1236 @Override |
| 1239 public boolean handleBackPressed() { | 1237 public boolean handleBackPressed() { |
| 1240 if (!mUIInitialized) return false; | 1238 if (!mUIInitialized) return false; |
| 1241 final Tab currentTab = getActivityTab(); | 1239 final Tab currentTab = getActivityTab(); |
| 1242 | 1240 |
| 1243 if (mVrShellDelegate.exitVRIfNecessary()) return true; | 1241 if (mVrShellDelegate.exitVRIfNecessary(true)) return true; |
| 1244 | 1242 |
| 1245 if (currentTab == null) { | 1243 if (currentTab == null) { |
| 1246 recordBackPressedUma("currentTab is null", BACK_PRESSED_TAB_IS_NULL)
; | 1244 recordBackPressedUma("currentTab is null", BACK_PRESSED_TAB_IS_NULL)
; |
| 1247 moveTaskToBack(true); | 1245 moveTaskToBack(true); |
| 1248 return true; | 1246 return true; |
| 1249 } | 1247 } |
| 1250 | 1248 |
| 1251 // If we are in overview mode and not a tablet, then leave overview mode
on back. | 1249 // If we are in overview mode and not a tablet, then leave overview mode
on back. |
| 1252 if (mLayoutManager.overviewVisible() && !isTablet()) { | 1250 if (mLayoutManager.overviewVisible() && !isTablet()) { |
| 1253 recordBackPressedUma("Hid overview", BACK_PRESSED_EXITED_TAB_SWITCHE
R); | 1251 recordBackPressedUma("Hid overview", BACK_PRESSED_EXITED_TAB_SWITCHE
R); |
| (...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1711 | 1709 |
| 1712 ActivityManager manager = (ActivityManager) getSystemService(Context.ACT
IVITY_SERVICE); | 1710 ActivityManager manager = (ActivityManager) getSystemService(Context.ACT
IVITY_SERVICE); |
| 1713 for (AppTask task : manager.getAppTasks()) { | 1711 for (AppTask task : manager.getAppTasks()) { |
| 1714 RecentTaskInfo info = DocumentUtils.getTaskInfoFromTask(task); | 1712 RecentTaskInfo info = DocumentUtils.getTaskInfoFromTask(task); |
| 1715 if (info == null) continue; | 1713 if (info == null) continue; |
| 1716 if (info.id == sMergedInstanceTaskId) return true; | 1714 if (info.id == sMergedInstanceTaskId) return true; |
| 1717 } | 1715 } |
| 1718 return false; | 1716 return false; |
| 1719 } | 1717 } |
| 1720 } | 1718 } |
| OLD | NEW |