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) { |