Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion browser/app/profile/firefox.js
Original file line number Diff line number Diff line change
Expand Up @@ -1194,8 +1194,9 @@ pref("browser.smartwindow.insights", "{}");
pref("browser.smartwindow.key", "sk-xblVm-OUfsPY0C1dER1LLQ");
pref("browser.smartwindow.model", "qwen3-235b-a22b-instruct-2507-maas");
pref("browser.smartwindow.chatHistory.loglevel", "Warn");
pref("browser.smartwindow.skipOnboarding", true);
pref("browser.smartwindow.requireSignIn", false);
pref("browser.smartwindow.tos", false);
pref("browser.smartwindow.isfirstrun", false);

// Scripts & Windows prefs
pref("dom.disable_open_during_load", true);
Expand Down
114 changes: 59 additions & 55 deletions browser/base/content/browser-smart-window.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ var SmartWindow = {
PAGE_URL: Services.io.newURI(
"chrome://browser/content/smartwindow/smartwindow.html"
),
FIRST_RUN_URL: Services.io.newURI(
"chrome://browser/content/smartwindow/firstrun.html"
),

_initialized: false,
_viewInitialized: false,
Expand Down Expand Up @@ -67,7 +70,7 @@ var SmartWindow = {
},

_isSmartPage(browser) {
return !!browser?.currentURI?.equalsExceptRef(this.PAGE_URL);
return !!browser?.currentURI?.equalsExceptRef(this.PAGE_URL) || !!browser?.currentURI?.equalsExceptRef(this.FIRST_RUN_URL);
},

_ensureViewInitialized() {
Expand All @@ -92,61 +95,51 @@ var SmartWindow = {
this.toggleSmartWindow();
break;
case "smart-window-switch-smart": {
const skipOnboarding = Services.prefs.getBoolPref(
"browser.smartwindow.skipOnboarding",
true
);
const completedOnboarding = Services.prefs.getBoolPref(
"messaging-system-action.smart-window-tos",
const requireSignIn = Services.prefs.getBoolPref(
"browser.smartwindow.requireSignIn",
false
);

if (skipOnboarding || completedOnboarding) {
const requireSignIn = Services.prefs.getBoolPref(
"browser.smartwindow.requireSignIn",
false
if (!requireSignIn) {
this.toggleSmartWindow();
break;
}
const { UIState } = ChromeUtils.importESModule(
"resource://services-sync/UIState.sys.mjs"
);
const currentState = UIState.get();

if (currentState.status !== UIState.STATUS_SIGNED_IN) {
console.warn(
"[Smart Window] User not authenticated, sign in with FxA"
);

if (requireSignIn) {
const { UIState } = ChromeUtils.importESModule(
"resource://services-sync/UIState.sys.mjs"
try {
const { SpecialMessageActions } = ChromeUtils.importESModule(
"resource://messaging-system/lib/SpecialMessageActions.sys.mjs"
);
// FXA_SMART_WINDOW_SIGNIN_FLOW handles toggling smart window on success
// TODO: we should await handleAction and set tos and isfirstrun pref here
// instead of SpecialMessageActions
SpecialMessageActions.handleAction(
{
type: "FXA_SMART_WINDOW_SIGNIN_FLOW",
data: {
entrypoint: "aimode",
},
},
gBrowser.selectedBrowser
);
break;
} catch (error) {
console.error(
"[Smart Window] Error during FxA sign-in:",
error
);
const currentState = UIState.get();

if (currentState.status !== UIState.STATUS_SIGNED_IN) {
console.warn(
"[Smart Window] User not authenticated, sign in with FxA"
);

try {
const { SpecialMessageActions } = ChromeUtils.importESModule(
"resource://messaging-system/lib/SpecialMessageActions.sys.mjs"
);
// FXA_SMART_WINDOW_SIGNIN_FLOW handles toggling smart window on success
SpecialMessageActions.handleAction(
{
type: "FXA_SMART_WINDOW_SIGNIN_FLOW",
data: {
entrypoint: "aimode",
},
},
gBrowser.selectedBrowser
);
break;
} catch (error) {
console.error(
"[Smart Window] Error during FxA sign-in:",
error
);
}
}
}

this.toggleSmartWindow();
} else {
this.showOnboarding();
this.toggleSmartWindow();
}

break;
}
case "smart-window-dev-onboarding":
Expand Down Expand Up @@ -187,13 +180,18 @@ var SmartWindow = {
}
},

showOnboarding() {
window.openTrustedLinkIn(
Services.urlFormatter.formatURL(
"chrome://browser/content/smartwindow/welcome.html"
),
"tab"
);
// Shows Post login first run onboarding
async showOnboarding() {
return new Promise(resolve => {
window.openTrustedLinkIn(
Services.urlFormatter.formatURL(
"chrome://browser/content/smartwindow/firstrun.html"
),
"tab"
);
// Resolve after a brief delay to ensure the window is opened
setTimeout(() => resolve(), 2000);
});
},

toggleSmartWindow() {
Expand Down Expand Up @@ -223,8 +221,14 @@ var SmartWindow = {
* Can be omitted if not switching from classic to smart
* window mode.
*/
reconcileUIToSmartWindowState(oldNewTabURL = "") {
async reconcileUIToSmartWindowState(oldNewTabURL = "") {
if (this.isSmartWindowActive()) {
// Show the first run onboarding first time user switches to smart window mode
if (Services.prefs.getBoolPref("browser.smartwindow.isfirstrun", false)) {
Services.prefs.setBoolPref("browser.smartwindow.isfirstrun", false);
await this.showOnboarding();
}

// Check if we're on a smart window page
const isSmartWindowPage = this._isSmartPage(gBrowser.selectedBrowser);

Expand Down
40 changes: 40 additions & 0 deletions browser/components/smartwindow/content/firstrun.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<!doctype html>

<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->

<html>
<head>
<meta
http-equiv="Content-Security-Policy"
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'"
/>
<meta name="referrer" content="no-referrer" />
<link
rel="stylesheet"
type="text/css"
href="chrome://global/skin/in-content/common.css"
/>
<link
rel="stylesheet"
href="chrome://browser/content/aboutwelcome/aboutwelcome.css"
/>
<link
rel="stylesheet"
href="chrome://browser/content/smartwindow/smartwindow.css"
/>
<link rel="localization" href="browser/genai.ftl" />
<link rel="localization" href="preview/genai.ftl" />
<link rel="localization" href="branding/brand.ftl" />
<link rel="localization" href="browser/newtab/onboarding.ftl" />
<title>Welcome Screen</title>
</head>

<body>
<div id="welcome-container"></div>
<script src="chrome://global/content/vendor/react.js"></script>
<script src="chrome://global/content/vendor/react-dom.js"></script>
<script src="chrome://browser/content/smartwindow/firstrun.js"></script>
</body>
</html>
Loading