Skip to content

Commit e67c56e

Browse files
author
Punam Dahiya
committed
Post login firstrun onboarding
1 parent 1c38fa2 commit e67c56e

File tree

8 files changed

+306
-61
lines changed

8 files changed

+306
-61
lines changed

browser/app/profile/firefox.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1194,7 +1194,6 @@ pref("browser.smartwindow.insights", "{}");
11941194
pref("browser.smartwindow.key", "sk-xblVm-OUfsPY0C1dER1LLQ");
11951195
pref("browser.smartwindow.model", "qwen3-235b-a22b-instruct-2507-maas");
11961196
pref("browser.smartwindow.chatHistory.loglevel", "Warn");
1197-
pref("browser.smartwindow.skipOnboarding", true);
11981197
pref("browser.smartwindow.requireSignIn", false);
11991198

12001199
// Scripts & Windows prefs

browser/base/content/browser-smart-window.js

Lines changed: 34 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ var SmartWindow = {
88
PAGE_URL: Services.io.newURI(
99
"chrome://browser/content/smartwindow/smartwindow.html"
1010
),
11+
FIRST_RUN_URL: Services.io.newURI(
12+
"chrome://browser/content/smartwindow/firstrun.html"
13+
),
1114

1215
_initialized: false,
1316
_viewInitialized: false,
@@ -67,7 +70,7 @@ var SmartWindow = {
6770
},
6871

6972
_isSmartPage(browser) {
70-
return !!browser?.currentURI?.equalsExceptRef(this.PAGE_URL);
73+
return !!browser?.currentURI?.equalsExceptRef(this.PAGE_URL) || !!browser?.currentURI?.equalsExceptRef(this.FIRST_RUN_URL);
7174
},
7275

7376
_ensureViewInitialized() {
@@ -92,61 +95,47 @@ var SmartWindow = {
9295
this.toggleSmartWindow();
9396
break;
9497
case "smart-window-switch-smart": {
95-
const skipOnboarding = Services.prefs.getBoolPref(
96-
"browser.smartwindow.skipOnboarding",
97-
true
98-
);
99-
const completedOnboarding = Services.prefs.getBoolPref(
100-
"messaging-system-action.smart-window-tos",
98+
const requireSignIn = Services.prefs.getBoolPref(
99+
"browser.smartwindow.requireSignIn",
101100
false
102101
);
103102

104-
if (skipOnboarding || completedOnboarding) {
105-
const requireSignIn = Services.prefs.getBoolPref(
106-
"browser.smartwindow.requireSignIn",
107-
false
103+
if (requireSignIn) {
104+
const { UIState } = ChromeUtils.importESModule(
105+
"resource://services-sync/UIState.sys.mjs"
108106
);
107+
const currentState = UIState.get();
109108

110-
if (requireSignIn) {
111-
const { UIState } = ChromeUtils.importESModule(
112-
"resource://services-sync/UIState.sys.mjs"
109+
if (currentState.status !== UIState.STATUS_SIGNED_IN) {
110+
console.warn(
111+
"[Smart Window] User not authenticated, sign in with FxA"
113112
);
114-
const currentState = UIState.get();
115113

116-
if (currentState.status !== UIState.STATUS_SIGNED_IN) {
117-
console.warn(
118-
"[Smart Window] User not authenticated, sign in with FxA"
114+
try {
115+
const { SpecialMessageActions } = ChromeUtils.importESModule(
116+
"resource://messaging-system/lib/SpecialMessageActions.sys.mjs"
119117
);
120-
121-
try {
122-
const { SpecialMessageActions } = ChromeUtils.importESModule(
123-
"resource://messaging-system/lib/SpecialMessageActions.sys.mjs"
124-
);
125-
// FXA_SMART_WINDOW_SIGNIN_FLOW handles toggling smart window on success
126-
SpecialMessageActions.handleAction(
127-
{
128-
type: "FXA_SMART_WINDOW_SIGNIN_FLOW",
129-
data: {
130-
entrypoint: "aimode",
131-
},
118+
// FXA_SMART_WINDOW_SIGNIN_FLOW handles toggling smart window on success
119+
SpecialMessageActions.handleAction(
120+
{
121+
type: "FXA_SMART_WINDOW_SIGNIN_FLOW",
122+
data: {
123+
entrypoint: "aimode",
132124
},
133-
gBrowser.selectedBrowser
134-
);
135-
break;
136-
} catch (error) {
137-
console.error(
138-
"[Smart Window] Error during FxA sign-in:",
139-
error
140-
);
141-
}
125+
},
126+
gBrowser.selectedBrowser
127+
);
128+
break;
129+
} catch (error) {
130+
console.error(
131+
"[Smart Window] Error during FxA sign-in:",
132+
error
133+
);
142134
}
143135
}
144-
145-
this.toggleSmartWindow();
146136
} else {
147-
this.showOnboarding();
137+
this.toggleSmartWindow();
148138
}
149-
150139
break;
151140
}
152141
case "smart-window-dev-onboarding":
@@ -187,10 +176,11 @@ var SmartWindow = {
187176
}
188177
},
189178

179+
// Shows Post login first run onboarding
190180
showOnboarding() {
191181
window.openTrustedLinkIn(
192182
Services.urlFormatter.formatURL(
193-
"chrome://browser/content/smartwindow/welcome.html"
183+
"chrome://browser/content/smartwindow/firstrun.html"
194184
),
195185
"tab"
196186
);
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<!doctype html>
2+
3+
<!-- This Source Code Form is subject to the terms of the Mozilla Public
4+
- License, v. 2.0. If a copy of the MPL was not distributed with this
5+
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
6+
7+
<html>
8+
<head>
9+
<meta
10+
http-equiv="Content-Security-Policy"
11+
content="default-src resource: chrome:; img-src moz-icon: https://www.mozilla.org https://firefox-settings-attachments.cdn.mozilla.net https://addons.mozilla.org blob: chrome:; style-src resource: chrome: 'unsafe-inline'; object-src 'none'"
12+
/>
13+
<meta name="referrer" content="no-referrer" />
14+
<link
15+
rel="stylesheet"
16+
type="text/css"
17+
href="chrome://global/skin/in-content/common.css"
18+
/>
19+
<link
20+
rel="stylesheet"
21+
href="chrome://browser/content/aboutwelcome/aboutwelcome.css"
22+
/>
23+
<link
24+
rel="stylesheet"
25+
href="chrome://browser/content/smartwindow/smartwindow.css"
26+
/>
27+
<link rel="localization" href="browser/genai.ftl" />
28+
<link rel="localization" href="preview/genai.ftl" />
29+
<link rel="localization" href="branding/brand.ftl" />
30+
<link rel="localization" href="browser/newtab/onboarding.ftl" />
31+
<title>Welcome Screen</title>
32+
</head>
33+
34+
<body>
35+
<div id="welcome-container"></div>
36+
<script src="chrome://global/content/vendor/react.js"></script>
37+
<script src="chrome://global/content/vendor/react-dom.js"></script>
38+
<script src="chrome://browser/content/smartwindow/firstrun.js"></script>
39+
</body>
40+
</html>
Lines changed: 224 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,224 @@
1+
/* This Source Code Form is subject to the terms of the Mozilla Public
2+
* License, v. 2.0. If a copy of the MPL was not distributed with this
3+
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4+
5+
const lazy = {};
6+
const { topChromeWindow } = window.browsingContext;
7+
const { XPCOMUtils } = ChromeUtils.importESModule(
8+
"resource://gre/modules/XPCOMUtils.sys.mjs"
9+
);
10+
11+
ChromeUtils.defineESModuleGetters(lazy, {
12+
AboutWelcomeParent: "resource:///actors/AboutWelcomeParent.sys.mjs",
13+
});
14+
15+
XPCOMUtils.defineLazyPreferenceGetter(
16+
lazy,
17+
"onboardingConfig",
18+
"browser.smartwindow.onboarding.config",
19+
JSON.stringify({
20+
id: "smart-window-welcome",
21+
template: "spotlight",
22+
modal: "tab",
23+
transitions: true,
24+
backdrop: "linear-gradient(0deg, #D9C7F8 0%, #F6EEFC 102.21%)",
25+
screens: [
26+
{
27+
id: "welcome_screen",
28+
auto_advance: "additional_button",
29+
content: {
30+
fullscreen: true,
31+
hide_secondary_section: "responsive",
32+
narrow: true,
33+
position: "split",
34+
title: {
35+
fontWeight: 600,
36+
fontSize: "55px",
37+
width: "800px",
38+
textAlign: "center",
39+
raw: "Welcome to Smart Window",
40+
},
41+
title_style: "fancy shine",
42+
text_color: "dark",
43+
primary_button: {
44+
label: "Next",
45+
action: {
46+
navigate: true
47+
},
48+
},
49+
},
50+
},
51+
{
52+
id: "CHOOSE_MODEL",
53+
content: {
54+
position: "center",
55+
screen_style: {
56+
width: "650px",
57+
height: "500px",
58+
},
59+
title: {
60+
raw: "Pick a model to start",
61+
},
62+
subtitle: {
63+
raw: "You can switch anytime - and trying a few helps you find the best fit.",
64+
},
65+
tiles: {
66+
type: "single-select",
67+
autoTrigger: false,
68+
action: {
69+
picker: "<event>",
70+
},
71+
data: [
72+
{
73+
id: "model_1",
74+
label: {
75+
raw: "Fast & Clear",
76+
fontSize: 17,
77+
fontWeight: 600,
78+
},
79+
body: {
80+
raw: "Quick answer to everyday questions",
81+
color: "var(--text-color-deemphasized)",
82+
},
83+
},
84+
{
85+
id: "model_2",
86+
label: {
87+
raw: "Fast & Clear",
88+
fontSize: 17,
89+
fontWeight: 600,
90+
},
91+
body: {
92+
raw: "Quick answer to everyday questions",
93+
color: "var(--text-color-deemphasized)",
94+
},
95+
},
96+
{
97+
id: "model_3",
98+
label: {
99+
raw: "Fast & Clear",
100+
fontSize: 17,
101+
fontWeight: 600,
102+
},
103+
body: {
104+
raw: "Quick answer to everyday questions",
105+
color: "var(--text-color-deemphasized)",
106+
},
107+
}
108+
]
109+
},
110+
primary_button: {
111+
label: {
112+
raw: "Next"
113+
},
114+
action: {
115+
navigate: true
116+
}
117+
},
118+
}
119+
},
120+
{
121+
id: "APPLY_INSIGHTS",
122+
content: {
123+
position: "center",
124+
screen_style: {
125+
width: "650px",
126+
height: "500px",
127+
},
128+
title: {
129+
raw: "Smarter browsing starts now",
130+
},
131+
subtitle: {
132+
raw: "Get personalized answers fast. Compare info across tabs. Find what you need in your history in your words, not keywords.",
133+
},
134+
above_button_content: [
135+
{
136+
type: "image",
137+
url: "chrome://browser/content/smartwindow/insights.png",
138+
width: "500px",
139+
height: "200px"
140+
}
141+
],
142+
primary_button: {
143+
label: {
144+
raw: "Back"
145+
},
146+
action: {
147+
navigate: true,
148+
goBack: true
149+
}
150+
},
151+
additional_button: {
152+
label: "Let's Go",
153+
style: "primary",
154+
flow: "row",
155+
action: {
156+
navigate: true
157+
}
158+
},
159+
}
160+
}
161+
],
162+
})
163+
);
164+
165+
function addStylesheet(href) {
166+
const link = document.head.appendChild(document.createElement("link"));
167+
link.rel = "stylesheet";
168+
link.href = href;
169+
}
170+
171+
function renderMultistage(ready) {
172+
const AWParent = new lazy.AboutWelcomeParent();
173+
const receive = name => data =>
174+
AWParent.onContentMessage(
175+
`AWPage:${name}`,
176+
data,
177+
topChromeWindow.gBrowser.selectedBrowser
178+
);
179+
180+
// Expose top level functions expected by the bundle.
181+
window.AWGetFeatureConfig = () => JSON.parse(lazy.onboardingConfig);
182+
window.AWGetSelectedTheme = receive("GET_SELECTED_THEME");
183+
window.AWGetInstalledAddons = receive("GET_INSTALLED_ADDONS");
184+
window.AWSelectTheme = data => receive("SELECT_THEME")(data?.toUpperCase());
185+
window.AWSendEventTelemetry = receive("TELEMETRY_EVENT");
186+
187+
window.AWSendToDeviceEmailsSupported = receive(
188+
"SEND_TO_DEVICE_EMAILS_SUPPORTED"
189+
);
190+
window.AWAddScreenImpression = receive("ADD_SCREEN_IMPRESSION");
191+
window.AWSendToParent = (name, data) => receive(name)(data);
192+
window.AWFinish = () => {
193+
window.close();
194+
};
195+
window.AWWaitForMigrationClose = receive("WAIT_FOR_MIGRATION_CLOSE");
196+
window.AWEvaluateScreenTargeting = receive("EVALUATE_SCREEN_TARGETING");
197+
window.AWEvaluateAttributeTargeting = receive("EVALUATE_ATTRIBUTE_TARGETING");
198+
199+
// Update styling to be compatible with about:welcome.
200+
addStylesheet("chrome://browser/content/aboutwelcome/aboutwelcome.css");
201+
202+
document.body.classList.add("onboardingContainer");
203+
document.body.id = "multi-stage-message-root";
204+
// This value is reported as the "page" in telemetry
205+
document.body.dataset.page = "smart-window-welcome";
206+
const bundleScript = document.head.appendChild(
207+
document.createElement("script")
208+
);
209+
bundleScript.src =
210+
"chrome://browser/content/aboutwelcome/aboutwelcome.bundle.js";
211+
212+
ready();
213+
}
214+
215+
// Initialize when DOM is ready
216+
if (document.readyState === "loading") {
217+
document.addEventListener(
218+
"DOMContentLoaded",
219+
() => renderMultistage(() => { }),
220+
{ once: true }
221+
);
222+
} else {
223+
renderMultistage(() => { });
224+
}
175 KB
Loading

0 commit comments

Comments
 (0)