Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(185)

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/ChromeTabbedActivity.java

Issue 2727873002: Implement lazy initialization for VrShellDelegate (Closed)
Patch Set: Fix FindBugs errors - neat! Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 * Keeps track of whether or not a specific tab was created based on the sta rtup intent. 237 * Keeps track of whether or not a specific tab was created based on the sta rtup intent.
238 */ 238 */
239 private boolean mCreatedTabOnStartup; 239 private boolean mCreatedTabOnStartup;
240 240
241 // Whether or not chrome was launched with an intent to open a tab. 241 // Whether or not chrome was launched with an intent to open a tab.
242 private boolean mIntentWithEffect; 242 private boolean mIntentWithEffect;
243 243
244 // Time at which an intent was received and handled. 244 // Time at which an intent was received and handled.
245 private long mIntentHandlingTimeMs; 245 private long mIntentHandlingTimeMs;
246 246
247 private VrShellDelegate mVrShellDelegate;
248
249 private class TabbedAssistStatusHandler extends AssistStatusHandler { 247 private class TabbedAssistStatusHandler extends AssistStatusHandler {
250 public TabbedAssistStatusHandler(Activity activity) { 248 public TabbedAssistStatusHandler(Activity activity) {
251 super(activity); 249 super(activity);
252 } 250 }
253 251
254 @Override 252 @Override
255 public boolean isAssistSupported() { 253 public boolean isAssistSupported() {
256 // If we are in the tab switcher and any incognito tabs are present, disable assist. 254 // If we are in the tab switcher and any incognito tabs are present, disable assist.
257 if (isInOverviewMode() && mTabModelSelectorImpl != null 255 if (isInOverviewMode() && mTabModelSelectorImpl != null
258 && mTabModelSelectorImpl.getModel(true).getCount() > 0) { 256 && mTabModelSelectorImpl.getModel(true).getCount() > 0) {
259 return false; 257 return false;
260 } 258 }
261 return super.isAssistSupported(); 259 return super.isAssistSupported();
262 } 260 }
263 } 261 }
264 262
265 private class TabbedModeBrowserControlsVisibilityDelegate 263 // TODO(mthiesse): Move VR control visibility handling into ChromeActivity. crbug.com/688611
264 private static class TabbedModeBrowserControlsVisibilityDelegate
266 extends TabStateBrowserControlsVisibilityDelegate { 265 extends TabStateBrowserControlsVisibilityDelegate {
267 public TabbedModeBrowserControlsVisibilityDelegate(Tab tab) { 266 public TabbedModeBrowserControlsVisibilityDelegate(Tab tab) {
268 super(tab); 267 super(tab);
269 } 268 }
270 269
271 @Override 270 @Override
272 public boolean isShowingBrowserControlsEnabled() { 271 public boolean isShowingBrowserControlsEnabled() {
273 if (mVrShellDelegate.isInVR()) return false; 272 if (VrShellDelegate.isInVR()) return false;
274 return super.isShowingBrowserControlsEnabled(); 273 return super.isShowingBrowserControlsEnabled();
275 } 274 }
276 275
277 @Override 276 @Override
278 public boolean isHidingBrowserControlsEnabled() { 277 public boolean isHidingBrowserControlsEnabled() {
279 if (mVrShellDelegate.isInVR()) return true; 278 if (VrShellDelegate.isInVR()) return true;
280 return super.isHidingBrowserControlsEnabled(); 279 return super.isHidingBrowserControlsEnabled();
281 } 280 }
282 } 281 }
283 282
284 private class TabbedModeTabDelegateFactory extends TabDelegateFactory { 283 private class TabbedModeTabDelegateFactory extends TabDelegateFactory {
285 @Override 284 @Override
286 public BrowserControlsVisibilityDelegate createBrowserControlsVisibility Delegate(Tab tab) { 285 public BrowserControlsVisibilityDelegate createBrowserControlsVisibility Delegate(Tab tab) {
287 return new ComposedBrowserControlsVisibilityDelegate( 286 return new ComposedBrowserControlsVisibilityDelegate(
288 new TabbedModeBrowserControlsVisibilityDelegate(tab), 287 new TabbedModeBrowserControlsVisibilityDelegate(tab),
289 getFullscreenManager().getBrowserVisibilityDelegate()); 288 getFullscreenManager().getBrowserVisibilityDelegate());
(...skipping 29 matching lines...) Expand all
319 mMainIntentMetrics = new MainIntentBehaviorMetrics(this); 318 mMainIntentMetrics = new MainIntentBehaviorMetrics(this);
320 } 319 }
321 320
322 @Override 321 @Override
323 public void initializeCompositor() { 322 public void initializeCompositor() {
324 try { 323 try {
325 TraceEvent.begin("ChromeTabbedActivity.initializeCompositor"); 324 TraceEvent.begin("ChromeTabbedActivity.initializeCompositor");
326 super.initializeCompositor(); 325 super.initializeCompositor();
327 326
328 mTabModelSelectorImpl.onNativeLibraryReady(getTabContentManager()); 327 mTabModelSelectorImpl.onNativeLibraryReady(getTabContentManager());
329 mVrShellDelegate.onNativeLibraryReady();
330 328
331 mTabModelObserver = new TabModelSelectorTabModelObserver(mTabModelSe lectorImpl) { 329 mTabModelObserver = new TabModelSelectorTabModelObserver(mTabModelSe lectorImpl) {
332 @Override 330 @Override
333 public void didCloseTab(int tabId, boolean incognito) { 331 public void didCloseTab(int tabId, boolean incognito) {
334 closeIfNoTabsAndHomepageEnabled(false); 332 closeIfNoTabsAndHomepageEnabled(false);
335 } 333 }
336 334
337 @Override 335 @Override
338 public void tabPendingClosure(Tab tab) { 336 public void tabPendingClosure(Tab tab) {
339 closeIfNoTabsAndHomepageEnabled(true); 337 closeIfNoTabsAndHomepageEnabled(true);
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 491
494 @Override 492 @Override
495 public void onResumeWithNative() { 493 public void onResumeWithNative() {
496 super.onResumeWithNative(); 494 super.onResumeWithNative();
497 495
498 if (shouldDestroyIncognitoProfile()) { 496 if (shouldDestroyIncognitoProfile()) {
499 Profile.getLastUsedProfile().getOffTheRecordProfile().destroyWhenApp ropriate(); 497 Profile.getLastUsedProfile().getOffTheRecordProfile().destroyWhenApp ropriate();
500 } else { 498 } else {
501 CookiesFetcher.restoreCookies(this); 499 CookiesFetcher.restoreCookies(this);
502 } 500 }
501
503 StartupMetrics.getInstance().recordHistogram(false); 502 StartupMetrics.getInstance().recordHistogram(false);
504 503
505 if (FeatureUtilities.isTabModelMergingEnabled()) { 504 if (FeatureUtilities.isTabModelMergingEnabled()) {
506 boolean inMultiWindowMode = MultiWindowUtils.getInstance().isInMulti WindowMode(this); 505 boolean inMultiWindowMode = MultiWindowUtils.getInstance().isInMulti WindowMode(this);
507 // Merge tabs if the activity is not in multi-window mode and mMerge TabsOnResume is true 506 // Merge tabs if the activity is not in multi-window mode and mMerge TabsOnResume is true
508 // or unset because the activity is just starting or was destroyed. 507 // or unset because the activity is just starting or was destroyed.
509 if (!inMultiWindowMode && (mMergeTabsOnResume == null || mMergeTabsO nResume)) { 508 if (!inMultiWindowMode && (mMergeTabsOnResume == null || mMergeTabsO nResume)) {
510 maybeMergeTabs(); 509 maybeMergeTabs();
511 } 510 }
512 mMergeTabsOnResume = false; 511 mMergeTabsOnResume = false;
513 } 512 }
514 513
515 VideoPersister.getInstance().stopPersist(this); 514 VideoPersister.getInstance().stopPersist(this);
516 mVrShellDelegate.maybeResumeVR(); 515 // TODO(mthiesse): Move this call into ChromeActivity. crbug.com/697694
516 VrShellDelegate.maybeResumeVR(this);
517 517
518 mLocaleManager.setSnackbarManager(getSnackbarManager()); 518 mLocaleManager.setSnackbarManager(getSnackbarManager());
519 mLocaleManager.startObservingPhoneChanges(); 519 mLocaleManager.startObservingPhoneChanges();
520 520
521 if (isWarmOnResume()) { 521 if (isWarmOnResume()) {
522 SnippetsBridge.notifySchedulerAboutWarmResume(); 522 SnippetsBridge.notifySchedulerAboutWarmResume();
523 } else { 523 } else {
524 SnippetsBridge.notifySchedulerAboutColdStart(); 524 SnippetsBridge.notifySchedulerAboutColdStart();
525 } 525 }
526 } 526 }
527 527
528 @Override 528 @Override
529 protected void onUserLeaveHint() { 529 protected void onUserLeaveHint() {
530 VideoPersister.getInstance().attemptPersist(this); 530 VideoPersister.getInstance().attemptPersist(this);
531 super.onUserLeaveHint(); 531 super.onUserLeaveHint();
532 } 532 }
533 533
534 @Override 534 @Override
535 public void onPauseWithNative() { 535 public void onPauseWithNative() {
536 mTabModelSelectorImpl.commitAllTabClosures(); 536 mTabModelSelectorImpl.commitAllTabClosures();
537 CookiesFetcher.persistCookies(this); 537 CookiesFetcher.persistCookies(this);
538 mVrShellDelegate.maybePauseVR();
539 538
540 mLocaleManager.setSnackbarManager(null); 539 mLocaleManager.setSnackbarManager(null);
541 mLocaleManager.stopObservingPhoneChanges(); 540 mLocaleManager.stopObservingPhoneChanges();
542 541
543 super.onPauseWithNative(); 542 super.onPauseWithNative();
544 } 543 }
545 544
546 @Override 545 @Override
547 public void onStopWithNative() { 546 public void onStopWithNative() {
548 super.onStopWithNative(); 547 super.onStopWithNative();
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 if (isMainIntent(intent)) { 582 if (isMainIntent(intent)) {
584 if (IntentHandler.getUrlFromIntent(intent) == null) { 583 if (IntentHandler.getUrlFromIntent(intent) == null) {
585 maybeLaunchNtpFromMainIntent(intent); 584 maybeLaunchNtpFromMainIntent(intent);
586 } 585 }
587 logMainIntentBehavior(intent); 586 logMainIntentBehavior(intent);
588 } 587 }
589 588
590 if (CommandLine.getInstance().hasSwitch(ContentSwitches.ENABLE_TEST_ INTENTS)) { 589 if (CommandLine.getInstance().hasSwitch(ContentSwitches.ENABLE_TEST_ INTENTS)) {
591 handleDebugIntent(intent); 590 handleDebugIntent(intent);
592 } 591 }
593 if (mVrShellDelegate.isDaydreamVrIntent(intent)) { 592 if (VrShellDelegate.isDaydreamVrIntent(intent)) {
594 mVrShellDelegate.enterVRFromIntent(intent); 593 // TODO(mthiesse): Move this into ChromeActivity. crbug.com/6886 11
594 VrShellDelegate.enterVRFromIntent(intent);
595 } else if (ShortcutHelper.isShowToastIntent(intent)) { 595 } else if (ShortcutHelper.isShowToastIntent(intent)) {
596 ShortcutHelper.showAddedToHomescreenToastFromIntent(intent); 596 ShortcutHelper.showAddedToHomescreenToastFromIntent(intent);
597 } 597 }
598 } finally { 598 } finally {
599 TraceEvent.end("ChromeTabbedActivity.onNewIntentWithNative"); 599 TraceEvent.end("ChromeTabbedActivity.onNewIntentWithNative");
600 } 600 }
601 } 601 }
602 602
603 @Override 603 @Override
604 public ChromeTabCreator getTabCreator(boolean incognito) { 604 public ChromeTabCreator getTabCreator(boolean incognito) {
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
805 // a previous state. This may change the current Model, watch ou t for initialization 805 // a previous state. This may change the current Model, watch ou t for initialization
806 // based on the model. 806 // based on the model.
807 // Never attempt to restore incognito tabs when this activity wa s previously swiped 807 // Never attempt to restore incognito tabs when this activity wa s previously swiped
808 // away in Recents. http://crbug.com/626629 808 // away in Recents. http://crbug.com/626629
809 boolean ignoreIncognitoFiles = !hadCipherData; 809 boolean ignoreIncognitoFiles = !hadCipherData;
810 mTabModelSelectorImpl.loadState(ignoreIncognitoFiles); 810 mTabModelSelectorImpl.loadState(ignoreIncognitoFiles);
811 } 811 }
812 812
813 mIntentWithEffect = false; 813 mIntentWithEffect = false;
814 if ((mIsOnFirstRun || getSavedInstanceState() == null) && intent != null) { 814 if ((mIsOnFirstRun || getSavedInstanceState() == null) && intent != null) {
815 if (mVrShellDelegate.isDaydreamVrIntent(intent)) { 815 if (VrShellDelegate.isDaydreamVrIntent(intent)) {
816 // TODO(mthiesse): Improve startup when started from a VR in tent. Right now 816 // TODO(mthiesse): Improve startup when started from a VR in tent.
817 // we launch out of VR, partially load out of VR, then switc h into VR. 817 // crbug.com/668541
818 mVrShellDelegate.enterVRIfNecessary(); 818 // TODO(mthiesse): Move this into ChromeActivity. crbug.com/ 688611
819 VrShellDelegate.enterVRIfNecessary();
819 } else if (!mIntentHandler.shouldIgnoreIntent(intent)) { 820 } else if (!mIntentHandler.shouldIgnoreIntent(intent)) {
820 mIntentWithEffect = mIntentHandler.onNewIntent(intent); 821 mIntentWithEffect = mIntentHandler.onNewIntent(intent);
821 } 822 }
822 823
823 if (isMainIntent(intent)) { 824 if (isMainIntent(intent)) {
824 if (IntentHandler.getUrlFromIntent(intent) == null) { 825 if (IntentHandler.getUrlFromIntent(intent) == null) {
825 assert !mIntentWithEffect 826 assert !mIntentWithEffect
826 : "ACTION_MAIN should not have triggered any pri or action"; 827 : "ACTION_MAIN should not have triggered any pri or action";
827 mIntentWithEffect = maybeLaunchNtpFromMainIntent(intent) ; 828 mIntentWithEffect = maybeLaunchNtpFromMainIntent(intent) ;
828 } 829 }
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
888 if (data != null && data.getBooleanExtra( 889 if (data != null && data.getBooleanExtra(
889 FirstRunActivity.RESULT_CLOSE_APP, false)) { 890 FirstRunActivity.RESULT_CLOSE_APP, false)) {
890 getTabModelSelector().closeAllTabs(true); 891 getTabModelSelector().closeAllTabs(true);
891 finish(); 892 finish();
892 } else { 893 } else {
893 launchFirstRunExperience(); 894 launchFirstRunExperience();
894 } 895 }
895 } 896 }
896 return true; 897 return true;
897 } else if (requestCode == VrShellDelegate.EXIT_VR_RESULT) { 898 } else if (requestCode == VrShellDelegate.EXIT_VR_RESULT) {
898 mVrShellDelegate.onExitVRResult(resultCode); 899 // TODO(mthiesse): Move this into ChromeActivity. crbug.com/688611
900 VrShellDelegate.onExitVRResult(resultCode);
899 return true; 901 return true;
900 } 902 }
901 return false; 903 return false;
902 } 904 }
903 905
904 @Override 906 @Override
905 public void onAccessibilityModeChanged(boolean enabled) { 907 public void onAccessibilityModeChanged(boolean enabled) {
906 super.onAccessibilityModeChanged(enabled); 908 super.onAccessibilityModeChanged(enabled);
907 909
908 if (mLayoutManager != null) { 910 if (mLayoutManager != null) {
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
1170 // Don't show the keyboard until user clicks in. 1172 // Don't show the keyboard until user clicks in.
1171 getWindow().setSoftInputMode( 1173 getWindow().setSoftInputMode(
1172 WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN 1174 WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN
1173 | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); 1175 | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
1174 1176
1175 mContentContainer = (ViewGroup) findViewById(android.R.id.content); 1177 mContentContainer = (ViewGroup) findViewById(android.R.id.content);
1176 mControlContainer = (ToolbarControlContainer) findViewById(R.id.control_ container); 1178 mControlContainer = (ToolbarControlContainer) findViewById(R.id.control_ container);
1177 1179
1178 mUndoBarPopupController = new UndoBarController(this, mTabModelSelectorI mpl, 1180 mUndoBarPopupController = new UndoBarController(this, mTabModelSelectorI mpl,
1179 getSnackbarManager()); 1181 getSnackbarManager());
1180
1181 mVrShellDelegate = new VrShellDelegate(this);
1182 } 1182 }
1183 1183
1184 @Override 1184 @Override
1185 protected void initializeToolbar() { 1185 protected void initializeToolbar() {
1186 super.initializeToolbar(); 1186 super.initializeToolbar();
1187 if (DeviceFormFactor.isTablet(getApplicationContext())) { 1187 if (DeviceFormFactor.isTablet(getApplicationContext())) {
1188 getToolbarManager().setShouldUpdateToolbarPrimaryColor(false); 1188 getToolbarManager().setShouldUpdateToolbarPrimaryColor(false);
1189 } 1189 }
1190 } 1190 }
1191 1191
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
1406 DownloadUtils.showDownloadManager(this, currentTab); 1406 DownloadUtils.showDownloadManager(this, currentTab);
1407 if (currentTabIsNtp) { 1407 if (currentTabIsNtp) {
1408 NewTabPageUma.recordAction(NewTabPageUma.ACTION_OPENED_DOWNLOADS _MANAGER); 1408 NewTabPageUma.recordAction(NewTabPageUma.ACTION_OPENED_DOWNLOADS _MANAGER);
1409 } 1409 }
1410 RecordUserAction.record("MobileMenuDownloadManager"); 1410 RecordUserAction.record("MobileMenuDownloadManager");
1411 } else if (id == R.id.open_recently_closed_tab) { 1411 } else if (id == R.id.open_recently_closed_tab) {
1412 TabModel currentModel = mTabModelSelectorImpl.getCurrentModel(); 1412 TabModel currentModel = mTabModelSelectorImpl.getCurrentModel();
1413 if (!currentModel.isIncognito()) currentModel.openMostRecentlyClosed Tab(); 1413 if (!currentModel.isIncognito()) currentModel.openMostRecentlyClosed Tab();
1414 RecordUserAction.record("MobileTabClosedUndoShortCut"); 1414 RecordUserAction.record("MobileTabClosedUndoShortCut");
1415 } else if (id == R.id.enter_vr_id) { 1415 } else if (id == R.id.enter_vr_id) {
1416 mVrShellDelegate.enterVRIfNecessary(); 1416 VrShellDelegate.enterVRIfNecessary();
1417 } else { 1417 } else {
1418 return super.onMenuOrKeyboardAction(id, fromMenu); 1418 return super.onMenuOrKeyboardAction(id, fromMenu);
1419 } 1419 }
1420 return true; 1420 return true;
1421 } 1421 }
1422 1422
1423 @Override 1423 @Override
1424 protected void onOmniboxFocusChanged(boolean hasFocus) { 1424 protected void onOmniboxFocusChanged(boolean hasFocus) {
1425 super.onOmniboxFocusChanged(hasFocus); 1425 super.onOmniboxFocusChanged(hasFocus);
1426 1426
(...skipping 25 matching lines...) Expand all
1452 MultiWindowUtils.onMultiInstanceModeStarted(); 1452 MultiWindowUtils.onMultiInstanceModeStarted();
1453 1453
1454 tab.detachAndStartReparenting(intent, null, null); 1454 tab.detachAndStartReparenting(intent, null, null);
1455 } 1455 }
1456 1456
1457 @Override 1457 @Override
1458 public boolean handleBackPressed() { 1458 public boolean handleBackPressed() {
1459 if (!mUIInitialized) return false; 1459 if (!mUIInitialized) return false;
1460 final Tab currentTab = getActivityTab(); 1460 final Tab currentTab = getActivityTab();
1461 1461
1462 if (mVrShellDelegate.onBackPressed()) return true;
1463
1464 if (currentTab == null) { 1462 if (currentTab == null) {
1465 recordBackPressedUma("currentTab is null", BACK_PRESSED_TAB_IS_NULL) ; 1463 recordBackPressedUma("currentTab is null", BACK_PRESSED_TAB_IS_NULL) ;
1466 moveTaskToBack(true); 1464 moveTaskToBack(true);
1467 return true; 1465 return true;
1468 } 1466 }
1469 1467
1470 // If we are in overview mode and not a tablet, then leave overview mode on back. 1468 // If we are in overview mode and not a tablet, then leave overview mode on back.
1471 if (mLayoutManager.overviewVisible() && !isTablet()) { 1469 if (mLayoutManager.overviewVisible() && !isTablet()) {
1472 recordBackPressedUma("Hid overview", BACK_PRESSED_EXITED_TAB_SWITCHE R); 1470 recordBackPressedUma("Hid overview", BACK_PRESSED_EXITED_TAB_SWITCHE R);
1473 mLayoutManager.hideOverview(true); 1471 mLayoutManager.hideOverview(true);
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
1665 mTabModelSelectorTabObserver = null; 1663 mTabModelSelectorTabObserver = null;
1666 } 1664 }
1667 1665
1668 if (mTabModelObserver != null) mTabModelObserver.destroy(); 1666 if (mTabModelObserver != null) mTabModelObserver.destroy();
1669 1667
1670 if (mUndoBarPopupController != null) { 1668 if (mUndoBarPopupController != null) {
1671 mUndoBarPopupController.destroy(); 1669 mUndoBarPopupController.destroy();
1672 mUndoBarPopupController = null; 1670 mUndoBarPopupController = null;
1673 } 1671 }
1674 1672
1675 if (mVrShellDelegate != null) {
1676 mVrShellDelegate.destroyVrShell();
1677 }
1678
1679 super.onDestroyInternal(); 1673 super.onDestroyInternal();
1680 } 1674 }
1681 1675
1682 @Override 1676 @Override
1683 public void onTrimMemory(int level) { 1677 public void onTrimMemory(int level) {
1684 super.onTrimMemory(level); 1678 super.onTrimMemory(level);
1685 // The conditions are expressed using ranges to capture intermediate lev els possibly added 1679 // The conditions are expressed using ranges to capture intermediate lev els possibly added
1686 // to the API in the future. 1680 // to the API in the future.
1687 if ((level >= TRIM_MEMORY_RUNNING_LOW && level < TRIM_MEMORY_UI_HIDDEN) 1681 if ((level >= TRIM_MEMORY_RUNNING_LOW && level < TRIM_MEMORY_UI_HIDDEN)
1688 || level >= TRIM_MEMORY_MODERATE) { 1682 || level >= TRIM_MEMORY_MODERATE) {
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
1873 otherActivityTask.finishAndRemoveTask(); 1867 otherActivityTask.finishAndRemoveTask();
1874 } 1868 }
1875 1869
1876 // 4. Ask TabPersistentStore to merge state. 1870 // 4. Ask TabPersistentStore to merge state.
1877 RecordUserAction.record("Android.MergeState.Live"); 1871 RecordUserAction.record("Android.MergeState.Live");
1878 mTabModelSelectorImpl.mergeState(); 1872 mTabModelSelectorImpl.mergeState();
1879 1873
1880 setMergedInstanceTaskId(getTaskId()); 1874 setMergedInstanceTaskId(getTaskId());
1881 } 1875 }
1882 1876
1883 // TODO(mthiesse): Toggle toolbar overlay, popups, etc. 1877 @Override
1884 public void setUIVisibilityForVR(int visibility) { 1878 public void onEnterVR() {
1885 mControlContainer.setVisibility(visibility); 1879 super.onEnterVR();
1886 getCompositorViewHolder().getSurfaceView().setVisibility(visibility); 1880 mControlContainer.setVisibility(View.INVISIBLE);
1887 getCompositorViewHolder().setVisibility(visibility); 1881 }
1882
1883 @Override
1884 public void onExitVR() {
1885 super.onExitVR();
1886 mControlContainer.setVisibility(View.VISIBLE);
1888 } 1887 }
1889 1888
1890 /** 1889 /**
1891 * Reports that a new tab launcher shortcut was selected or an action equiva lent to a shortcut 1890 * Reports that a new tab launcher shortcut was selected or an action equiva lent to a shortcut
1892 * was performed. 1891 * was performed.
1893 * @param isIncognito Whether the shortcut or action created a new incognito tab. 1892 * @param isIncognito Whether the shortcut or action created a new incognito tab.
1894 */ 1893 */
1895 @TargetApi(25) 1894 @TargetApi(25)
1896 private void reportNewTabShortcutUsed(boolean isIncognito) { 1895 private void reportNewTabShortcutUsed(boolean isIncognito) {
1897 if (!BuildInfo.isGreaterThanN()) return; 1896 if (!BuildInfo.isGreaterThanN()) return;
1898 1897
1899 try { 1898 try {
1900 Class<?> clazz = Class.forName("android.content.pm.ShortcutManager") ; 1899 Class<?> clazz = Class.forName("android.content.pm.ShortcutManager") ;
1901 Method method = clazz.getDeclaredMethod("reportShortcutUsed", String .class); 1900 Method method = clazz.getDeclaredMethod("reportShortcutUsed", String .class);
1902 method.invoke(getSystemService(clazz), 1901 method.invoke(getSystemService(clazz),
1903 isIncognito ? "new-incognito-tab-shortcut" : "new-tab-shortc ut"); 1902 isIncognito ? "new-incognito-tab-shortcut" : "new-tab-shortc ut");
1904 } catch (Exception e) { 1903 } catch (Exception e) {
1905 e.printStackTrace(); 1904 e.printStackTrace();
1906 } 1905 }
1907 } 1906 }
1908 1907
1909 public VrShellDelegate getVrShellDelegate() {
1910 return mVrShellDelegate;
1911 }
1912
1913 @Override 1908 @Override
1914 protected ChromeFullscreenManager createFullscreenManager() { 1909 protected ChromeFullscreenManager createFullscreenManager() {
1915 return new ChromeFullscreenManager(this, FeatureUtilities.isChromeHomeEn abled()); 1910 return new ChromeFullscreenManager(this, FeatureUtilities.isChromeHomeEn abled());
1916 } 1911 }
1917 1912
1918 /** 1913 /**
1919 * Should be called when multi-instance mode is started. 1914 * Should be called when multi-instance mode is started.
1920 */ 1915 */
1921 public static void onMultiInstanceModeStarted() { 1916 public static void onMultiInstanceModeStarted() {
1922 // When a second instance is created, the merged instance task id should be cleared. 1917 // When a second instance is created, the merged instance task id should be cleared.
(...skipping 12 matching lines...) Expand all
1935 1930
1936 ActivityManager manager = (ActivityManager) getSystemService(Context.ACT IVITY_SERVICE); 1931 ActivityManager manager = (ActivityManager) getSystemService(Context.ACT IVITY_SERVICE);
1937 for (AppTask task : manager.getAppTasks()) { 1932 for (AppTask task : manager.getAppTasks()) {
1938 RecentTaskInfo info = DocumentUtils.getTaskInfoFromTask(task); 1933 RecentTaskInfo info = DocumentUtils.getTaskInfoFromTask(task);
1939 if (info == null) continue; 1934 if (info == null) continue;
1940 if (info.id == sMergedInstanceTaskId) return true; 1935 if (info.id == sMergedInstanceTaskId) return true;
1941 } 1936 }
1942 return false; 1937 return false;
1943 } 1938 }
1944 } 1939 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698