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

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

Issue 1351303003: Add the UI for the Interests Prototype. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ntp-interests-jni
Patch Set: Fetch the oauth token from the native code. Created 5 years, 3 months 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 2edbf6eaf404192a0a77899c15165133e9f358f4..f0d85b6acaf845f29f489f245bf04d20ac558337 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
@@ -32,6 +32,7 @@ import org.chromium.chrome.browser.favicon.FaviconHelper.FaviconImageCallback;
import org.chromium.chrome.browser.favicon.LargeIconBridge;
import org.chromium.chrome.browser.favicon.LargeIconBridge.LargeIconCallback;
import org.chromium.chrome.browser.ntp.BookmarksPage.BookmarkSelectedListener;
+import org.chromium.chrome.browser.ntp.InterestsPage.InterestsListener;
import org.chromium.chrome.browser.ntp.LogoBridge.Logo;
import org.chromium.chrome.browser.ntp.LogoBridge.LogoObserver;
import org.chromium.chrome.browser.ntp.NewTabPageView.NewTabPageManager;
@@ -53,6 +54,8 @@ import org.chromium.content_public.browser.LoadUrlParams;
import org.chromium.ui.base.DeviceFormFactor;
import org.chromium.ui.base.PageTransition;
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
import java.util.concurrent.TimeUnit;
/**
@@ -159,6 +162,16 @@ public class NewTabPage
}
}
+ public static void launchInterestsDialog(Activity activity, Tab tab) {
+ InterestDialogSelectedListener listener = new InterestDialogSelectedListener(tab);
+ NativePage page = new InterestsPage(activity, tab, Profile.getLastUsedProfile(),
+ listener, activity);
+ Dialog dialog = new NativePageDialog(activity, page);
+ listener.setDialog(dialog);
+
+ dialog.show();
+ }
+
public static void launchRecentTabsDialog(Activity activity, Tab tab) {
DocumentRecentTabsManager manager = new DocumentRecentTabsManager(tab, activity);
NativePage page = new RecentTabsPage(activity, manager);
@@ -611,4 +624,38 @@ public class NewTabPage
mDialog = dialog;
}
}
+
+ private static class InterestDialogSelectedListener implements InterestsListener {
+ private static final String GOOGLE_SEARCH_URL_PATTERN =
+ "https://www.google.com/search?tbm=nws&q=%s";
+ private Dialog mDialog;
+ private final Tab mTab;
+
+ public InterestDialogSelectedListener(Tab tab) {
+ mTab = tab;
+ }
+
+ @Override
+ public void onInterestClicked(String name) {
+ if (mDialog == null) {
Bernhard Bauer 2015/09/29 14:33:28 When would this happen?
PEConn 2015/11/18 15:26:57 Done.
+ return;
+ }
+
+ try {
+ String url = String.format(GOOGLE_SEARCH_URL_PATTERN,
newt (away) 2015/09/29 17:33:22 I think you want TemplateUrlService.getInstance().
PEConn 2015/11/18 15:26:57 Done.
+ URLEncoder.encode(name, "UTF-8"));
+
+ mTab.loadUrl(new LoadUrlParams(url));
+ } catch (UnsupportedEncodingException e) {
+ // Don't redirect the tab if we have failed to encode the url. This should not
+ // happen.
+ }
+
+ mDialog.dismiss();
+ }
+
+ public void setDialog(Dialog dialog) {
+ mDialog = dialog;
+ }
+ }
}

Powered by Google App Engine
This is Rietveld 408576698