| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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.suggestions; | 5 package org.chromium.chrome.browser.suggestions; |
| 6 | 6 |
| 7 import android.view.View; | 7 import android.view.View; |
| 8 | 8 |
| 9 import org.chromium.chrome.browser.ChromeActivity; | 9 import org.chromium.chrome.browser.ChromeActivity; |
| 10 import org.chromium.chrome.browser.NativePageHost; | 10 import org.chromium.chrome.browser.NativePageHost; |
| 11 import org.chromium.chrome.browser.ntp.ContextMenuManager; | 11 import org.chromium.chrome.browser.ntp.ContextMenuManager; |
| 12 import org.chromium.chrome.browser.ntp.cards.NewTabPageAdapter; | 12 import org.chromium.chrome.browser.ntp.cards.NewTabPageAdapter; |
| 13 import org.chromium.chrome.browser.ntp.snippets.SnippetsBridge; | 13 import org.chromium.chrome.browser.ntp.snippets.SnippetsBridge; |
| 14 import org.chromium.chrome.browser.ntp.snippets.SuggestionsSource; | 14 import org.chromium.chrome.browser.ntp.snippets.SuggestionsSource; |
| 15 import org.chromium.chrome.browser.offlinepages.OfflinePageBridge; | 15 import org.chromium.chrome.browser.offlinepages.OfflinePageBridge; |
| 16 import org.chromium.chrome.browser.profiles.Profile; | 16 import org.chromium.chrome.browser.profiles.Profile; |
| 17 import org.chromium.chrome.browser.tabmodel.TabModelSelector; | 17 import org.chromium.chrome.browser.tabmodel.TabModelSelector; |
| 18 import org.chromium.chrome.browser.widget.bottomsheet.BottomSheet; | 18 import org.chromium.chrome.browser.widget.bottomsheet.BottomSheet; |
| 19 import org.chromium.chrome.browser.widget.bottomsheet.BottomSheetContentControll
er; |
| 19 import org.chromium.chrome.browser.widget.bottomsheet.EmptyBottomSheetObserver; | 20 import org.chromium.chrome.browser.widget.bottomsheet.EmptyBottomSheetObserver; |
| 20 import org.chromium.chrome.browser.widget.displaystyle.UiConfig; | 21 import org.chromium.chrome.browser.widget.displaystyle.UiConfig; |
| 21 | 22 |
| 22 /** | 23 /** |
| 23 * Provides content to be displayed inside of the Home tab of bottom sheet. | 24 * Provides content to be displayed inside of the Home tab of bottom sheet. |
| 24 * | 25 * |
| 25 * TODO(dgn): If the bottom sheet view is not recreated across tab changes, it w
ill have to be | 26 * TODO(dgn): If the bottom sheet view is not recreated across tab changes, it w
ill have to be |
| 26 * notified of it, at least when it is pulled up on the new tab. | 27 * notified of it, at least when it is pulled up on the new tab. |
| 27 */ | 28 */ |
| 28 public class SuggestionsBottomSheetContent implements BottomSheet.BottomSheetCon
tent { | 29 public class SuggestionsBottomSheetContent implements BottomSheet.BottomSheetCon
tent { |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 | 87 |
| 87 @Override | 88 @Override |
| 88 public int getVerticalScrollOffset() { | 89 public int getVerticalScrollOffset() { |
| 89 return mRecyclerView.computeVerticalScrollOffset(); | 90 return mRecyclerView.computeVerticalScrollOffset(); |
| 90 } | 91 } |
| 91 | 92 |
| 92 public ContextMenuManager getContextMenuManager() { | 93 public ContextMenuManager getContextMenuManager() { |
| 93 return mContextMenuManager; | 94 return mContextMenuManager; |
| 94 } | 95 } |
| 95 | 96 |
| 97 @Override |
| 96 public void destroy() { | 98 public void destroy() { |
| 97 mSuggestionsManager.onDestroy(); | 99 mSuggestionsManager.onDestroy(); |
| 98 mTileGroupDelegate.destroy(); | 100 mTileGroupDelegate.destroy(); |
| 99 } | 101 } |
| 100 | 102 |
| 103 @Override |
| 104 public int getType() { |
| 105 return BottomSheetContentController.TYPE_SUGGESTIONS; |
| 106 } |
| 107 |
| 101 public static void setSuggestionsSourceForTesting(SuggestionsSource suggesti
onsSource) { | 108 public static void setSuggestionsSourceForTesting(SuggestionsSource suggesti
onsSource) { |
| 102 sSuggestionsSourceForTesting = suggestionsSource; | 109 sSuggestionsSourceForTesting = suggestionsSource; |
| 103 } | 110 } |
| 104 | 111 |
| 105 public static void setMetricsReporterForTesting(SuggestionsMetricsReporter m
etricsReporter) { | 112 public static void setMetricsReporterForTesting(SuggestionsMetricsReporter m
etricsReporter) { |
| 106 sMetricsReporterForTesting = metricsReporter; | 113 sMetricsReporterForTesting = metricsReporter; |
| 107 } | 114 } |
| 108 | 115 |
| 109 private static SuggestionsUiDelegateImpl createSuggestionsDelegate(Profile p
rofile, | 116 private static SuggestionsUiDelegateImpl createSuggestionsDelegate(Profile p
rofile, |
| 110 SuggestionsNavigationDelegate navigationDelegate, NativePageHost hos
t) { | 117 SuggestionsNavigationDelegate navigationDelegate, NativePageHost hos
t) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 126 metricsReporter = sMetricsReporterForTesting; | 133 metricsReporter = sMetricsReporterForTesting; |
| 127 } | 134 } |
| 128 | 135 |
| 129 SuggestionsUiDelegateImpl delegate = new SuggestionsUiDelegateImpl( | 136 SuggestionsUiDelegateImpl delegate = new SuggestionsUiDelegateImpl( |
| 130 suggestionsSource, metricsReporter, navigationDelegate, profile,
host); | 137 suggestionsSource, metricsReporter, navigationDelegate, profile,
host); |
| 131 if (snippetsBridge != null) delegate.addDestructionObserver(snippetsBrid
ge); | 138 if (snippetsBridge != null) delegate.addDestructionObserver(snippetsBrid
ge); |
| 132 | 139 |
| 133 return delegate; | 140 return delegate; |
| 134 } | 141 } |
| 135 } | 142 } |
| OLD | NEW |