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.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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 44 import org.chromium.chrome.browser.ntp.LogoBridge.Logo; | 44 import org.chromium.chrome.browser.ntp.LogoBridge.Logo; |
| 45 import org.chromium.chrome.browser.ntp.LogoBridge.LogoObserver; | 45 import org.chromium.chrome.browser.ntp.LogoBridge.LogoObserver; |
| 46 import org.chromium.chrome.browser.ntp.MostVisitedItem.MostVisitedItemManager; | 46 import org.chromium.chrome.browser.ntp.MostVisitedItem.MostVisitedItemManager; |
| 47 import org.chromium.chrome.browser.ntp.NewTabPage.OnSearchBoxScrollListener; | 47 import org.chromium.chrome.browser.ntp.NewTabPage.OnSearchBoxScrollListener; |
| 48 import org.chromium.chrome.browser.ntp.snippets.SnippetsManager; | 48 import org.chromium.chrome.browser.ntp.snippets.SnippetsManager; |
| 49 import org.chromium.chrome.browser.preferences.DocumentModeManager; | 49 import org.chromium.chrome.browser.preferences.DocumentModeManager; |
| 50 import org.chromium.chrome.browser.profiles.MostVisitedSites.MostVisitedURLsObse rver; | 50 import org.chromium.chrome.browser.profiles.MostVisitedSites.MostVisitedURLsObse rver; |
| 51 import org.chromium.chrome.browser.profiles.MostVisitedSites.ThumbnailCallback; | 51 import org.chromium.chrome.browser.profiles.MostVisitedSites.ThumbnailCallback; |
| 52 import org.chromium.chrome.browser.util.ViewUtils; | 52 import org.chromium.chrome.browser.util.ViewUtils; |
| 53 import org.chromium.chrome.browser.widget.RoundedIconGenerator; | 53 import org.chromium.chrome.browser.widget.RoundedIconGenerator; |
| 54 import org.chromium.sync.signin.ChromeSigninController; | |
| 54 import org.chromium.ui.text.SpanApplier; | 55 import org.chromium.ui.text.SpanApplier; |
| 55 import org.chromium.ui.text.SpanApplier.SpanInfo; | 56 import org.chromium.ui.text.SpanApplier.SpanInfo; |
| 56 | 57 |
| 57 import java.util.Locale; | 58 import java.util.Locale; |
| 58 | 59 |
| 59 import jp.tomorrowkey.android.gifplayer.BaseGifImage; | 60 import jp.tomorrowkey.android.gifplayer.BaseGifImage; |
| 60 | 61 |
| 61 /** | 62 /** |
| 62 * The native new tab page, represented by some basic data such as title and url , and an Android | 63 * The native new tab page, represented by some basic data such as title and url , and an Android |
| 63 * View that displays the page. | 64 * View that displays the page. |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 127 | 128 |
| 128 /** Opens the bookmarks page in the current tab. */ | 129 /** Opens the bookmarks page in the current tab. */ |
| 129 void navigateToBookmarks(); | 130 void navigateToBookmarks(); |
| 130 | 131 |
| 131 /** Opens the recent tabs page in the current tab. */ | 132 /** Opens the recent tabs page in the current tab. */ |
| 132 void navigateToRecentTabs(); | 133 void navigateToRecentTabs(); |
| 133 | 134 |
| 134 /** Opens a given URL in the current tab. */ | 135 /** Opens a given URL in the current tab. */ |
| 135 void open(String url); | 136 void open(String url); |
| 136 | 137 |
| 138 /** Opens the recent tabs page in the current tab. */ | |
|
newt (away)
2015/12/12 00:30:31
fix javadoc
PEConn
2015/12/14 17:05:16
Done.
| |
| 139 void navigateToInterests(); | |
| 140 | |
| 137 /** | 141 /** |
| 138 * Animates the search box up into the omnibox and bring up the keyboard . | 142 * Animates the search box up into the omnibox and bring up the keyboard . |
| 139 * @param beginVoiceSearch Whether to begin a voice search. | 143 * @param beginVoiceSearch Whether to begin a voice search. |
| 140 * @param pastedText Text to paste in the omnibox after it's been focuse d. May be null. | 144 * @param pastedText Text to paste in the omnibox after it's been focuse d. May be null. |
| 141 */ | 145 */ |
| 142 void focusSearchBox(boolean beginVoiceSearch, String pastedText); | 146 void focusSearchBox(boolean beginVoiceSearch, String pastedText); |
| 143 | 147 |
| 144 /** | 148 /** |
| 145 * Gets the list of most visited sites. | 149 * Gets the list of most visited sites. |
| 146 * @param observer The observer to be notified with the list of sites. | 150 * @param observer The observer to be notified with the list of sites. |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 300 public void onClick(View v) { | 304 public void onClick(View v) { |
| 301 mManager.navigateToRecentTabs(); | 305 mManager.navigateToRecentTabs(); |
| 302 } | 306 } |
| 303 }); | 307 }); |
| 304 toolbar.getBookmarksButton().setOnClickListener(new View.OnClickListener () { | 308 toolbar.getBookmarksButton().setOnClickListener(new View.OnClickListener () { |
| 305 @Override | 309 @Override |
| 306 public void onClick(View v) { | 310 public void onClick(View v) { |
| 307 mManager.navigateToBookmarks(); | 311 mManager.navigateToBookmarks(); |
| 308 } | 312 } |
| 309 }); | 313 }); |
| 314 toolbar.getInterestsButton().setOnClickListener(new View.OnClickListener () { | |
| 315 @Override | |
| 316 public void onClick(View v) { | |
| 317 mManager.navigateToInterests(); | |
| 318 } | |
| 319 }); | |
| 310 | 320 |
| 311 initializeSearchBoxScrollHandling(); | 321 initializeSearchBoxScrollHandling(); |
| 312 addOnLayoutChangeListener(this); | 322 addOnLayoutChangeListener(this); |
| 313 setSearchProviderHasLogo(searchProviderHasLogo); | 323 setSearchProviderHasLogo(searchProviderHasLogo); |
| 314 | 324 |
| 315 mPendingLoadTasks++; | 325 mPendingLoadTasks++; |
| 316 mManager.setMostVisitedURLsObserver(this, | 326 mManager.setMostVisitedURLsObserver(this, |
| 317 mMostVisitedDesign.getNumberOfTiles(searchProviderHasLogo)); | 327 mMostVisitedDesign.getNumberOfTiles(searchProviderHasLogo)); |
| 318 | 328 |
| 319 if (mManager.shouldShowOptOutPromo()) showOptOutPromo(); | 329 if (mManager.shouldShowOptOutPromo()) showOptOutPromo(); |
| 320 | 330 |
| 321 // Set up snippets | 331 // Set up snippets |
| 322 if (CommandLine.getInstance().hasSwitch(ChromeSwitches.ENABLE_NTP_SNIPPE TS)) { | 332 if (CommandLine.getInstance().hasSwitch(ChromeSwitches.ENABLE_NTP_SNIPPE TS)) { |
| 323 mSnippetsView = (RecyclerView) findViewById(R.id.snippets_card_list) ; | 333 mSnippetsView = (RecyclerView) findViewById(R.id.snippets_card_list) ; |
| 324 mSnippetsView.setVisibility(View.VISIBLE); | 334 mSnippetsView.setVisibility(View.VISIBLE); |
| 325 mSnippetsView.setLayoutManager(new LinearLayoutManager(getContext()) ); | 335 mSnippetsView.setLayoutManager(new LinearLayoutManager(getContext()) ); |
| 326 mSnippetsManager = new SnippetsManager(mManager, mSnippetsView); | 336 mSnippetsManager = new SnippetsManager(mManager, mSnippetsView); |
| 327 } | 337 } |
| 338 | |
| 339 // Set up interests | |
| 340 if (CommandLine.getInstance().hasSwitch(ChromeSwitches.ENABLE_NTP_INTERE STS) | |
| 341 && ChromeSigninController.get(getContext()).isSignedIn()) { | |
|
newt (away)
2015/12/12 00:30:31
This class (NewTabPageView) shouldn't interact dir
PEConn
2015/12/14 17:05:16
Done.
| |
| 342 toolbar.getInterestsButton().setVisibility(View.VISIBLE); | |
| 343 } | |
| 328 } | 344 } |
| 329 | 345 |
| 330 private int getTabsMovedIllustration() { | 346 private int getTabsMovedIllustration() { |
| 331 switch (Build.MANUFACTURER.toLowerCase(Locale.US)) { | 347 switch (Build.MANUFACTURER.toLowerCase(Locale.US)) { |
| 332 case "samsung": | 348 case "samsung": |
| 333 if (DocumentModeManager.isDeviceTabbedModeByDefault()) return 0; | 349 if (DocumentModeManager.isDeviceTabbedModeByDefault()) return 0; |
| 334 return R.drawable.tabs_moved_samsung; | 350 return R.drawable.tabs_moved_samsung; |
| 335 case "htc": | 351 case "htc": |
| 336 return R.drawable.tabs_moved_htc; | 352 return R.drawable.tabs_moved_htc; |
| 337 default: | 353 default: |
| (...skipping 760 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1098 } | 1114 } |
| 1099 } | 1115 } |
| 1100 } | 1116 } |
| 1101 | 1117 |
| 1102 @Override | 1118 @Override |
| 1103 public boolean preferLargeIcons() { | 1119 public boolean preferLargeIcons() { |
| 1104 return true; | 1120 return true; |
| 1105 } | 1121 } |
| 1106 } | 1122 } |
| 1107 } | 1123 } |
| OLD | NEW |