Commit 3f75eb24 authored by Cathy Li's avatar Cathy Li Committed by Commit Bot

[Explore sites]: Add native page frame for explore sites page.

Bug: 867488
Change-Id: I886f26467826aa4c2beda38785bd4961f375e338
Reviewed-on: https://chromium-review.googlesource.com/1174699Reviewed-by: default avatarTheresa <twellington@chromium.org>
Reviewed-by: default avatarJustin DeWitt <dewittj@chromium.org>
Reviewed-by: default avatarMichael Giuffrida <michaelpg@chromium.org>
Commit-Queue: Cathy Li <chili@chromium.org>
Cr-Commit-Position: refs/heads/master@{#584382}
parent 45fabee2
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="@dimen/explore_sites_spacing" android:layout_marginTop="@dimen/explore_sites_spacing"
android:gravity="center" android:gravity="center"
android:text="@string/ntp_explore_sites_title" /> android:text="@string/explore_sites_title" />
<LinearLayout <LinearLayout
android:id="@+id/explore_sites_tiles" android:id="@+id/explore_sites_tiles"
......
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2018 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file. -->
<android.support.v7.widget.RecyclerView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/recycler_view"
android:layout_height="match_parent"
android:layout_width="match_parent" />
...@@ -77,4 +77,7 @@ public class UrlConstants { ...@@ -77,4 +77,7 @@ public class UrlConstants {
public static final String CHROME_MEMEX_DEV_URL = "https://chrome-memex-dev.appspot.com/"; public static final String CHROME_MEMEX_DEV_URL = "https://chrome-memex-dev.appspot.com/";
public static final String CONTENT_SUGGESTIONS_SUFFIX = "#suggestions"; public static final String CONTENT_SUGGESTIONS_SUFFIX = "#suggestions";
public static final String EXPLORE_HOST = "explore";
public static final String EXPLORE_URL = "chrome-native://explore";
} }
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.chromium.chrome.browser.explore_sites;
import android.app.Activity;
import android.view.View;
import android.view.ViewGroup;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.BasicNativePage;
import org.chromium.chrome.browser.ChromeActivity;
import org.chromium.chrome.browser.NativePageHost;
import org.chromium.chrome.browser.UrlConstants;
/**
* Provides functionality when the user interacts with the explore sites page.
*/
public class ExploreSitesPage extends BasicNativePage {
private ViewGroup mView;
private String mTitle;
private Activity mActivity;
/**
* Create a new instance of the explore sites page.
*/
public ExploreSitesPage(ChromeActivity activity, NativePageHost host) {
super(activity, host);
}
@Override
protected void initialize(ChromeActivity activity, NativePageHost host) {
mActivity = activity;
mTitle = mActivity.getString(R.string.explore_sites_title);
mView = (ViewGroup) mActivity.getLayoutInflater().inflate(
R.layout.explore_sites_main, null);
}
@Override
public String getHost() {
return UrlConstants.EXPLORE_HOST;
}
@Override
public View getView() {
return mView;
}
@Override
public String getTitle() {
return mTitle;
}
}
...@@ -16,6 +16,7 @@ import org.chromium.chrome.browser.TabLoadStatus; ...@@ -16,6 +16,7 @@ import org.chromium.chrome.browser.TabLoadStatus;
import org.chromium.chrome.browser.UrlConstants; import org.chromium.chrome.browser.UrlConstants;
import org.chromium.chrome.browser.bookmarks.BookmarkPage; import org.chromium.chrome.browser.bookmarks.BookmarkPage;
import org.chromium.chrome.browser.download.DownloadPage; import org.chromium.chrome.browser.download.DownloadPage;
import org.chromium.chrome.browser.explore_sites.ExploreSitesPage;
import org.chromium.chrome.browser.feed.FeedNewTabPage; import org.chromium.chrome.browser.feed.FeedNewTabPage;
import org.chromium.chrome.browser.history.HistoryPage; import org.chromium.chrome.browser.history.HistoryPage;
import org.chromium.chrome.browser.tab.Tab; import org.chromium.chrome.browser.tab.Tab;
...@@ -55,6 +56,10 @@ public class NativePageFactory { ...@@ -55,6 +56,10 @@ public class NativePageFactory {
return new DownloadPage(activity, new TabShim(tab)); return new DownloadPage(activity, new TabShim(tab));
} }
protected NativePage buildExploreSitesPage(ChromeActivity activity, Tab tab) {
return new ExploreSitesPage(activity, new TabShim(tab));
}
protected NativePage buildHistoryPage(ChromeActivity activity, Tab tab) { protected NativePage buildHistoryPage(ChromeActivity activity, Tab tab) {
return new HistoryPage(activity, new TabShim(tab)); return new HistoryPage(activity, new TabShim(tab));
} }
...@@ -68,7 +73,7 @@ public class NativePageFactory { ...@@ -68,7 +73,7 @@ public class NativePageFactory {
@IntDef({NativePageType.NONE, NativePageType.CANDIDATE, NativePageType.NTP, @IntDef({NativePageType.NONE, NativePageType.CANDIDATE, NativePageType.NTP,
NativePageType.BOOKMARKS, NativePageType.RECENT_TABS, NativePageType.DOWNLOADS, NativePageType.BOOKMARKS, NativePageType.RECENT_TABS, NativePageType.DOWNLOADS,
NativePageType.HISTORY}) NativePageType.HISTORY, NativePageType.EXPLORE})
@Retention(RetentionPolicy.SOURCE) @Retention(RetentionPolicy.SOURCE)
public @interface NativePageType { public @interface NativePageType {
int NONE = 0; int NONE = 0;
...@@ -78,6 +83,7 @@ public class NativePageFactory { ...@@ -78,6 +83,7 @@ public class NativePageFactory {
int RECENT_TABS = 4; int RECENT_TABS = 4;
int DOWNLOADS = 5; int DOWNLOADS = 5;
int HISTORY = 6; int HISTORY = 6;
int EXPLORE = 7;
} }
private static @NativePageType int nativePageType( private static @NativePageType int nativePageType(
...@@ -104,6 +110,8 @@ public class NativePageFactory { ...@@ -104,6 +110,8 @@ public class NativePageFactory {
return NativePageType.HISTORY; return NativePageType.HISTORY;
} else if (UrlConstants.RECENT_TABS_HOST.equals(host) && !isIncognito) { } else if (UrlConstants.RECENT_TABS_HOST.equals(host) && !isIncognito) {
return NativePageType.RECENT_TABS; return NativePageType.RECENT_TABS;
} else if (UrlConstants.EXPLORE_HOST.equals(host)) {
return NativePageType.EXPLORE;
} else { } else {
return NativePageType.NONE; return NativePageType.NONE;
} }
...@@ -154,6 +162,9 @@ public class NativePageFactory { ...@@ -154,6 +162,9 @@ public class NativePageFactory {
case NativePageType.RECENT_TABS: case NativePageType.RECENT_TABS:
page = sNativePageBuilder.buildRecentTabsPage(activity, tab); page = sNativePageBuilder.buildRecentTabsPage(activity, tab);
break; break;
case NativePageType.EXPLORE:
page = sNativePageBuilder.buildExploreSitesPage(activity, tab);
break;
default: default:
assert false; assert false;
return null; return null;
......
...@@ -2780,7 +2780,7 @@ To obtain new licenses, connect to the internet and play your downloaded content ...@@ -2780,7 +2780,7 @@ To obtain new licenses, connect to the internet and play your downloaded content
</message> </message>
<!-- Explore sites strings --> <!-- Explore sites strings -->
<message name="IDS_NTP_EXPLORE_SITES_TITLE" desc="Title of a section showing different categories, each with a number of popular websites"> <message name="IDS_EXPLORE_SITES_TITLE" desc="Title of a section showing different categories, each with a number of popular websites">
Explore Explore
</message> </message>
<message name="IDS_NTP_EXPLORE_SITES_MORE" desc="Text on a button leading to a complete view of all categories for all popular websites"> <message name="IDS_NTP_EXPLORE_SITES_MORE" desc="Text on a button leading to a complete view of all categories for all popular websites">
......
...@@ -544,6 +544,7 @@ chrome_java_sources = [ ...@@ -544,6 +544,7 @@ chrome_java_sources = [
"java/src/org/chromium/chrome/browser/explore_sites/ExperimentalExploreSitesSection.java", "java/src/org/chromium/chrome/browser/explore_sites/ExperimentalExploreSitesSection.java",
"java/src/org/chromium/chrome/browser/explore_sites/ExploreSitesBridge.java", "java/src/org/chromium/chrome/browser/explore_sites/ExploreSitesBridge.java",
"java/src/org/chromium/chrome/browser/explore_sites/ExploreSitesCategoryTile.java", "java/src/org/chromium/chrome/browser/explore_sites/ExploreSitesCategoryTile.java",
"java/src/org/chromium/chrome/browser/explore_sites/ExploreSitesPage.java",
"java/src/org/chromium/chrome/browser/externalauth/ExternalAuthUtils.java", "java/src/org/chromium/chrome/browser/externalauth/ExternalAuthUtils.java",
"java/src/org/chromium/chrome/browser/externalauth/UserRecoverableErrorHandler.java", "java/src/org/chromium/chrome/browser/externalauth/UserRecoverableErrorHandler.java",
"java/src/org/chromium/chrome/browser/externalauth/VerifiedHandler.java", "java/src/org/chromium/chrome/browser/externalauth/VerifiedHandler.java",
......
...@@ -173,6 +173,7 @@ const char kDeprecatedChromeUIHistoryFrameURL[] = "chrome://history-frame/"; ...@@ -173,6 +173,7 @@ const char kDeprecatedChromeUIHistoryFrameURL[] = "chrome://history-frame/";
const char kChromeUIEocInternalsHost[] = "eoc-internals"; const char kChromeUIEocInternalsHost[] = "eoc-internals";
const char kChromeUIJavaCrashURL[] = "chrome://java-crash/"; const char kChromeUIJavaCrashURL[] = "chrome://java-crash/";
const char kChromeUINativeBookmarksURL[] = "chrome-native://bookmarks/"; const char kChromeUINativeBookmarksURL[] = "chrome-native://bookmarks/";
const char kChromeUINativeExploreURL[] = "chrome-native://explore";
const char kChromeUINativeHistoryURL[] = "chrome-native://history/"; const char kChromeUINativeHistoryURL[] = "chrome-native://history/";
const char kChromeUINativeNewTabURL[] = "chrome-native://newtab/"; const char kChromeUINativeNewTabURL[] = "chrome-native://newtab/";
const char kChromeUINativePhysicalWebDiagnosticsURL[] = const char kChromeUINativePhysicalWebDiagnosticsURL[] =
......
...@@ -173,6 +173,7 @@ extern const char kDeprecatedChromeUIHistoryFrameURL[]; ...@@ -173,6 +173,7 @@ extern const char kDeprecatedChromeUIHistoryFrameURL[];
extern const char kChromeUIEocInternalsHost[]; extern const char kChromeUIEocInternalsHost[];
extern const char kChromeUIJavaCrashURL[]; extern const char kChromeUIJavaCrashURL[];
extern const char kChromeUINativeBookmarksURL[]; extern const char kChromeUINativeBookmarksURL[];
extern const char kChromeUINativeExploreURL[];
extern const char kChromeUINativeHistoryURL[]; extern const char kChromeUINativeHistoryURL[];
extern const char kChromeUINativeNewTabURL[]; extern const char kChromeUINativeNewTabURL[];
extern const char kChromeUINativePhysicalWebDiagnosticsURL[]; extern const char kChromeUINativePhysicalWebDiagnosticsURL[];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment