| 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 821 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 832 } | 832 } |
| 833 | 833 |
| 834 mCreatedTabOnStartup = getCurrentTabModel().getCount() > 0 | 834 mCreatedTabOnStartup = getCurrentTabModel().getCount() > 0 |
| 835 || mTabModelSelectorImpl.getRestoredTabCount() > 0 | 835 || mTabModelSelectorImpl.getRestoredTabCount() > 0 |
| 836 || mIntentWithEffect; | 836 || mIntentWithEffect; |
| 837 | 837 |
| 838 // We always need to try to restore tabs. The set of tabs might be e
mpty, but at least | 838 // We always need to try to restore tabs. The set of tabs might be e
mpty, but at least |
| 839 // it will trigger the notification that tab restore is complete whi
ch is needed by | 839 // it will trigger the notification that tab restore is complete whi
ch is needed by |
| 840 // other parts of Chrome such as sync. | 840 // other parts of Chrome such as sync. |
| 841 boolean activeTabBeingRestored = !mIntentWithEffect; | 841 boolean activeTabBeingRestored = !mIntentWithEffect; |
| 842 mMainIntentMetrics.setIgnoreEvents(true); |
| 842 mTabModelSelectorImpl.restoreTabs(activeTabBeingRestored); | 843 mTabModelSelectorImpl.restoreTabs(activeTabBeingRestored); |
| 844 mMainIntentMetrics.setIgnoreEvents(false); |
| 843 | 845 |
| 844 // Only create an initial tab if no tabs were restored and no intent
was handled. | 846 // Only create an initial tab if no tabs were restored and no intent
was handled. |
| 845 // Also, check whether the active tab was supposed to be restored an
d that the total | 847 // Also, check whether the active tab was supposed to be restored an
d that the total |
| 846 // tab count is now non zero. If this is not the case, tab restore
failed and we need | 848 // tab count is now non zero. If this is not the case, tab restore
failed and we need |
| 847 // to create a new tab as well. | 849 // to create a new tab as well. |
| 848 if (!mCreatedTabOnStartup | 850 if (!mCreatedTabOnStartup |
| 849 || (activeTabBeingRestored && getTabModelSelector().getTotal
TabCount() == 0)) { | 851 || (activeTabBeingRestored && getTabModelSelector().getTotal
TabCount() == 0)) { |
| 850 // If homepage URI is not determined, due to PartnerBrowserCusto
mizations provider | 852 // If homepage URI is not determined, due to PartnerBrowserCusto
mizations provider |
| 851 // async reading, then create a tab at the async reading finishe
d. If it takes | 853 // async reading, then create a tab at the async reading finishe
d. If it takes |
| 852 // too long, just create NTP. | 854 // too long, just create NTP. |
| 853 PartnerBrowserCustomizations.setOnInitializeAsyncFinished( | 855 PartnerBrowserCustomizations.setOnInitializeAsyncFinished( |
| 854 new Runnable() { | 856 new Runnable() { |
| 855 @Override | 857 @Override |
| 856 public void run() { | 858 public void run() { |
| 857 mMainIntentMetrics.ignorePendingAddTab(); | 859 mMainIntentMetrics.setIgnoreEvents(true); |
| 858 createInitialTab(); | 860 createInitialTab(); |
| 861 mMainIntentMetrics.setIgnoreEvents(false); |
| 859 } | 862 } |
| 860 }, INITIAL_TAB_CREATION_TIMEOUT_MS); | 863 }, INITIAL_TAB_CREATION_TIMEOUT_MS); |
| 861 } | 864 } |
| 862 | 865 |
| 863 RecordHistogram.recordBooleanHistogram( | 866 RecordHistogram.recordBooleanHistogram( |
| 864 "MobileStartup.ColdStartupIntent", mIntentWithEffect); | 867 "MobileStartup.ColdStartupIntent", mIntentWithEffect); |
| 865 } finally { | 868 } finally { |
| 866 TraceEvent.end("ChromeTabbedActivity.initializeState"); | 869 TraceEvent.end("ChromeTabbedActivity.initializeState"); |
| 867 } | 870 } |
| 868 } | 871 } |
| (...skipping 1119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1988 | 1991 |
| 1989 ActivityManager manager = (ActivityManager) getSystemService(Context.ACT
IVITY_SERVICE); | 1992 ActivityManager manager = (ActivityManager) getSystemService(Context.ACT
IVITY_SERVICE); |
| 1990 for (AppTask task : manager.getAppTasks()) { | 1993 for (AppTask task : manager.getAppTasks()) { |
| 1991 RecentTaskInfo info = DocumentUtils.getTaskInfoFromTask(task); | 1994 RecentTaskInfo info = DocumentUtils.getTaskInfoFromTask(task); |
| 1992 if (info == null) continue; | 1995 if (info == null) continue; |
| 1993 if (info.id == sMergedInstanceTaskId) return true; | 1996 if (info.id == sMergedInstanceTaskId) return true; |
| 1994 } | 1997 } |
| 1995 return false; | 1998 return false; |
| 1996 } | 1999 } |
| 1997 } | 2000 } |
| OLD | NEW |