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.Resources; | 9 import android.content.res.Resources; |
10 import android.graphics.Bitmap; | 10 import android.graphics.Bitmap; |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 /** | 112 /** |
113 * Manages the view interaction with the rest of the system. | 113 * Manages the view interaction with the rest of the system. |
114 */ | 114 */ |
115 public interface NewTabPageManager extends MostVisitedItemManager { | 115 public interface NewTabPageManager extends MostVisitedItemManager { |
116 /** @return Whether the location bar is shown in the NTP. */ | 116 /** @return Whether the location bar is shown in the NTP. */ |
117 boolean isLocationBarShownInNTP(); | 117 boolean isLocationBarShownInNTP(); |
118 | 118 |
119 /** @return Whether voice search is enabled and the microphone should be
shown. */ | 119 /** @return Whether voice search is enabled and the microphone should be
shown. */ |
120 boolean isVoiceSearchEnabled(); | 120 boolean isVoiceSearchEnabled(); |
121 | 121 |
| 122 /** @return Whether the NTP Interests tab is enabled and its button shou
ld be shown. */ |
| 123 boolean isInterestsEnabled(); |
| 124 |
122 /** @return Whether the document mode opt out promo should be shown. */ | 125 /** @return Whether the document mode opt out promo should be shown. */ |
123 boolean shouldShowOptOutPromo(); | 126 boolean shouldShowOptOutPromo(); |
124 | 127 |
125 /** Called when the document mode opt out promo is shown. */ | 128 /** Called when the document mode opt out promo is shown. */ |
126 void optOutPromoShown(); | 129 void optOutPromoShown(); |
127 | 130 |
128 /** Called when the user clicks "settings" or "ok, got it" on the opt ou
t promo. */ | 131 /** Called when the user clicks "settings" or "ok, got it" on the opt ou
t promo. */ |
129 void optOutPromoClicked(boolean settingsClicked); | 132 void optOutPromoClicked(boolean settingsClicked); |
130 | 133 |
131 /** Opens the bookmarks page in the current tab. */ | 134 /** Opens the bookmarks page in the current tab. */ |
132 void navigateToBookmarks(); | 135 void navigateToBookmarks(); |
133 | 136 |
134 /** Opens the recent tabs page in the current tab. */ | 137 /** Opens the recent tabs page in the current tab. */ |
135 void navigateToRecentTabs(); | 138 void navigateToRecentTabs(); |
136 | 139 |
137 /** Opens a given URL in the current tab. */ | 140 /** Opens a given URL in the current tab. */ |
138 void open(String url); | 141 void open(String url); |
139 | 142 |
| 143 /** Opens the interests dialog. */ |
| 144 void navigateToInterests(); |
| 145 |
140 /** | 146 /** |
141 * Animates the search box up into the omnibox and bring up the keyboard
. | 147 * Animates the search box up into the omnibox and bring up the keyboard
. |
142 * @param beginVoiceSearch Whether to begin a voice search. | 148 * @param beginVoiceSearch Whether to begin a voice search. |
143 * @param pastedText Text to paste in the omnibox after it's been focuse
d. May be null. | 149 * @param pastedText Text to paste in the omnibox after it's been focuse
d. May be null. |
144 */ | 150 */ |
145 void focusSearchBox(boolean beginVoiceSearch, String pastedText); | 151 void focusSearchBox(boolean beginVoiceSearch, String pastedText); |
146 | 152 |
147 /** | 153 /** |
148 * Gets the list of most visited sites. | 154 * Gets the list of most visited sites. |
149 * @param observer The observer to be notified with the list of sites. | 155 * @param observer The observer to be notified with the list of sites. |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 public void onClick(View v) { | 312 public void onClick(View v) { |
307 mManager.navigateToRecentTabs(); | 313 mManager.navigateToRecentTabs(); |
308 } | 314 } |
309 }); | 315 }); |
310 toolbar.getBookmarksButton().setOnClickListener(new View.OnClickListener
() { | 316 toolbar.getBookmarksButton().setOnClickListener(new View.OnClickListener
() { |
311 @Override | 317 @Override |
312 public void onClick(View v) { | 318 public void onClick(View v) { |
313 mManager.navigateToBookmarks(); | 319 mManager.navigateToBookmarks(); |
314 } | 320 } |
315 }); | 321 }); |
| 322 toolbar.getInterestsButton().setOnClickListener(new View.OnClickListener
() { |
| 323 @Override |
| 324 public void onClick(View v) { |
| 325 mManager.navigateToInterests(); |
| 326 } |
| 327 }); |
316 | 328 |
317 initializeSearchBoxScrollHandling(); | 329 initializeSearchBoxScrollHandling(); |
318 addOnLayoutChangeListener(this); | 330 addOnLayoutChangeListener(this); |
319 setSearchProviderHasLogo(searchProviderHasLogo); | 331 setSearchProviderHasLogo(searchProviderHasLogo); |
320 | 332 |
321 mPendingLoadTasks++; | 333 mPendingLoadTasks++; |
322 mManager.setMostVisitedURLsObserver(this, | 334 mManager.setMostVisitedURLsObserver(this, |
323 mMostVisitedDesign.getNumberOfTiles(searchProviderHasLogo)); | 335 mMostVisitedDesign.getNumberOfTiles(searchProviderHasLogo)); |
324 | 336 |
325 if (mManager.shouldShowOptOutPromo()) showOptOutPromo(); | 337 if (mManager.shouldShowOptOutPromo()) showOptOutPromo(); |
(...skipping 14 matching lines...) Expand all Loading... |
340 RecordUserAction.record("MobileNTP.Snippets.Scrolled"); | 352 RecordUserAction.record("MobileNTP.Snippets.Scrolled"); |
341 if (mScrolledOnce) return; | 353 if (mScrolledOnce) return; |
342 mScrolledOnce = true; | 354 mScrolledOnce = true; |
343 RecordHistogram.recordEnumeratedHistogram( | 355 RecordHistogram.recordEnumeratedHistogram( |
344 SnippetsManager.SNIPPETS_STATE_HISTOGRAM, | 356 SnippetsManager.SNIPPETS_STATE_HISTOGRAM, |
345 SnippetsManager.SNIPPETS_SCROLLED, | 357 SnippetsManager.SNIPPETS_SCROLLED, |
346 SnippetsManager.NUM_SNIPPETS_ACTIONS); | 358 SnippetsManager.NUM_SNIPPETS_ACTIONS); |
347 } | 359 } |
348 }); | 360 }); |
349 } | 361 } |
| 362 |
| 363 // Set up interests |
| 364 if (manager.isInterestsEnabled()) { |
| 365 toolbar.getInterestsButton().setVisibility(View.VISIBLE); |
| 366 } |
350 } | 367 } |
351 | 368 |
352 private int getTabsMovedIllustration() { | 369 private int getTabsMovedIllustration() { |
353 switch (Build.MANUFACTURER.toLowerCase(Locale.US)) { | 370 switch (Build.MANUFACTURER.toLowerCase(Locale.US)) { |
354 case "samsung": | 371 case "samsung": |
355 if (DocumentModeManager.isDeviceTabbedModeByDefault()) return 0; | 372 if (DocumentModeManager.isDeviceTabbedModeByDefault()) return 0; |
356 return R.drawable.tabs_moved_samsung; | 373 return R.drawable.tabs_moved_samsung; |
357 case "htc": | 374 case "htc": |
358 return R.drawable.tabs_moved_htc; | 375 return R.drawable.tabs_moved_htc; |
359 default: | 376 default: |
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
971 for (MostVisitedItem item : mMostVisitedItems) { | 988 for (MostVisitedItem item : mMostVisitedItems) { |
972 if (item.getUrl().equals(url)) { | 989 if (item.getUrl().equals(url)) { |
973 LargeIconCallback iconCallback = new LargeIconCallbackImpl(i
tem, false); | 990 LargeIconCallback iconCallback = new LargeIconCallbackImpl(i
tem, false); |
974 mManager.getLargeIconForUrl(url, mMinIconSize, iconCallback)
; | 991 mManager.getLargeIconForUrl(url, mMinIconSize, iconCallback)
; |
975 break; | 992 break; |
976 } | 993 } |
977 } | 994 } |
978 } | 995 } |
979 } | 996 } |
980 } | 997 } |
OLD | NEW |