| 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.ntp; | 5 package org.chromium.chrome.browser.ntp; |
| 6 | 6 |
| 7 import android.annotation.SuppressLint; | 7 import android.annotation.SuppressLint; |
| 8 import android.content.Context; | 8 import android.content.Context; |
| 9 import android.content.res.Configuration; | 9 import android.content.res.Configuration; |
| 10 import android.content.res.Resources; | 10 import android.content.res.Resources; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 import android.widget.FrameLayout; | 35 import android.widget.FrameLayout; |
| 36 import android.widget.ImageView; | 36 import android.widget.ImageView; |
| 37 import android.widget.TextView; | 37 import android.widget.TextView; |
| 38 | 38 |
| 39 import org.chromium.base.ApiCompatibilityUtils; | 39 import org.chromium.base.ApiCompatibilityUtils; |
| 40 import org.chromium.base.Callback; | 40 import org.chromium.base.Callback; |
| 41 import org.chromium.base.Log; | 41 import org.chromium.base.Log; |
| 42 import org.chromium.base.VisibleForTesting; | 42 import org.chromium.base.VisibleForTesting; |
| 43 import org.chromium.chrome.R; | 43 import org.chromium.chrome.R; |
| 44 import org.chromium.chrome.browser.ChromeActivity; | 44 import org.chromium.chrome.browser.ChromeActivity; |
| 45 import org.chromium.chrome.browser.favicon.FaviconHelper.FaviconImageCallback; | |
| 46 import org.chromium.chrome.browser.favicon.FaviconHelper.IconAvailabilityCallbac
k; | |
| 47 import org.chromium.chrome.browser.favicon.LargeIconBridge.LargeIconCallback; | 45 import org.chromium.chrome.browser.favicon.LargeIconBridge.LargeIconCallback; |
| 48 import org.chromium.chrome.browser.ntp.LogoBridge.Logo; | 46 import org.chromium.chrome.browser.ntp.LogoBridge.Logo; |
| 49 import org.chromium.chrome.browser.ntp.LogoBridge.LogoObserver; | 47 import org.chromium.chrome.browser.ntp.LogoBridge.LogoObserver; |
| 50 import org.chromium.chrome.browser.ntp.MostVisitedItem.MostVisitedItemManager; | 48 import org.chromium.chrome.browser.ntp.MostVisitedItem.MostVisitedItemManager; |
| 51 import org.chromium.chrome.browser.ntp.NewTabPage.DestructionObserver; | 49 import org.chromium.chrome.browser.ntp.NewTabPage.DestructionObserver; |
| 52 import org.chromium.chrome.browser.ntp.NewTabPage.OnSearchBoxScrollListener; | 50 import org.chromium.chrome.browser.ntp.NewTabPage.OnSearchBoxScrollListener; |
| 53 import org.chromium.chrome.browser.ntp.cards.CardsVariationParameters; | 51 import org.chromium.chrome.browser.ntp.cards.CardsVariationParameters; |
| 54 import org.chromium.chrome.browser.ntp.cards.NewTabPageAdapter; | 52 import org.chromium.chrome.browser.ntp.cards.NewTabPageAdapter; |
| 55 import org.chromium.chrome.browser.ntp.cards.NewTabPageRecyclerView; | 53 import org.chromium.chrome.browser.ntp.cards.NewTabPageRecyclerView; |
| 56 import org.chromium.chrome.browser.ntp.snippets.SnippetArticle; | |
| 57 import org.chromium.chrome.browser.ntp.snippets.SnippetsConfig; | 54 import org.chromium.chrome.browser.ntp.snippets.SnippetsConfig; |
| 58 import org.chromium.chrome.browser.ntp.snippets.SuggestionsSource; | |
| 59 import org.chromium.chrome.browser.offlinepages.OfflinePageBridge; | 55 import org.chromium.chrome.browser.offlinepages.OfflinePageBridge; |
| 60 import org.chromium.chrome.browser.profiles.MostVisitedSites.MostVisitedURLsObse
rver; | 56 import org.chromium.chrome.browser.profiles.MostVisitedSites.MostVisitedURLsObse
rver; |
| 61 import org.chromium.chrome.browser.profiles.Profile; | 57 import org.chromium.chrome.browser.profiles.Profile; |
| 62 import org.chromium.chrome.browser.suggestions.SuggestionsMetricsReporter; | 58 import org.chromium.chrome.browser.suggestions.SuggestionsUiDelegate; |
| 63 import org.chromium.chrome.browser.tab.Tab; | 59 import org.chromium.chrome.browser.tab.Tab; |
| 64 import org.chromium.chrome.browser.util.MathUtils; | 60 import org.chromium.chrome.browser.util.MathUtils; |
| 65 import org.chromium.chrome.browser.util.ViewUtils; | 61 import org.chromium.chrome.browser.util.ViewUtils; |
| 66 import org.chromium.chrome.browser.widget.RoundedIconGenerator; | 62 import org.chromium.chrome.browser.widget.RoundedIconGenerator; |
| 67 import org.chromium.ui.base.DeviceFormFactor; | 63 import org.chromium.ui.base.DeviceFormFactor; |
| 68 | 64 |
| 69 import java.util.Arrays; | 65 import java.util.Arrays; |
| 70 import java.util.HashSet; | 66 import java.util.HashSet; |
| 71 import java.util.Set; | 67 import java.util.Set; |
| 72 | 68 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 95 private NewTabPageRecyclerView mRecyclerView; | 91 private NewTabPageRecyclerView mRecyclerView; |
| 96 | 92 |
| 97 private NewTabPageLayout mNewTabPageLayout; | 93 private NewTabPageLayout mNewTabPageLayout; |
| 98 private LogoView mSearchProviderLogoView; | 94 private LogoView mSearchProviderLogoView; |
| 99 private View mSearchBoxView; | 95 private View mSearchBoxView; |
| 100 private ImageView mVoiceSearchButton; | 96 private ImageView mVoiceSearchButton; |
| 101 private MostVisitedLayout mMostVisitedLayout; | 97 private MostVisitedLayout mMostVisitedLayout; |
| 102 private View mMostVisitedPlaceholder; | 98 private View mMostVisitedPlaceholder; |
| 103 private View mNoSearchLogoSpacer; | 99 private View mNoSearchLogoSpacer; |
| 104 | 100 |
| 105 /** Adapter for {@link #mRecyclerView}. Will be {@code null} when using the
old UI */ | |
| 106 private NewTabPageAdapter mNewTabPageAdapter; | |
| 107 | |
| 108 private OnSearchBoxScrollListener mSearchBoxScrollListener; | 101 private OnSearchBoxScrollListener mSearchBoxScrollListener; |
| 109 | 102 |
| 110 private ChromeActivity mActivity; | 103 private ChromeActivity mActivity; |
| 111 private NewTabPageManager mManager; | 104 private NewTabPageManager mManager; |
| 112 private UiConfig mUiConfig; | 105 private UiConfig mUiConfig; |
| 113 private MostVisitedDesign mMostVisitedDesign; | 106 private MostVisitedDesign mMostVisitedDesign; |
| 114 private MostVisitedItem[] mMostVisitedItems; | 107 private MostVisitedItem[] mMostVisitedItems; |
| 115 private boolean mFirstShow = true; | 108 private boolean mFirstShow = true; |
| 116 private boolean mSearchProviderHasLogo = true; | 109 private boolean mSearchProviderHasLogo = true; |
| 117 private boolean mHasReceivedMostVisitedSites; | 110 private boolean mHasReceivedMostVisitedSites; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 132 private boolean mSnapshotMostVisitedChanged; | 125 private boolean mSnapshotMostVisitedChanged; |
| 133 private boolean mNewTabPageRecyclerViewChanged; | 126 private boolean mNewTabPageRecyclerViewChanged; |
| 134 private int mSnapshotWidth; | 127 private int mSnapshotWidth; |
| 135 private int mSnapshotHeight; | 128 private int mSnapshotHeight; |
| 136 private int mSnapshotScrollY; | 129 private int mSnapshotScrollY; |
| 137 private ContextMenuManager mContextMenuManager; | 130 private ContextMenuManager mContextMenuManager; |
| 138 | 131 |
| 139 /** | 132 /** |
| 140 * Manages the view interaction with the rest of the system. | 133 * Manages the view interaction with the rest of the system. |
| 141 */ | 134 */ |
| 142 public interface NewTabPageManager extends MostVisitedItemManager { | 135 public interface NewTabPageManager extends MostVisitedItemManager, Suggestio
nsUiDelegate { |
| 143 /** @return Whether the location bar is shown in the NTP. */ | 136 /** @return Whether the location bar is shown in the NTP. */ |
| 144 boolean isLocationBarShownInNTP(); | 137 boolean isLocationBarShownInNTP(); |
| 145 | 138 |
| 146 /** @return Whether voice search is enabled and the microphone should be
shown. */ | 139 /** @return Whether voice search is enabled and the microphone should be
shown. */ |
| 147 boolean isVoiceSearchEnabled(); | 140 boolean isVoiceSearchEnabled(); |
| 148 | 141 |
| 149 /** @return Whether the omnibox 'Search or type URL' text should be show
n. */ | 142 /** @return Whether the omnibox 'Search or type URL' text should be show
n. */ |
| 150 boolean isFakeOmniboxTextEnabledTablet(); | 143 boolean isFakeOmniboxTextEnabledTablet(); |
| 151 | 144 |
| 152 /** @return Whether context menus should allow the option to open a link
in a new window. */ | |
| 153 boolean isOpenInNewWindowEnabled(); | |
| 154 | |
| 155 /** @return Whether context menus should allow the option to open a link
in incognito. */ | |
| 156 boolean isOpenInIncognitoEnabled(); | |
| 157 | |
| 158 /** Opens the bookmarks page in the current tab. */ | |
| 159 void navigateToBookmarks(); | |
| 160 | |
| 161 /** Opens the recent tabs page in the current tab. */ | |
| 162 void navigateToRecentTabs(); | |
| 163 | |
| 164 /** Opens the Download Manager UI in the current tab. */ | |
| 165 void navigateToDownloadManager(); | |
| 166 | |
| 167 /** | |
| 168 * Opens a content suggestion and records related metrics. | |
| 169 * @param windowOpenDisposition How to open (current tab, new tab, new w
indow etc). | |
| 170 * @param article The content suggestion to open. | |
| 171 */ | |
| 172 void openSnippet(int windowOpenDisposition, SnippetArticle article); | |
| 173 | |
| 174 /** | 145 /** |
| 175 * Animates the search box up into the omnibox and bring up the keyboard
. | 146 * Animates the search box up into the omnibox and bring up the keyboard
. |
| 176 * @param beginVoiceSearch Whether to begin a voice search. | 147 * @param beginVoiceSearch Whether to begin a voice search. |
| 177 * @param pastedText Text to paste in the omnibox after it's been focuse
d. May be null. | 148 * @param pastedText Text to paste in the omnibox after it's been focuse
d. May be null. |
| 178 */ | 149 */ |
| 179 void focusSearchBox(boolean beginVoiceSearch, String pastedText); | 150 void focusSearchBox(boolean beginVoiceSearch, String pastedText); |
| 180 | 151 |
| 181 /** | 152 /** |
| 182 * Gets the list of most visited sites. | 153 * Gets the list of most visited sites. |
| 183 * @param observer The observer to be notified with the list of sites. | 154 * @param observer The observer to be notified with the list of sites. |
| 184 * @param numResults The maximum number of sites to retrieve. | 155 * @param numResults The maximum number of sites to retrieve. |
| 185 */ | 156 */ |
| 186 void setMostVisitedURLsObserver(MostVisitedURLsObserver observer, int nu
mResults); | 157 void setMostVisitedURLsObserver(MostVisitedURLsObserver observer, int nu
mResults); |
| 187 | 158 |
| 188 /** | 159 /** |
| 189 * Gets the favicon image for a given URL. | |
| 190 * @param url The URL of the site whose favicon is being requested. | |
| 191 * @param size The desired size of the favicon in pixels. | |
| 192 * @param faviconCallback The callback to be notified when the favicon i
s available. | |
| 193 */ | |
| 194 void getLocalFaviconImageForURL( | |
| 195 String url, int size, FaviconImageCallback faviconCallback); | |
| 196 | |
| 197 /** | |
| 198 * Gets the large icon (e.g. favicon or touch icon) for a given URL. | |
| 199 * @param url The URL of the site whose icon is being requested. | |
| 200 * @param size The desired size of the icon in pixels. | |
| 201 * @param callback The callback to be notified when the icon is availabl
e. | |
| 202 */ | |
| 203 void getLargeIconForUrl(String url, int size, LargeIconCallback callback
); | |
| 204 | |
| 205 /** | |
| 206 * Checks if an icon with the given URL is available. If not, | |
| 207 * downloads it and stores it as a favicon/large icon for the given {@co
de pageUrl}. | |
| 208 * @param pageUrl The URL of the site whose icon is being requested. | |
| 209 * @param iconUrl The URL of the favicon/large icon. | |
| 210 * @param isLargeIcon Whether the {@code iconUrl} represents a large ico
n or favicon. | |
| 211 * @param callback The callback to be notified when the favicon has been
checked. | |
| 212 */ | |
| 213 void ensureIconIsAvailable(String pageUrl, String iconUrl, boolean isLar
geIcon, | |
| 214 boolean isTemporary, IconAvailabilityCallback callback); | |
| 215 | |
| 216 /** | |
| 217 * Checks if the pages with the given URLs are available offline. | |
| 218 * @param pageUrls The URLs of the sites whose offline availability is r
equested. | |
| 219 * @param callback Fired when the results are available. | |
| 220 */ | |
| 221 void getUrlsAvailableOffline(Set<String> pageUrls, Callback<Set<String>>
callback); | |
| 222 | |
| 223 /** | |
| 224 * Called when the user clicks on the logo. | 160 * Called when the user clicks on the logo. |
| 225 * @param isAnimatedLogoShowing Whether the animated GIF logo is playing
. | 161 * @param isAnimatedLogoShowing Whether the animated GIF logo is playing
. |
| 226 */ | 162 */ |
| 227 void onLogoClicked(boolean isAnimatedLogoShowing); | 163 void onLogoClicked(boolean isAnimatedLogoShowing); |
| 228 | 164 |
| 229 /** | 165 /** |
| 230 * Gets the default search provider's logo and calls logoObserver with t
he result. | 166 * Gets the default search provider's logo and calls logoObserver with t
he result. |
| 231 * @param logoObserver The callback to notify when the logo is available
. | 167 * @param logoObserver The callback to notify when the logo is available
. |
| 232 */ | 168 */ |
| 233 void getSearchProviderLogo(LogoObserver logoObserver); | 169 void getSearchProviderLogo(LogoObserver logoObserver); |
| 234 | 170 |
| 235 /** | 171 /** |
| 236 * Called when the NTP has completely finished loading (all views will b
e inflated | 172 * Called when the NTP has completely finished loading (all views will b
e inflated |
| 237 * and any dependent resources will have been loaded). | 173 * and any dependent resources will have been loaded). |
| 238 * @param mostVisitedItems The MostVisitedItem shown on the NTP. Used to
record metrics. | 174 * @param mostVisitedItems The MostVisitedItem shown on the NTP. Used to
record metrics. |
| 239 */ | 175 */ |
| 240 void onLoadingComplete(MostVisitedItem[] mostVisitedItems); | 176 void onLoadingComplete(MostVisitedItem[] mostVisitedItems); |
| 241 | 177 |
| 242 /** | 178 /** |
| 243 * Handles clicks on the "learn more" link in the footer. | |
| 244 */ | |
| 245 void onLearnMoreClicked(); | |
| 246 | |
| 247 /** | |
| 248 * Returns the SuggestionsSource or null if it doesn't exist. The Sugges
tionsSource is | |
| 249 * invalidated (has destroy() called) when the NewTabPage is destroyed s
o use this method | |
| 250 * instead of keeping your own reference. | |
| 251 */ | |
| 252 @Nullable SuggestionsSource getSuggestionsSource(); | |
| 253 | |
| 254 /** | |
| 255 * Registers a {@link DestructionObserver}, notified when the New Tab Pa
ge goes away. | |
| 256 */ | |
| 257 void addDestructionObserver(DestructionObserver destructionObserver); | |
| 258 | |
| 259 /** | |
| 260 * @return whether the {@link NewTabPage} associated with this manager i
s the current page | 179 * @return whether the {@link NewTabPage} associated with this manager i
s the current page |
| 261 * displayed to the user. | 180 * displayed to the user. |
| 262 */ | 181 */ |
| 263 boolean isCurrentPage(); | 182 boolean isCurrentPage(); |
| 264 | 183 |
| 265 /** | 184 /** |
| 266 * @return The context menu manager. Will be {@code null} if the {@link
NewTabPageView} is | 185 * @return The context menu manager. Will be {@code null} if the {@link
NewTabPageView} is |
| 267 * not done initialising. | 186 * not done initialising. |
| 268 */ | 187 */ |
| 269 @Nullable | 188 @Nullable |
| 270 ContextMenuManager getContextMenuManager(); | 189 ContextMenuManager getContextMenuManager(); |
| 271 | |
| 272 /** | |
| 273 * @return The suggestion metrics reporter. Will be {@code null} if the | |
| 274 * {@link NewTabPageView} is not done initialising. | |
| 275 */ | |
| 276 @Nullable | |
| 277 SuggestionsMetricsReporter getSuggestionsMetricsReporter(); | |
| 278 } | 190 } |
| 279 | 191 |
| 280 /** | 192 /** |
| 281 * Default constructor required for XML inflation. | 193 * Default constructor required for XML inflation. |
| 282 */ | 194 */ |
| 283 public NewTabPageView(Context context, AttributeSet attrs) { | 195 public NewTabPageView(Context context, AttributeSet attrs) { |
| 284 super(context, attrs); | 196 super(context, attrs); |
| 285 } | 197 } |
| 286 | 198 |
| 287 /** | 199 /** |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 } | 241 } |
| 330 }); | 242 }); |
| 331 } else { | 243 } else { |
| 332 stub.setLayoutResource(R.layout.new_tab_page_scroll_view); | 244 stub.setLayoutResource(R.layout.new_tab_page_scroll_view); |
| 333 mScrollView = (NewTabPageScrollView) stub.inflate(); | 245 mScrollView = (NewTabPageScrollView) stub.inflate(); |
| 334 mScrollView.setBackgroundColor( | 246 mScrollView.setBackgroundColor( |
| 335 ApiCompatibilityUtils.getColor(getResources(), R.color.ntp_b
g)); | 247 ApiCompatibilityUtils.getColor(getResources(), R.color.ntp_b
g)); |
| 336 mScrollView.enableBottomShadow(SHADOW_COLOR); | 248 mScrollView.enableBottomShadow(SHADOW_COLOR); |
| 337 mNewTabPageLayout = (NewTabPageLayout) findViewById(R.id.ntp_content
); | 249 mNewTabPageLayout = (NewTabPageLayout) findViewById(R.id.ntp_content
); |
| 338 } | 250 } |
| 339 mContextMenuManager = new ContextMenuManager(mActivity, mManager, | 251 mContextMenuManager = new ContextMenuManager(mActivity, mManager.getNavi
gationDelegate(), |
| 340 mUseCardsUi ? mRecyclerView : mScrollView); | 252 mUseCardsUi ? mRecyclerView : mScrollView); |
| 341 mActivity.getWindowAndroid().addContextMenuCloseListener(mContextMenuMan
ager); | 253 mActivity.getWindowAndroid().addContextMenuCloseListener(mContextMenuMan
ager); |
| 342 manager.addDestructionObserver(new DestructionObserver() { | 254 manager.addDestructionObserver(new DestructionObserver() { |
| 343 @Override | 255 @Override |
| 344 public void onDestroy() { | 256 public void onDestroy() { |
| 345 mActivity.getWindowAndroid().removeContextMenuCloseListener(mCon
textMenuManager); | 257 mActivity.getWindowAndroid().removeContextMenuCloseListener(mCon
textMenuManager); |
| 346 } | 258 } |
| 347 }); | 259 }); |
| 348 | 260 |
| 349 mMostVisitedDesign = new MostVisitedDesign(getContext()); | 261 mMostVisitedDesign = new MostVisitedDesign(getContext()); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 362 | 274 |
| 363 mNewTabPageLayout.addOnLayoutChangeListener(this); | 275 mNewTabPageLayout.addOnLayoutChangeListener(this); |
| 364 setSearchProviderHasLogo(searchProviderHasLogo); | 276 setSearchProviderHasLogo(searchProviderHasLogo); |
| 365 | 277 |
| 366 mPendingLoadTasks++; | 278 mPendingLoadTasks++; |
| 367 mManager.setMostVisitedURLsObserver( | 279 mManager.setMostVisitedURLsObserver( |
| 368 this, mMostVisitedDesign.getNumberOfTiles(searchProviderHasLogo)
); | 280 this, mMostVisitedDesign.getNumberOfTiles(searchProviderHasLogo)
); |
| 369 | 281 |
| 370 // Set up snippets | 282 // Set up snippets |
| 371 if (mUseCardsUi) { | 283 if (mUseCardsUi) { |
| 372 mNewTabPageAdapter = new NewTabPageAdapter(mManager, mNewTabPageLayo
ut, mUiConfig, | 284 NewTabPageAdapter newTabPageAdapter = new NewTabPageAdapter(mManager
, mNewTabPageLayout, |
| 373 OfflinePageBridge.getForProfile(Profile.getLastUsedProfile()
)); | 285 mUiConfig, OfflinePageBridge.getForProfile(Profile.getLastUs
edProfile()), |
| 374 mRecyclerView.setAdapter(mNewTabPageAdapter); | 286 mContextMenuManager); |
| 287 mRecyclerView.setAdapter(newTabPageAdapter); |
| 375 | 288 |
| 376 int scrollOffset; | 289 int scrollOffset; |
| 377 if (CardsVariationParameters.isScrollBelowTheFoldEnabled()) { | 290 if (CardsVariationParameters.isScrollBelowTheFoldEnabled()) { |
| 378 scrollPosition = mNewTabPageAdapter.getFirstHeaderPosition(); | 291 scrollPosition = newTabPageAdapter.getFirstHeaderPosition(); |
| 379 scrollOffset = getResources().getDimensionPixelSize(R.dimen.ntp_
search_box_height); | 292 scrollOffset = getResources().getDimensionPixelSize(R.dimen.ntp_
search_box_height); |
| 380 } else { | 293 } else { |
| 381 scrollOffset = 0; | 294 scrollOffset = 0; |
| 382 } | 295 } |
| 383 mRecyclerView.getLinearLayoutManager().scrollToPositionWithOffset( | 296 mRecyclerView.getLinearLayoutManager().scrollToPositionWithOffset( |
| 384 scrollPosition, scrollOffset); | 297 scrollPosition, scrollOffset); |
| 385 | 298 |
| 386 mRecyclerView.setUpSwipeToDismiss(); | 299 mRecyclerView.setUpSwipeToDismiss(); |
| 387 | 300 |
| 388 initializeSearchBoxRecyclerViewScrollHandling(); | 301 initializeSearchBoxRecyclerViewScrollHandling(); |
| 389 | 302 |
| 390 // When the NewTabPageAdapter's data changes we need to invalidate a
ny previous | 303 // When the NewTabPageAdapter's data changes we need to invalidate a
ny previous |
| 391 // screen captures of the NewTabPageView. | 304 // screen captures of the NewTabPageView. |
| 392 mNewTabPageAdapter.registerAdapterDataObserver(new AdapterDataObserv
er() { | 305 newTabPageAdapter.registerAdapterDataObserver(new AdapterDataObserve
r() { |
| 393 @Override | 306 @Override |
| 394 public void onChanged() { | 307 public void onChanged() { |
| 395 mNewTabPageRecyclerViewChanged = true; | 308 mNewTabPageRecyclerViewChanged = true; |
| 396 } | 309 } |
| 397 | 310 |
| 398 @Override | 311 @Override |
| 399 public void onItemRangeChanged(int positionStart, int itemCount)
{ | 312 public void onItemRangeChanged(int positionStart, int itemCount)
{ |
| 400 onChanged(); | 313 onChanged(); |
| 401 } | 314 } |
| 402 | 315 |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 475 NewTabPageToolbar toolbar = (NewTabPageToolbar) findViewById(R.id.ntp_to
olbar); | 388 NewTabPageToolbar toolbar = (NewTabPageToolbar) findViewById(R.id.ntp_to
olbar); |
| 476 if (SnippetsConfig.isEnabled()) { | 389 if (SnippetsConfig.isEnabled()) { |
| 477 ((ViewGroup) toolbar.getParent()).removeView(toolbar); | 390 ((ViewGroup) toolbar.getParent()).removeView(toolbar); |
| 478 MarginLayoutParams params = (MarginLayoutParams) getWrapperView().ge
tLayoutParams(); | 391 MarginLayoutParams params = (MarginLayoutParams) getWrapperView().ge
tLayoutParams(); |
| 479 params.bottomMargin = 0; | 392 params.bottomMargin = 0; |
| 480 } else { | 393 } else { |
| 481 toolbar.getRecentTabsButton().setOnClickListener(new View.OnClickLis
tener() { | 394 toolbar.getRecentTabsButton().setOnClickListener(new View.OnClickLis
tener() { |
| 482 @Override | 395 @Override |
| 483 public void onClick(View v) { | 396 public void onClick(View v) { |
| 484 NewTabPageUma.recordAction(NewTabPageUma.ACTION_OPENED_RECEN
T_TABS_MANAGER); | 397 NewTabPageUma.recordAction(NewTabPageUma.ACTION_OPENED_RECEN
T_TABS_MANAGER); |
| 485 mManager.navigateToRecentTabs(); | 398 mManager.getNavigationDelegate().navigateToRecentTabs(); |
| 486 } | 399 } |
| 487 }); | 400 }); |
| 488 toolbar.getBookmarksButton().setOnClickListener(new View.OnClickList
ener() { | 401 toolbar.getBookmarksButton().setOnClickListener(new View.OnClickList
ener() { |
| 489 @Override | 402 @Override |
| 490 public void onClick(View v) { | 403 public void onClick(View v) { |
| 491 NewTabPageUma.recordAction(NewTabPageUma.ACTION_OPENED_BOOKM
ARKS_MANAGER); | 404 NewTabPageUma.recordAction(NewTabPageUma.ACTION_OPENED_BOOKM
ARKS_MANAGER); |
| 492 mManager.navigateToBookmarks(); | 405 mManager.getNavigationDelegate().navigateToBookmarks(); |
| 493 } | 406 } |
| 494 }); | 407 }); |
| 495 } | 408 } |
| 496 } | 409 } |
| 497 | 410 |
| 498 private void updateSearchBoxOnScroll() { | 411 private void updateSearchBoxOnScroll() { |
| 499 if (mDisableUrlFocusChangeAnimations) return; | 412 if (mDisableUrlFocusChangeAnimations) return; |
| 500 | 413 |
| 501 // When the page changes (tab switching or new page loading), it is poss
ible that events | 414 // When the page changes (tab switching or new page loading), it is poss
ible that events |
| 502 // (e.g. delayed RecyclerView change notifications) trigger calls to the
se methods after | 415 // (e.g. delayed RecyclerView change notifications) trigger calls to the
se methods after |
| (...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1219 public int getScrollPosition() { | 1132 public int getScrollPosition() { |
| 1220 if (mUseCardsUi) return mRecyclerView.getScrollPosition(); | 1133 if (mUseCardsUi) return mRecyclerView.getScrollPosition(); |
| 1221 return RecyclerView.NO_POSITION; | 1134 return RecyclerView.NO_POSITION; |
| 1222 } | 1135 } |
| 1223 | 1136 |
| 1224 /** @return the context menu manager. */ | 1137 /** @return the context menu manager. */ |
| 1225 public ContextMenuManager getContextMenuManager() { | 1138 public ContextMenuManager getContextMenuManager() { |
| 1226 return mContextMenuManager; | 1139 return mContextMenuManager; |
| 1227 } | 1140 } |
| 1228 } | 1141 } |
| OLD | NEW |