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.document; | 5 package org.chromium.chrome.browser.document; |
6 | 6 |
7 import android.annotation.TargetApi; | 7 import android.annotation.TargetApi; |
8 import android.content.Intent; | 8 import android.content.Intent; |
9 import android.graphics.Bitmap; | 9 import android.graphics.Bitmap; |
10 import android.graphics.Color; | 10 import android.graphics.Color; |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 | 223 |
224 // Whether the page has started loading in this (browser) process once alrea
dy. Must only be | 224 // Whether the page has started loading in this (browser) process once alrea
dy. Must only be |
225 // used from the UI thread. | 225 // used from the UI thread. |
226 private static boolean sIsFirstPageLoadStart = true; | 226 private static boolean sIsFirstPageLoadStart = true; |
227 | 227 |
228 /** Whether the Tab has already been added to the TabModel. */ | 228 /** Whether the Tab has already been added to the TabModel. */ |
229 private boolean mNeedsToBeAddedToTabModel; | 229 private boolean mNeedsToBeAddedToTabModel; |
230 | 230 |
231 @Override | 231 @Override |
232 protected boolean isStartedUpCorrectly(Intent intent) { | 232 protected boolean isStartedUpCorrectly(Intent intent) { |
| 233 boolean isDocumentMode = FeatureUtilities.isDocumentMode(this); |
233 int tabId = ActivityDelegate.getTabIdFromIntent(getIntent()); | 234 int tabId = ActivityDelegate.getTabIdFromIntent(getIntent()); |
234 boolean isDocumentMode = FeatureUtilities.isDocumentMode(this); | 235 |
| 236 if (!isDocumentMode) { |
| 237 // Fire a MAIN Intent to send the user back through ChromeLauncherAc
tivity. |
| 238 Log.e(TAG, "User is not in document mode. Sending back to ChromeLau
ncherActivity."); |
| 239 |
| 240 // Try to bring this tab forward after migration. |
| 241 Intent tabbedIntent = null; |
| 242 if (tabId != Tab.INVALID_TAB_ID) tabbedIntent = Tab.createBringTabTo
FrontIntent(tabId); |
| 243 |
| 244 if (tabbedIntent == null) { |
| 245 tabbedIntent = new Intent(Intent.ACTION_MAIN); |
| 246 tabbedIntent.setPackage(getPackageName()); |
| 247 } |
| 248 |
| 249 // Launch the other Activity in its own task so it stays when this o
ne finishes. |
| 250 tabbedIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
| 251 tabbedIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT); |
| 252 |
| 253 startActivity(tabbedIntent); |
| 254 overridePendingTransition(0, 0); |
| 255 } |
| 256 |
235 boolean isStartedUpCorrectly = tabId != Tab.INVALID_TAB_ID && isDocument
Mode; | 257 boolean isStartedUpCorrectly = tabId != Tab.INVALID_TAB_ID && isDocument
Mode; |
236 if (!isStartedUpCorrectly) { | 258 if (!isStartedUpCorrectly) { |
237 Log.e(TAG, "Discarding Intent: Tab = " + tabId + ", Document mode =
" + isDocumentMode); | 259 Log.e(TAG, "Discarding Intent: Tab = " + tabId + ", Document mode =
" + isDocumentMode); |
238 } | 260 } |
239 return isStartedUpCorrectly; | 261 return isStartedUpCorrectly; |
240 } | 262 } |
241 | 263 |
242 @Override | 264 @Override |
243 public void preInflationStartup() { | 265 public void preInflationStartup() { |
244 // Decide whether to record startup UMA histograms. This is done early
in the main | 266 // Decide whether to record startup UMA histograms. This is done early
in the main |
(...skipping 725 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
970 | 992 |
971 /** | 993 /** |
972 * Launch a new DocumentActivity showing the new tab page. | 994 * Launch a new DocumentActivity showing the new tab page. |
973 * @param incognito Whether the new NTP should be in incognito mode. | 995 * @param incognito Whether the new NTP should be in incognito mode. |
974 */ | 996 */ |
975 private void launchNtp(boolean incognito) { | 997 private void launchNtp(boolean incognito) { |
976 if (incognito && !PrefServiceBridge.getInstance().isIncognitoModeEnabled
()) return; | 998 if (incognito && !PrefServiceBridge.getInstance().isIncognitoModeEnabled
()) return; |
977 getTabCreator(incognito).launchNTP(); | 999 getTabCreator(incognito).launchNTP(); |
978 } | 1000 } |
979 } | 1001 } |
OLD | NEW |