Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5819)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/ntp/NewTabPage.java

Issue 1459593002: Added a UI for the Interests Prototype. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/android/java/src/org/chromium/chrome/browser/ntp/NewTabPage.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ntp/NewTabPage.java b/chrome/android/java/src/org/chromium/chrome/browser/ntp/NewTabPage.java
index 9abd51615a5edf384459fa45f4f5870d36316634..15221e5ca2ee3f4dacba7cef01414e99e00c5f1c 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/ntp/NewTabPage.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/ntp/NewTabPage.java
@@ -45,6 +45,8 @@ import org.chromium.chrome.browser.ntp.BookmarksPage.BookmarkSelectedListener;
import org.chromium.chrome.browser.ntp.LogoBridge.Logo;
import org.chromium.chrome.browser.ntp.LogoBridge.LogoObserver;
import org.chromium.chrome.browser.ntp.NewTabPageView.NewTabPageManager;
+import org.chromium.chrome.browser.ntp.interests.InterestsPage;
+import org.chromium.chrome.browser.ntp.interests.InterestsPage.InterestsClickListener;
import org.chromium.chrome.browser.offlinepages.OfflinePageBridge;
import org.chromium.chrome.browser.preferences.DocumentModeManager;
import org.chromium.chrome.browser.preferences.DocumentModePreference;
@@ -69,6 +71,7 @@ import org.chromium.chrome.browser.util.FeatureUtilities;
import org.chromium.chrome.browser.util.UrlUtilities;
import org.chromium.content_public.browser.LoadUrlParams;
import org.chromium.net.NetworkChangeNotifier;
+import org.chromium.sync.signin.ChromeSigninController;
import org.chromium.ui.base.DeviceFormFactor;
import org.chromium.ui.base.PageTransition;
@@ -190,6 +193,24 @@ public class NewTabPage
}
}
+ public static void launchInterestsDialog(Activity activity, final Tab tab) {
+ InterestsPage page =
+ new InterestsPage(activity, tab, Profile.getLastUsedProfile());
+ final Dialog dialog = new NativePageDialog(activity, page);
+
+ InterestsClickListener listener = new InterestsClickListener() {
+ @Override
+ public void onInterestClicked(String name) {
+ tab.loadUrl(new LoadUrlParams(
+ TemplateUrlService.getInstance().getUrlForSearchQuery(name)));
+ dialog.dismiss();
+ }
+ };
+
+ page.setListener(listener);
+ dialog.show();
+ }
+
public static void launchRecentTabsDialog(Activity activity, Tab tab) {
DocumentRecentTabsManager manager = new DocumentRecentTabsManager(tab, activity);
NativePage page = new RecentTabsPage(activity, manager);
@@ -218,6 +239,12 @@ public class NewTabPage
return mFakeboxDelegate != null && mFakeboxDelegate.isVoiceSearchEnabled();
}
+ @Override
+ public boolean isInterestsEnabled() {
+ return CommandLine.getInstance().hasSwitch(ChromeSwitches.ENABLE_INTERESTS)
+ && ChromeSigninController.get(mActivity).isSignedIn();
+ }
+
private void recordOpenedMostVisitedItem(MostVisitedItem item) {
if (mIsDestroyed) return;
NewTabPageUma.recordAction(NewTabPageUma.ACTION_OPENED_MOST_VISITED_ENTRY);
@@ -380,6 +407,14 @@ public class NewTabPage
}
@Override
+ public void navigateToInterests() {
+ if (mIsDestroyed) return;
+ RecordUserAction.record("MobileNTP.Interests.OpenDialog");
+ // TODO(peconn): Make this load a native page on tablets.
+ launchInterestsDialog(mActivity, mTab);
+ }
+
+ @Override
public void focusSearchBox(boolean beginVoiceSearch, String pastedText) {
if (mIsDestroyed) return;
if (mFakeboxDelegate != null) {

Powered by Google App Engine
This is Rietveld 408576698