Skip to content

Commit e644d77

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

File tree

9 files changed

+397
-73
lines changed

9 files changed

+397
-73
lines changed

browser/app/profile/firefox.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1194,8 +1194,9 @@ 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);
1198+
pref("browser.smartwindow.tos", false);
1199+
pref("browser.smartwindow.isfirstrun", false);
11991200

12001201
// Scripts & Windows prefs
12011202
pref("dom.disable_open_during_load", true);

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

Lines changed: 59 additions & 55 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,51 @@ 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+
this.toggleSmartWindow();
105+
break;
106+
}
107+
const { UIState } = ChromeUtils.importESModule(
108+
"resource://services-sync/UIState.sys.mjs"
109+
);
110+
const currentState = UIState.get();
111+
112+
if (currentState.status !== UIState.STATUS_SIGNED_IN) {
113+
console.warn(
114+
"[Smart Window] User not authenticated, sign in with FxA"
108115
);
109116

110-
if (requireSignIn) {
111-
const { UIState } = ChromeUtils.importESModule(
112-
"resource://services-sync/UIState.sys.mjs"
117+
try {
118+
const { SpecialMessageActions } = ChromeUtils.importESModule(
119+
"resource://messaging-system/lib/SpecialMessageActions.sys.mjs"
120+
);
121+
// FXA_SMART_WINDOW_SIGNIN_FLOW handles toggling smart window on success
122+
// TODO: we should await handleAction and set tos and isfirstrun pref here
123+
// instead of SpecialMessageActions
124+
SpecialMessageActions.handleAction(
125+
{
126+
type: "FXA_SMART_WINDOW_SIGNIN_FLOW",
127+
data: {
128+
entrypoint: "aimode",
129+
},
130+
},
131+
gBrowser.selectedBrowser
132+
);
133+
break;
134+
} catch (error) {
135+
console.error(
136+
"[Smart Window] Error during FxA sign-in:",
137+
error
113138
);
114-
const currentState = UIState.get();
115-
116-
if (currentState.status !== UIState.STATUS_SIGNED_IN) {
117-
console.warn(
118-
"[Smart Window] User not authenticated, sign in with FxA"
119-
);
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-
},
132-
},
133-
gBrowser.selectedBrowser
134-
);
135-
break;
136-
} catch (error) {
137-
console.error(
138-
"[Smart Window] Error during FxA sign-in:",
139-
error
140-
);
141-
}
142-
}
143139
}
144-
145-
this.toggleSmartWindow();
146140
} else {
147-
this.showOnboarding();
141+
this.toggleSmartWindow();
148142
}
149-
150143
break;
151144
}
152145
case "smart-window-dev-onboarding":
@@ -187,13 +180,18 @@ var SmartWindow = {
187180
}
188181
},
189182

190-
showOnboarding() {
191-
window.openTrustedLinkIn(
192-
Services.urlFormatter.formatURL(
193-
"chrome://browser/content/smartwindow/welcome.html"
194-
),
195-
"tab"
196-
);
183+
// Shows Post login first run onboarding
184+
async showOnboarding() {
185+
return new Promise(resolve => {
186+
window.openTrustedLinkIn(
187+
Services.urlFormatter.formatURL(
188+
"chrome://browser/content/smartwindow/firstrun.html"
189+
),
190+
"tab"
191+
);
192+
// Resolve after a brief delay to ensure the window is opened
193+
setTimeout(() => resolve(), 2000);
194+
});
197195
},
198196

199197
toggleSmartWindow() {
@@ -223,8 +221,14 @@ var SmartWindow = {
223221
* Can be omitted if not switching from classic to smart
224222
* window mode.
225223
*/
226-
reconcileUIToSmartWindowState(oldNewTabURL = "") {
224+
async reconcileUIToSmartWindowState(oldNewTabURL = "") {
227225
if (this.isSmartWindowActive()) {
226+
// Show the first run onboarding first time user switches to smart window mode
227+
if (Services.prefs.getBoolPref("browser.smartwindow.isfirstrun", false)) {
228+
Services.prefs.setBoolPref("browser.smartwindow.isfirstrun", false);
229+
await this.showOnboarding();
230+
}
231+
228232
// Check if we're on a smart window page
229233
const isSmartWindowPage = this._isSmartPage(gBrowser.selectedBrowser);
230234

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>

0 commit comments

Comments
 (0)