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 743 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
754 for (int i = 0; i < normalTabModel.getCount(); i++) { | 754 for (int i = 0; i < normalTabModel.getCount(); i++) { |
755 Tab tab = normalTabModel.getTabAt(i); | 755 Tab tab = normalTabModel.getTabAt(i); |
756 | 756 |
757 if (NewTabPage.isNTPUrl(tab.getUrl()) && !tab.canGoBack() && !tab.ca nGoForward()) { | 757 if (NewTabPage.isNTPUrl(tab.getUrl()) && !tab.canGoBack() && !tab.ca nGoForward()) { |
758 if (getActivityTab().equals(tab)) return true; | 758 if (getActivityTab().equals(tab)) return true; |
759 | 759 |
760 normalTabModel.moveTab(tab.getId(), normalTabModel.getCount()); | 760 normalTabModel.moveTab(tab.getId(), normalTabModel.getCount()); |
761 normalTabModel.setIndex( | 761 normalTabModel.setIndex( |
762 TabModelUtils.getTabIndexById(normalTabModel, tab.getId( )), | 762 TabModelUtils.getTabIndexById(normalTabModel, tab.getId( )), |
763 TabSelectionType.FROM_USER); | 763 TabSelectionType.FROM_USER); |
764 RecordUserAction.record("MobileStartup.MainIntent.NTPCreatedDueT oInactivity"); | |
764 return true; | 765 return true; |
765 } | 766 } |
766 } | 767 } |
767 | 768 |
768 getTabCreator(false).launchUrl(UrlConstants.NTP_URL, TabLaunchType.FROM_ EXTERNAL_APP); | 769 getTabCreator(false).launchUrl(UrlConstants.NTP_URL, TabLaunchType.FROM_ EXTERNAL_APP); |
770 RecordUserAction.record("MobileStartup.MainIntent.NTPCreatedDueToInactiv ity"); | |
Ilya Sherman
2017/03/28 18:19:54
nit: Could you move this to be above the for loop,
Ted C
2017/03/28 20:32:22
There is a return true at the top of the if check
| |
769 return true; | 771 return true; |
770 } | 772 } |
771 | 773 |
772 @Override | 774 @Override |
773 public void initializeState() { | 775 public void initializeState() { |
774 // This method goes through 3 steps: | 776 // This method goes through 3 steps: |
775 // 1. Load the saved tab state (but don't start restoring the tabs yet). | 777 // 1. Load the saved tab state (but don't start restoring the tabs yet). |
776 // 2. Process the Intent that this activity received and if that should result in any | 778 // 2. Process the Intent that this activity received and if that should result in any |
777 // new tabs, create them. This is done after step 1 so that the new tab gets | 779 // new tabs, create them. This is done after step 1 so that the new tab gets |
778 // created after previous tab state was restored. | 780 // created after previous tab state was restored. |
(...skipping 1163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1942 | 1944 |
1943 ActivityManager manager = (ActivityManager) getSystemService(Context.ACT IVITY_SERVICE); | 1945 ActivityManager manager = (ActivityManager) getSystemService(Context.ACT IVITY_SERVICE); |
1944 for (AppTask task : manager.getAppTasks()) { | 1946 for (AppTask task : manager.getAppTasks()) { |
1945 RecentTaskInfo info = DocumentUtils.getTaskInfoFromTask(task); | 1947 RecentTaskInfo info = DocumentUtils.getTaskInfoFromTask(task); |
1946 if (info == null) continue; | 1948 if (info == null) continue; |
1947 if (info.id == sMergedInstanceTaskId) return true; | 1949 if (info.id == sMergedInstanceTaskId) return true; |
1948 } | 1950 } |
1949 return false; | 1951 return false; |
1950 } | 1952 } |
1951 } | 1953 } |
OLD | NEW |