Chromium Code Reviews| 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 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 581 | 582 |
| 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 setInitialOverviewState(); |
| 592 if (getActivityTab() == null) mLayoutManager.showOverview(false); | 593 BrowserActionsContextMenuItemDelegate.cancelBrowserActionsNotification() ; |
| 593 | 594 |
| 594 resetSavedInstanceState(); | 595 resetSavedInstanceState(); |
| 595 } | 596 } |
| 596 | 597 |
| 597 @Override | 598 @Override |
| 598 public void onNewIntentWithNative(Intent intent) { | 599 public void onNewIntentWithNative(Intent intent) { |
| 599 try { | 600 try { |
| 600 TraceEvent.begin("ChromeTabbedActivity.onNewIntentWithNative"); | 601 TraceEvent.begin("ChromeTabbedActivity.onNewIntentWithNative"); |
| 601 | 602 |
| 602 super.onNewIntentWithNative(intent); | 603 super.onNewIntentWithNative(intent); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 636 | 637 |
| 637 private void handleDebugIntent(Intent intent) { | 638 private void handleDebugIntent(Intent intent) { |
| 638 if (ACTION_CLOSE_TABS.equals(intent.getAction())) { | 639 if (ACTION_CLOSE_TABS.equals(intent.getAction())) { |
| 639 getTabModelSelector().closeAllTabs(); | 640 getTabModelSelector().closeAllTabs(); |
| 640 } else if (MemoryPressureListener.handleDebugIntent(ChromeTabbedActivity .this, | 641 } else if (MemoryPressureListener.handleDebugIntent(ChromeTabbedActivity .this, |
| 641 intent.getAction())) { | 642 intent.getAction())) { |
| 642 // Handled. | 643 // Handled. |
| 643 } | 644 } |
| 644 } | 645 } |
| 645 | 646 |
| 647 private boolean isStartedByBrowserActions() { | |
|
Yusuf
2017/05/30 17:57:15
would look much nicer if this was a static in Brow
ltian
2017/05/30 19:19:49
Done.
| |
| 648 if (BrowserActionsContextMenuItemDelegate.ACTION_BROWSER_ACTIONS_OPEN_IN _BACKGROUND.equals( | |
| 649 getIntent().getAction())) { | |
| 650 return true; | |
| 651 } | |
| 652 return false; | |
| 653 } | |
| 654 | |
| 655 private void setInitialOverviewState() { | |
| 656 boolean isOverviewVisible = mLayoutManager.overviewVisible(); | |
| 657 if (getActivityTab() == null && !isOverviewVisible) { | |
| 658 toggleOverview(); | |
| 659 } | |
| 660 | |
| 661 boolean fromBrowserActions = isStartedByBrowserActions(); | |
| 662 boolean isSingleUrl = IntentUtils.safeGetBooleanExtra( | |
| 663 getIntent(), BrowserActionsContextMenuItemDelegate.EXTRA_IS_SING LE_URL, false); | |
| 664 if (fromBrowserActions) { | |
| 665 if (isSingleUrl == isOverviewVisible) { | |
|
Yusuf
2017/05/30 17:57:15
all this logic is specific to BrowserActions and s
ltian
2017/05/30 19:19:49
Done.
| |
| 666 toggleOverview(); | |
| 667 } | |
| 668 } | |
| 669 } | |
| 670 | |
| 646 private void initializeUI() { | 671 private void initializeUI() { |
| 647 try { | 672 try { |
| 648 TraceEvent.begin("ChromeTabbedActivity.initializeUI"); | 673 TraceEvent.begin("ChromeTabbedActivity.initializeUI"); |
| 649 | 674 |
| 650 CompositorViewHolder compositorViewHolder = getCompositorViewHolder( ); | 675 CompositorViewHolder compositorViewHolder = getCompositorViewHolder( ); |
| 651 if (DeviceFormFactor.isTablet()) { | 676 if (DeviceFormFactor.isTablet()) { |
| 652 mLayoutManager = new LayoutManagerChromeTablet(compositorViewHol der); | 677 mLayoutManager = new LayoutManagerChromeTablet(compositorViewHol der); |
| 653 } else { | 678 } else { |
| 654 mLayoutManager = new LayoutManagerChromePhone(compositorViewHold er); | 679 mLayoutManager = new LayoutManagerChromePhone(compositorViewHold er); |
| 655 } | 680 } |
| (...skipping 1120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1776 null, | 1801 null, |
| 1777 intent); | 1802 intent); |
| 1778 } else { | 1803 } else { |
| 1779 return getTabCreator(false).launchUrlFromExternalApp(url, referer, h eaders, | 1804 return getTabCreator(false).launchUrlFromExternalApp(url, referer, h eaders, |
| 1780 externalAppId, forceNewTab, intent, mIntentHandlingTimeMs); | 1805 externalAppId, forceNewTab, intent, mIntentHandlingTimeMs); |
| 1781 } | 1806 } |
| 1782 } | 1807 } |
| 1783 | 1808 |
| 1784 private void toggleOverview() { | 1809 private void toggleOverview() { |
| 1785 Tab currentTab = getActivityTab(); | 1810 Tab currentTab = getActivityTab(); |
| 1811 // If we don't have a current tab, show the overview mode. | |
| 1812 if (currentTab == null) { | |
| 1813 mLayoutManager.showOverview(false); | |
| 1814 return; | |
| 1815 } | |
| 1786 ContentViewCore contentViewCore = | 1816 ContentViewCore contentViewCore = |
| 1787 currentTab != null ? currentTab.getContentViewCore() : null; | 1817 currentTab != null ? currentTab.getContentViewCore() : null; |
| 1788 | 1818 |
| 1789 if (!mLayoutManager.overviewVisible()) { | 1819 if (!mLayoutManager.overviewVisible()) { |
| 1790 getCompositorViewHolder().hideKeyboard(new Runnable() { | 1820 getCompositorViewHolder().hideKeyboard(new Runnable() { |
| 1791 @Override | 1821 @Override |
| 1792 public void run() { | 1822 public void run() { |
| 1793 mLayoutManager.showOverview(true); | 1823 mLayoutManager.showOverview(true); |
| 1794 } | 1824 } |
| 1795 }); | 1825 }); |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2111 | 2141 |
| 2112 private boolean shouldCreateNewTabsUsingBottomSheet() { | 2142 private boolean shouldCreateNewTabsUsingBottomSheet() { |
| 2113 if (mShouldCreateNewTabsUsingBottomSheet == null) { | 2143 if (mShouldCreateNewTabsUsingBottomSheet == null) { |
| 2114 mShouldCreateNewTabsUsingBottomSheet = getBottomSheet() != null | 2144 mShouldCreateNewTabsUsingBottomSheet = getBottomSheet() != null |
| 2115 && ChromeFeatureList.isEnabled(ChromeFeatureList.CHROME_HOME _NTP_REDESIGN); | 2145 && ChromeFeatureList.isEnabled(ChromeFeatureList.CHROME_HOME _NTP_REDESIGN); |
| 2116 } | 2146 } |
| 2117 | 2147 |
| 2118 return mShouldCreateNewTabsUsingBottomSheet; | 2148 return mShouldCreateNewTabsUsingBottomSheet; |
| 2119 } | 2149 } |
| 2120 } | 2150 } |
| OLD | NEW |