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 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
179 public static final String SKIP_FIRST_RUN_EXPERIENCE = "skip_first_run_exper ience"; | 179 public static final String SKIP_FIRST_RUN_EXPERIENCE = "skip_first_run_exper ience"; |
180 | 180 |
181 /** | 181 /** |
182 * Sending an intent with this action to Chrome will cause it to close all t abs | 182 * Sending an intent with this action to Chrome will cause it to close all t abs |
183 * (iff the --enable-test-intents command line flag is set). If a URL is sup plied in the | 183 * (iff the --enable-test-intents command line flag is set). If a URL is sup plied in the |
184 * intent data, this will be loaded and unaffected by the close all action. | 184 * intent data, this will be loaded and unaffected by the close all action. |
185 */ | 185 */ |
186 private static final String ACTION_CLOSE_TABS = | 186 private static final String ACTION_CLOSE_TABS = |
187 "com.google.android.apps.chrome.ACTION_CLOSE_TABS"; | 187 "com.google.android.apps.chrome.ACTION_CLOSE_TABS"; |
188 | 188 |
189 /** The task id of the activity that tabs were merged into. */ | |
190 private static int sMergedInstanceTaskId; | |
191 | |
189 private final ActivityStopMetrics mActivityStopMetrics = new ActivityStopMet rics(); | 192 private final ActivityStopMetrics mActivityStopMetrics = new ActivityStopMet rics(); |
190 | 193 |
191 private FindToolbarManager mFindToolbarManager; | 194 private FindToolbarManager mFindToolbarManager; |
192 | 195 |
193 private UndoBarController mUndoBarPopupController; | 196 private UndoBarController mUndoBarPopupController; |
194 | 197 |
195 private LayoutManagerChrome mLayoutManager; | 198 private LayoutManagerChrome mLayoutManager; |
196 | 199 |
197 private ViewGroup mContentContainer; | 200 private ViewGroup mContentContainer; |
198 | 201 |
(...skipping 887 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1086 (ActivityManager) getSystemService(Context.ACTIVITY_SERV ICE); | 1089 (ActivityManager) getSystemService(Context.ACTIVITY_SERV ICE); |
1087 RecordHistogram.recordSparseSlowlyHistogram( | 1090 RecordHistogram.recordSparseSlowlyHistogram( |
1088 "MemoryAndroid.DeviceMemoryClass", am.getMemoryClass()); | 1091 "MemoryAndroid.DeviceMemoryClass", am.getMemoryClass()); |
1089 | 1092 |
1090 AutocompleteController.nativePrefetchZeroSuggestResults(); | 1093 AutocompleteController.nativePrefetchZeroSuggestResults(); |
1091 } | 1094 } |
1092 }); | 1095 }); |
1093 } | 1096 } |
1094 | 1097 |
1095 @Override | 1098 @Override |
1099 protected boolean isStartedUpCorrectly(Intent intent) { | |
1100 // If tabs were merged into a different ChromeTabbedActivity instance, t hen this | |
gone
2016/10/25 18:33:10
If tabs from this instance?
Theresa
2016/10/25 18:57:40
Done.
| |
1101 // instance should not be created. This may happen if the process is res tarted | |
1102 // e.g. on upgrade or from about://flags. See crbug.com/657418 | |
1103 return sMergedInstanceTaskId == 0 || sMergedInstanceTaskId == getTaskId( ); | |
gone
2016/10/25 18:33:10
I'm worried about cases where the user can't get b
Theresa
2016/10/25 18:57:40
Done.
| |
1104 } | |
1105 | |
1106 @Override | |
1096 public void terminateIncognitoSession() { | 1107 public void terminateIncognitoSession() { |
1097 getTabModelSelector().getModel(true).closeAllTabs(); | 1108 getTabModelSelector().getModel(true).closeAllTabs(); |
1098 } | 1109 } |
1099 | 1110 |
1100 @Override | 1111 @Override |
1101 public boolean onMenuOrKeyboardAction(final int id, boolean fromMenu) { | 1112 public boolean onMenuOrKeyboardAction(final int id, boolean fromMenu) { |
1102 final Tab currentTab = getActivityTab(); | 1113 final Tab currentTab = getActivityTab(); |
1103 if (id == R.id.move_to_other_window_menu_id) { | 1114 if (id == R.id.move_to_other_window_menu_id) { |
1104 if (currentTab != null) moveTabToOtherWindow(currentTab); | 1115 if (currentTab != null) moveTabToOtherWindow(currentTab); |
1105 } else if (id == R.id.new_tab_menu_id) { | 1116 } else if (id == R.id.new_tab_menu_id) { |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1190 } else { | 1201 } else { |
1191 RecordUserAction.record("Android.LauncherShortcut.NewTab"); | 1202 RecordUserAction.record("Android.LauncherShortcut.NewTab"); |
1192 } | 1203 } |
1193 } | 1204 } |
1194 | 1205 |
1195 private void moveTabToOtherWindow(Tab tab) { | 1206 private void moveTabToOtherWindow(Tab tab) { |
1196 Class<? extends Activity> targetActivity = | 1207 Class<? extends Activity> targetActivity = |
1197 MultiWindowUtils.getInstance().getOpenInOtherWindowActivity(this ); | 1208 MultiWindowUtils.getInstance().getOpenInOtherWindowActivity(this ); |
1198 if (targetActivity == null) return; | 1209 if (targetActivity == null) return; |
1199 | 1210 |
1211 // When a second instance is created, the merged instance task id should be cleared. | |
1212 setMergedInstanceTaskId(0); | |
1200 Intent intent = new Intent(this, targetActivity); | 1213 Intent intent = new Intent(this, targetActivity); |
1201 MultiWindowUtils.setOpenInOtherWindowIntentExtras(intent, this, targetAc tivity); | 1214 MultiWindowUtils.setOpenInOtherWindowIntentExtras(intent, this, targetAc tivity); |
1202 | 1215 |
1203 tab.detachAndStartReparenting(intent, null, null); | 1216 tab.detachAndStartReparenting(intent, null, null); |
1204 } | 1217 } |
1205 | 1218 |
1206 @Override | 1219 @Override |
1207 public boolean handleBackPressed() { | 1220 public boolean handleBackPressed() { |
1208 if (!mUIInitialized) return false; | 1221 if (!mUIInitialized) return false; |
1209 final Tab currentTab = getActivityTab(); | 1222 final Tab currentTab = getActivityTab(); |
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1609 break; | 1622 break; |
1610 } | 1623 } |
1611 } | 1624 } |
1612 // 3. Kill the other activity's task to remove it from Android recen ts. | 1625 // 3. Kill the other activity's task to remove it from Android recen ts. |
1613 otherActivityTask.finishAndRemoveTask(); | 1626 otherActivityTask.finishAndRemoveTask(); |
1614 } | 1627 } |
1615 | 1628 |
1616 // 4. Ask TabPersistentStore to merge state. | 1629 // 4. Ask TabPersistentStore to merge state. |
1617 RecordUserAction.record("Android.MergeState.Live"); | 1630 RecordUserAction.record("Android.MergeState.Live"); |
1618 mTabModelSelectorImpl.mergeState(); | 1631 mTabModelSelectorImpl.mergeState(); |
1632 | |
1633 setMergedInstanceTaskId(getTaskId()); | |
1619 } | 1634 } |
1620 | 1635 |
1621 /** | 1636 /** |
1622 * See VrShellDelegate#isVrShellEnabled() | 1637 * See VrShellDelegate#isVrShellEnabled() |
1623 */ | 1638 */ |
1624 @Override | 1639 @Override |
1625 public boolean isVrShellEnabled() { | 1640 public boolean isVrShellEnabled() { |
1626 return mVrShellDelegate.isVrShellEnabled(); | 1641 return mVrShellDelegate.isVrShellEnabled(); |
1627 } | 1642 } |
1628 | 1643 |
(...skipping 26 matching lines...) Expand all Loading... | |
1655 public VrShellDelegate getVrShellDelegate() { | 1670 public VrShellDelegate getVrShellDelegate() { |
1656 return mVrShellDelegate; | 1671 return mVrShellDelegate; |
1657 } | 1672 } |
1658 | 1673 |
1659 @Override | 1674 @Override |
1660 protected ChromeFullscreenManager createFullscreenManager() { | 1675 protected ChromeFullscreenManager createFullscreenManager() { |
1661 return new ChromeFullscreenManager(this, | 1676 return new ChromeFullscreenManager(this, |
1662 (ToolbarControlContainer) findViewById(R.id.control_container), | 1677 (ToolbarControlContainer) findViewById(R.id.control_container), |
1663 getTabModelSelector(), getControlContainerHeightResource(), true ); | 1678 getTabModelSelector(), getControlContainerHeightResource(), true ); |
1664 } | 1679 } |
1680 | |
1681 private static void setMergedInstanceTaskId(int mergedInstanceTaskId) { | |
1682 sMergedInstanceTaskId = mergedInstanceTaskId; | |
1683 } | |
1665 } | 1684 } |
OLD | NEW |