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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
44 import org.chromium.base.TraceEvent; | 44 import org.chromium.base.TraceEvent; |
45 import org.chromium.base.VisibleForTesting; | 45 import org.chromium.base.VisibleForTesting; |
46 import org.chromium.base.library_loader.LibraryLoader; | 46 import org.chromium.base.library_loader.LibraryLoader; |
47 import org.chromium.base.metrics.RecordHistogram; | 47 import org.chromium.base.metrics.RecordHistogram; |
48 import org.chromium.base.metrics.RecordUserAction; | 48 import org.chromium.base.metrics.RecordUserAction; |
49 import org.chromium.chrome.R; | 49 import org.chromium.chrome.R; |
50 import org.chromium.chrome.browser.IntentHandler.IntentHandlerDelegate; | 50 import org.chromium.chrome.browser.IntentHandler.IntentHandlerDelegate; |
51 import org.chromium.chrome.browser.IntentHandler.TabOpenType; | 51 import org.chromium.chrome.browser.IntentHandler.TabOpenType; |
52 import org.chromium.chrome.browser.appmenu.AppMenuPropertiesDelegate; | 52 import org.chromium.chrome.browser.appmenu.AppMenuPropertiesDelegate; |
53 import org.chromium.chrome.browser.bookmarks.BookmarkUtils; | 53 import org.chromium.chrome.browser.bookmarks.BookmarkUtils; |
54 import org.chromium.chrome.browser.browseractions.BrowserActionsContextMenuItemD elegate; | |
54 import org.chromium.chrome.browser.compositor.CompositorViewHolder; | 55 import org.chromium.chrome.browser.compositor.CompositorViewHolder; |
55 import org.chromium.chrome.browser.compositor.bottombar.OverlayPanel.StateChange Reason; | 56 import org.chromium.chrome.browser.compositor.bottombar.OverlayPanel.StateChange Reason; |
56 import org.chromium.chrome.browser.compositor.layouts.Layout; | 57 import org.chromium.chrome.browser.compositor.layouts.Layout; |
57 import org.chromium.chrome.browser.compositor.layouts.LayoutManager; | 58 import org.chromium.chrome.browser.compositor.layouts.LayoutManager; |
58 import org.chromium.chrome.browser.compositor.layouts.LayoutManagerChrome; | 59 import org.chromium.chrome.browser.compositor.layouts.LayoutManagerChrome; |
59 import org.chromium.chrome.browser.compositor.layouts.LayoutManagerChromePhone; | 60 import org.chromium.chrome.browser.compositor.layouts.LayoutManagerChromePhone; |
60 import org.chromium.chrome.browser.compositor.layouts.LayoutManagerChromeTablet; | 61 import org.chromium.chrome.browser.compositor.layouts.LayoutManagerChromeTablet; |
61 import org.chromium.chrome.browser.compositor.layouts.OverviewModeBehavior.Overv iewModeObserver; | 62 import org.chromium.chrome.browser.compositor.layouts.OverviewModeBehavior.Overv iewModeObserver; |
62 import org.chromium.chrome.browser.compositor.layouts.phone.StackLayout; | 63 import org.chromium.chrome.browser.compositor.layouts.phone.StackLayout; |
63 import org.chromium.chrome.browser.cookies.CookiesFetcher; | 64 import org.chromium.chrome.browser.cookies.CookiesFetcher; |
(...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
582 @Override | 583 @Override |
583 public void onStart() { | 584 public void onStart() { |
584 super.onStart(); | 585 super.onStart(); |
585 StartupMetrics.getInstance().updateIntent(getIntent()); | 586 StartupMetrics.getInstance().updateIntent(getIntent()); |
586 } | 587 } |
587 | 588 |
588 @Override | 589 @Override |
589 public void onStartWithNative() { | 590 public void onStartWithNative() { |
590 super.onStartWithNative(); | 591 super.onStartWithNative(); |
591 // If we don't have a current tab, show the overview mode. | 592 // If we don't have a current tab, show the overview mode. |
592 if (getActivityTab() == null) mLayoutManager.showOverview(false); | 593 if (setInitialOverviewState()) { |
David Trainor- moved to gerrit
2017/05/23 06:16:43
set -> Should just set. No need to return anythin
ltian
2017/05/23 18:36:46
Done.
| |
594 toggleOverview(); | |
595 } | |
596 BrowserActionsContextMenuItemDelegate.cancelBrowserActionsNotification() ; | |
593 | 597 |
594 resetSavedInstanceState(); | 598 resetSavedInstanceState(); |
595 } | 599 } |
596 | 600 |
597 @Override | 601 @Override |
598 public void onNewIntentWithNative(Intent intent) { | 602 public void onNewIntentWithNative(Intent intent) { |
599 try { | 603 try { |
600 TraceEvent.begin("ChromeTabbedActivity.onNewIntentWithNative"); | 604 TraceEvent.begin("ChromeTabbedActivity.onNewIntentWithNative"); |
601 | 605 |
602 super.onNewIntentWithNative(intent); | 606 super.onNewIntentWithNative(intent); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
636 | 640 |
637 private void handleDebugIntent(Intent intent) { | 641 private void handleDebugIntent(Intent intent) { |
638 if (ACTION_CLOSE_TABS.equals(intent.getAction())) { | 642 if (ACTION_CLOSE_TABS.equals(intent.getAction())) { |
639 getTabModelSelector().closeAllTabs(); | 643 getTabModelSelector().closeAllTabs(); |
640 } else if (MemoryPressureListener.handleDebugIntent(ChromeTabbedActivity .this, | 644 } else if (MemoryPressureListener.handleDebugIntent(ChromeTabbedActivity .this, |
641 intent.getAction())) { | 645 intent.getAction())) { |
642 // Handled. | 646 // Handled. |
643 } | 647 } |
644 } | 648 } |
645 | 649 |
650 private boolean isStartedByBrowserActions() { | |
651 if (BrowserActionsContextMenuItemDelegate.ACTION_BROWSER_ACTIONS_OPEN_IN _BACKGROUND.equals( | |
652 getIntent().getAction())) { | |
653 return true; | |
654 } | |
655 return false; | |
656 } | |
657 | |
658 private boolean setInitialOverviewState() { | |
659 boolean isOverviewVisible = mLayoutManager.overviewVisible(); | |
660 if (getActivityTab() == null && !isOverviewVisible) { | |
661 return true; | |
662 } | |
663 | |
664 boolean fromBrowserActions = isStartedByBrowserActions(); | |
665 boolean isSingleUrl = IntentUtils.safeGetBooleanExtra( | |
666 getIntent(), BrowserActionsContextMenuItemDelegate.EXTRA_IS_SING LE_URL, false); | |
667 if (fromBrowserActions) { | |
668 if (isSingleUrl && isOverviewVisible) { | |
669 return true; | |
670 } else if (!isSingleUrl && !isOverviewVisible) { | |
671 return true; | |
672 } | |
673 } | |
674 return false; | |
675 } | |
676 | |
646 private void initializeUI() { | 677 private void initializeUI() { |
647 try { | 678 try { |
648 TraceEvent.begin("ChromeTabbedActivity.initializeUI"); | 679 TraceEvent.begin("ChromeTabbedActivity.initializeUI"); |
649 | 680 |
650 CompositorViewHolder compositorViewHolder = getCompositorViewHolder( ); | 681 CompositorViewHolder compositorViewHolder = getCompositorViewHolder( ); |
651 if (DeviceFormFactor.isTablet()) { | 682 if (DeviceFormFactor.isTablet()) { |
652 mLayoutManager = new LayoutManagerChromeTablet(compositorViewHol der); | 683 mLayoutManager = new LayoutManagerChromeTablet(compositorViewHol der); |
653 } else { | 684 } else { |
654 mLayoutManager = new LayoutManagerChromePhone(compositorViewHold er); | 685 mLayoutManager = new LayoutManagerChromePhone(compositorViewHold er); |
655 } | 686 } |
(...skipping 1116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1772 null, | 1803 null, |
1773 intent); | 1804 intent); |
1774 } else { | 1805 } else { |
1775 return getTabCreator(false).launchUrlFromExternalApp(url, referer, h eaders, | 1806 return getTabCreator(false).launchUrlFromExternalApp(url, referer, h eaders, |
1776 externalAppId, forceNewTab, intent, mIntentHandlingTimeMs); | 1807 externalAppId, forceNewTab, intent, mIntentHandlingTimeMs); |
1777 } | 1808 } |
1778 } | 1809 } |
1779 | 1810 |
1780 private void toggleOverview() { | 1811 private void toggleOverview() { |
1781 Tab currentTab = getActivityTab(); | 1812 Tab currentTab = getActivityTab(); |
1813 if (currentTab == null) { | |
1814 mLayoutManager.showOverview(false); | |
David Trainor- moved to gerrit
2017/05/23 06:16:43
Do we need this? If so, should we just return aft
ltian
2017/05/23 18:36:46
Originally, this is a separate check outside the t
| |
1815 } | |
1782 ContentViewCore contentViewCore = | 1816 ContentViewCore contentViewCore = |
1783 currentTab != null ? currentTab.getContentViewCore() : null; | 1817 currentTab != null ? currentTab.getContentViewCore() : null; |
1784 | 1818 |
1785 if (!mLayoutManager.overviewVisible()) { | 1819 if (!mLayoutManager.overviewVisible()) { |
1786 getCompositorViewHolder().hideKeyboard(new Runnable() { | 1820 getCompositorViewHolder().hideKeyboard(new Runnable() { |
1787 @Override | 1821 @Override |
1788 public void run() { | 1822 public void run() { |
1789 mLayoutManager.showOverview(true); | 1823 mLayoutManager.showOverview(true); |
1790 } | 1824 } |
1791 }); | 1825 }); |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2107 | 2141 |
2108 private boolean shouldCreateNewTabsUsingBottomSheet() { | 2142 private boolean shouldCreateNewTabsUsingBottomSheet() { |
2109 if (mShouldCreateNewTabsUsingBottomSheet == null) { | 2143 if (mShouldCreateNewTabsUsingBottomSheet == null) { |
2110 mShouldCreateNewTabsUsingBottomSheet = getBottomSheet() != null | 2144 mShouldCreateNewTabsUsingBottomSheet = getBottomSheet() != null |
2111 && ChromeFeatureList.isEnabled(ChromeFeatureList.CHROME_HOME _NTP_REDESIGN); | 2145 && ChromeFeatureList.isEnabled(ChromeFeatureList.CHROME_HOME _NTP_REDESIGN); |
2112 } | 2146 } |
2113 | 2147 |
2114 return mShouldCreateNewTabsUsingBottomSheet; | 2148 return mShouldCreateNewTabsUsingBottomSheet; |
2115 } | 2149 } |
2116 } | 2150 } |
OLD | NEW |