Bug 1448918 - Create about:welcome page in preparation for firstrun migration. r=dmose

MozReview-Commit-ID: L34uRsOeziS

--HG--
extra : rebase_source : 9e783e9ba1a8473c8867aa9c2a87337005acbab2
This commit is contained in:
Erica Wright 2018-04-23 15:47:57 -04:00
parent 77bb63790b
commit dc93192a58
12 changed files with 32 additions and 21 deletions

View File

@ -315,7 +315,8 @@ var gInitialPages = [
"about:home",
"about:privatebrowsing",
"about:welcomeback",
"about:sessionrestore"
"about:sessionrestore",
"about:welcome"
];
function isInitialPage(url) {
@ -1252,7 +1253,7 @@ var gBrowserInit = {
// Hack to ensure that the about:home favicon is loaded
// instantaneously, to avoid flickering and improve perceived performance.
this._callWithURIToLoad(uriToLoad => {
if (uriToLoad == "about:home") {
if (uriToLoad == "about:home" || uriToLoad == "about:newtab" || uriToLoad == "about:welcome") {
gBrowser.setIcon(gBrowser.selectedTab, "chrome://branding/content/icon32.png");
} else if (uriToLoad == "about:privatebrowsing") {
gBrowser.setIcon(gBrowser.selectedTab, "chrome://browser/skin/privatebrowsing/favicon.svg");

View File

@ -2449,9 +2449,9 @@ window._gBrowser = {
throw e;
}
// Hack to ensure that the about:newtab favicon is loaded
// Hack to ensure that the about:newtab, and about:welcome favicon is loaded
// instantaneously, to avoid flickering and improve perceived performance.
if (aURI == "about:newtab") {
if (aURI == "about:newtab" || aURI == "about:home" || aURI == "about:welcome") {
this.setIcon(t, "chrome://branding/content/icon32.png");
} else if (aURI == "about:privatebrowsing") {
this.setIcon(t, "chrome://browser/skin/privatebrowsing/favicon.svg");
@ -4501,13 +4501,14 @@ class TabProgressListener {
// Ignore initial about:blank to prevent flickering.
if (!this.mBrowser.mIconURL && !ignoreBlank) {
// Don't switch to the default icon on about:home or about:newtab,
// since these pages get their favicon set in browser code to
// improve perceived performance.
// Don't switch to the default icon on about:home, about:newtab,
// about:privatebrowsing, or about:welcome since these pages get
// their favicon set in browser code to improve perceived performance.
let isNewTab = originalLocation &&
(originalLocation.spec == "about:newtab" ||
(originalLocation.spec == "about:newtab" ||
originalLocation.spec == "about:privatebrowsing" ||
originalLocation.spec == "about:home");
originalLocation.spec == "about:home" ||
originalLocation.spec == "about:welcome");
if (!isNewTab) {
gBrowser.useDefaultIcon(this.mTab);
}

View File

@ -44,6 +44,7 @@ var gBidiUI = false;
function isBlankPageURL(aURL) {
return aURL == "about:blank" ||
aURL == "about:home" ||
aURL == "about:welcome" ||
aURL == BROWSER_NEW_TAB_URL;
}

View File

@ -86,6 +86,10 @@ static const RedirEntry kRedirMap[] = {
// Actual activity stream URL for home and newtab are set in channel creation
{ "home", "about:blank", ACTIVITY_STREAM_FLAGS | nsIAboutModule::MAKE_LINKABLE }, // Bug 1438367 to try removing MAKE_LINKABLE again
{ "newtab", "about:blank", ACTIVITY_STREAM_FLAGS },
{ "welcome", "about:blank",
nsIAboutModule::URI_MUST_LOAD_IN_CHILD |
nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT |
nsIAboutModule::ALLOW_SCRIPT },
{ "library", "chrome://browser/content/aboutLibrary.xhtml",
nsIAboutModule::URI_MUST_LOAD_IN_CHILD |
nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT },
@ -148,9 +152,10 @@ AboutRedirector::NewChannel(nsIURI* aURI,
nsAutoCString url;
// Let the aboutNewTabService decide where to redirect for about:home and
// enabled about:newtab. Disabled about:newtab page uses fallback.
// enabled about:newtab. Disabledx about:newtab page uses fallback.
if (path.EqualsLiteral("home") ||
(sNewTabPageEnabled && path.EqualsLiteral("newtab"))) {
(sNewTabPageEnabled && path.EqualsLiteral("newtab")) ||
path.EqualsLiteral("welcome")) {
nsCOMPtr<nsIAboutNewTabService> aboutNewTabService =
do_GetService("@mozilla.org/browser/aboutnewtab-service;1", &rv);
NS_ENSURE_SUCCESS(rv, rv);

View File

@ -101,6 +101,7 @@ static const mozilla::Module::ContractIDEntry kBrowserContracts[] = {
{ NS_ABOUT_MODULE_CONTRACTID_PREFIX "downloads", &kNS_BROWSER_ABOUT_REDIRECTOR_CID },
{ NS_ABOUT_MODULE_CONTRACTID_PREFIX "reader", &kNS_BROWSER_ABOUT_REDIRECTOR_CID },
{ NS_ABOUT_MODULE_CONTRACTID_PREFIX "restartrequired", &kNS_BROWSER_ABOUT_REDIRECTOR_CID },
{ NS_ABOUT_MODULE_CONTRACTID_PREFIX "welcome", &kNS_BROWSER_ABOUT_REDIRECTOR_CID },
#if defined(XP_WIN)
{ NS_IEHISTORYENUMERATOR_CONTRACTID, &kNS_WINIEHISTORYENUMERATOR_CID },
#elif defined(XP_MACOSX)

View File

@ -47,7 +47,7 @@ function isValidCategory(category) {
// Validate the page value is within the list
function isValidPage(page) {
return ["about:newtab", "about:home"].includes(page);
return ["about:newtab", "about:home", "about:welcome"].includes(page);
}
// Validate the tour_type value is within the list

View File

@ -16,7 +16,7 @@ And make sure the value of `browser.onboarding.tourset-verion` and `browser.onbo
Besides above settings, notification will wait 5 minutes before showing the first notification on a new profile or the updated user profile (to not put too much information to the user at once).
To manually remove the mute duration, set pref `browser.onboarding.notification.mute-duration-on-first-session-ms` to `0` and notification will be shown at the next time you open `about:home` or `about:newtab`.
To manually remove the mute duration, set pref `browser.onboarding.notification.mute-duration-on-first-session-ms` to `0` and notification will be shown at the next time you open `about:home`, `about:newtab`, or `about:welcome`.
## How to show the snippets
@ -28,7 +28,7 @@ Snippets (the remote notification that handled by activity stream) will only be
During booting from `bootstrap.js`, `OnboardingTourType.jsm` will check the onboarding tour type (`new` and `update` are supported types) and set required initial states into preferences.
Everytime `about:home` or `about:newtab` page is opened, `onboarding.js` is injected into that page via [frame scripts](https://developer.mozilla.org/en-US/Firefox/Multiprocess_Firefox/Message_Manager/Communicating_with_frame_scripts).
Everytime `about:home`, `about:newtab`, or `about:welcome` page is opened, `onboarding.js` is injected into that page via [frame scripts](https://developer.mozilla.org/en-US/Firefox/Multiprocess_Firefox/Message_Manager/Communicating_with_frame_scripts).
Then in `onboarding.js`, all tours are defined inside of `onboardingTourset` dictionary. `getTourIDList` function will load tours from proper preferences. (Check `How to change the order of tours` section for more detail).

View File

@ -11,6 +11,7 @@ ChromeUtils.defineModuleGetter(this, "Onboarding", "resource://onboarding/Onboar
const ABOUT_HOME_URL = "about:home";
const ABOUT_NEWTAB_URL = "about:newtab";
const ABOUT_WELCOME_URL = "about:welcome";
// Load onboarding module only when we enable it.
if (Services.prefs.getBoolPref("browser.onboarding.enabled", false)) {
@ -21,7 +22,7 @@ if (Services.prefs.getBoolPref("browser.onboarding.enabled", false)) {
let window = evt.target.defaultView;
let location = window.location.href;
if (location == ABOUT_NEWTAB_URL || location == ABOUT_HOME_URL) {
if (location == ABOUT_NEWTAB_URL || location == ABOUT_HOME_URL || location == ABOUT_WELCOME_URL) {
// We just want to run tests as quickly as possible
// so in the automation test, we don't do `requestIdleCallback`.
if (Cu.isInAutomation) {

View File

@ -20,7 +20,7 @@ For reference, Onyx is a Mozilla owned service to serve tiles for the current ne
"client_id": "374dc4d8-0cb2-4ac5-a3cf-c5a9bc3c602e",
"locale": "en-US",
"type": ["onboarding_session" | "overlay_session" | "notification_session"],
"page": ["about:newtab" | "about:home"],
"page": ["about:newtab" | "about:home" | "about:welcome"],
"parent_session_id": "{45cddbeb-2bec-4f3a-bada-fb87d4b79a6c}",
"root_session_id": "{45cddbeb-2bec-4f3a-bada-fb87d4b79a6c}",
"session_begin": 1505440017018,
@ -43,7 +43,7 @@ For reference, Onyx is a Mozilla owned service to serve tiles for the current ne
| `client_id` | [Required] An identifier generated by [ClientID](https://github.com/mozilla/gecko-dev/blob/master/toolkit/modules/ClientID.jsm) module to provide an identifier for this device. This data is automatically appended by `ping-centre` module | :one:
| `ip` | [Auto populated by Onyx] The IP address of the client. Onyx does use (with the permission) the IP address to infer user's geo-information so that it could prepare the corresponding tiles for the country she lives in. However, Ping-centre will NOT store IP address in the database, where only authorized Mozilla employees can access the telemetry data, and all the raw logs are being strictly managed by the Ops team and will expire according to the Mozilla's data retention policy.| :two:
| `locale` | The browser chrome's language (e.g. en-US). | :two:
| `page` | [Required] One of ["about:newtab", "about:home"]| :one:
| `page` | [Required] One of ["about:newtab", "about:home", "about:welcome"]| :one:
| `parent_session_id` | [Required] The unique identifier generated by `gUUIDGenerator` service to identify this event belongs to which parent session. Events happen upon overlay will have the `overlay session uuid` as its `parent_session_id`. Events happen upon notification will have the `notification session uuid` as its `parent_session_id`. | :one:
| `root_session_id` | [Required] The unique identifier generated by `gUUIDGenerator` service to identify this event belongs to which root session. Every event will have the same `onboarding session uuid` as its `root_session_id` when interact in the same tab. | :one:
| `session_begin` | [Required] Timestamp in (integer) milliseconds when onboarding/overlay/notification becoming visible. | :one:
@ -66,7 +66,7 @@ For reference, Onyx is a Mozilla owned service to serve tiles for the current ne
"logo_state": ["logo" | "watermark"],
"notification_impression": [1-8],
"notification_state": ["show" | "hide" | "finished"],
"page": ["about:newtab" | "about:home"],
"page": ["about:newtab" | "about:home" | "about:welcome"],
"parent_session_id": "{45cddbeb-2bec-4f3a-bada-fb87d4b79a6c}",
"root_session_id": "{45cddbeb-2bec-4f3a-bada-fb87d4b79a6c}",
"current_tour_id": ["onboarding-tour-private-browsing" | "onboarding-tour-addons"|...], // tour ids defined in 'onboardingTourset'

View File

@ -3,7 +3,7 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
[features/onboarding@mozilla.org] chrome.jar:
# resource://onboarding/ is referenced in about:home and about:newtab,
# resource://onboarding/ is referenced in about:home about:newtab and about:welcome,
# so make it content-accessible.
% resource onboarding %content/ contentaccessible=yes
content/ (content/*)

View File

@ -26,7 +26,7 @@ var AboutNewTab = {
if (this.isOverridden) {
return;
}
this.pageListener = pageListener || new RemotePages(["about:home", "about:newtab"]);
this.pageListener = pageListener || new RemotePages(["about:home", "about:newtab", "about:welcome"]);
this.pageListener.addMessageListener("NewTab:Customize", this.customize);
this.pageListener.addMessageListener("NewTab:MaybeShowMigrateMessage",
this.maybeShowMigrateMessage);

View File

@ -2481,7 +2481,8 @@ pref("security.csp.experimentalEnabled", false);
pref("security.csp.enableStrictDynamic", true);
#if defined(DEBUG) && !defined(ANDROID)
pref("csp.content_privileged_about_uris_without_csp", "blank,home,newtab,printpreview,srcdoc,studies");
// about:welcome has been added until Bug 1448359 is fixed at which time home, newtab, and welcome will all be removed.
pref("csp.content_privileged_about_uris_without_csp", "blank,home,newtab,printpreview,srcdoc,studies,welcome");
#endif
#ifdef NIGHTLY_BUILD