Skip to content

Commit

Permalink
Backed out changeset e4a8608d96d5 (bug 1931982) for causing failures …
Browse files Browse the repository at this point in the history
…at test_first_startup.py. CLOSED TREE
  • Loading branch information
Butkovits Atila committed Nov 26, 2024
1 parent faca517 commit 492b37c
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 124 deletions.
22 changes: 2 additions & 20 deletions browser/components/profiles/SelectableProfile.sys.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -87,33 +87,15 @@ export class SelectableProfile {
}

/**
* Get the profile directory as an nsIFile.
* Get the profile directory as an nsIFile.
*
* @returns {Promise<nsIFile>} A promise that resolves to an nsIFile for
* @returns {Promise<nsIFile>} A promise that resolves to an nsIFIle for
* the profile directory
*/
get rootDir() {
return IOUtils.getDirectory(this.path);
}

/**
* Get the profile local directory as an nsIFile.
*
* @returns {Promise<nsIFile>} A promise that resolves to an nsIFile for
* the profile local directory
*/
get localDir() {
return this.rootDir.then(root => {
let relative = root.getRelativePath(
this.#selectableProfileService.constructor.getDirectory("DefProfRt")
);
let local =
this.#selectableProfileService.constructor.getDirectory("DefProfLRt");
local.appendRelativePath(relative);
return local;
});
}

/**
* Get the name of the avatar for the profile.
*
Expand Down
5 changes: 2 additions & 3 deletions browser/components/profiles/SelectableProfileService.sys.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ class SelectableProfileServiceClass {
static getDirectory(id) {
if (this.#dirSvc) {
if (id in this.#dirSvc) {
return this.#dirSvc[id].clone();
return this.#dirSvc[id];
}
}

Expand Down Expand Up @@ -655,8 +655,7 @@ class SelectableProfileServiceClass {

async #updateTaskbar() {
try {
// We don't want the startup profile selector to badge the dock icon.
if (!gSupportsBadging || Services.startup.startingUp) {
if (!gSupportsBadging) {
return;
}

Expand Down
64 changes: 7 additions & 57 deletions browser/components/profiles/content/profile-selector.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -29,48 +29,11 @@ export class ProfileSelector extends MozLitElement {
};

#initPromise = null;
#startupParams = null;

constructor() {
super();

this.#initPromise = this.init();
if (window.arguments?.[0] instanceof Ci.nsIDialogParamBlock) {
this.#startupParams = window.arguments[0];
}
}

get isStartupUI() {
return !!this.#startupParams;
}

/**
* Sets the return block for the startup UI.
*
* @param {SelectableProfile} profile The profile to launch
* @param {string[]} args Any additional command line arguments to append
*/
async setLaunchArguments(profile, args = []) {
if (!this.#startupParams) {
return;
}

this.#startupParams.SetInt(
0,
Ci.nsIToolkitProfileService.launchWithProfile
);
// Set start offline to false.
this.#startupParams.SetInt(1, 0);
// Number of new arguments.
this.#startupParams.SetInt(2, args.length);

this.#startupParams.objects.insertElementAt(await profile.rootDir, 0);
this.#startupParams.objects.insertElementAt(await profile.localDir, 1);

this.#startupParams.SetNumberStrings(args.length);
for (let i = 0; i < args.length; i++) {
this.#startupParams.SetString(i, args[i]);
}
}

async getUpdateComplete() {
Expand Down Expand Up @@ -100,13 +63,6 @@ export class ProfileSelector extends MozLitElement {

this.initialized = true;
this.#initPromise = null;

if (this.isStartupUI) {
window.addEventListener("unload", () => {
// In case the user closed the window manually.
this.selectableProfileService.uninit();
});
}
}

handleCheckboxToggle() {
Expand All @@ -115,22 +71,12 @@ export class ProfileSelector extends MozLitElement {
);
}

async launchProfile(profile, url) {
if (this.isStartupUI) {
await this.setLaunchArguments(profile, url ? ["-url", url] : []);
await this.selectableProfileService.uninit();
} else {
this.selectableProfileService.launchInstance(profile, url);
}

window.close();
}

async handleEvent(event) {
switch (event.type) {
case "LaunchProfile": {
let { profile, url } = event.detail;
await this.launchProfile(profile, url);
this.selectableProfileService.launchInstance(profile, url);
window.close();
break;
}
case "CreateProfile": {
Expand All @@ -140,7 +86,11 @@ export class ProfileSelector extends MozLitElement {
}
case "DeleteProfile": {
let profile = event.detail;
await this.launchProfile(profile, "about:deleteprofile");
this.selectableProfileService.launchInstance(
profile,
"about:deleteprofile"
);
window.close();
break;
}
}
Expand Down
2 changes: 0 additions & 2 deletions toolkit/profile/content/profileSelection.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ function getFluentString(str) {
function startup() {
try {
gDialogParams = window.arguments[0].QueryInterface(I.nsIDialogParamBlock);
gDialogParams.SetNumberStrings(0);
gDialogParams.SetInt(2, 0);

gProfileService = C[ToolkitProfileService].getService(
I.nsIToolkitProfileService
Expand Down
57 changes: 15 additions & 42 deletions toolkit/xre/nsAppRunner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2856,28 +2856,6 @@ static ReturnAbortOnError ShowProfileDialog(
rv = dlgArray->QueryElementAt(1, NS_GET_IID(nsIFile),
getter_AddRefs(profLD));
NS_ENSURE_SUCCESS_LOG(rv, rv);

if (dialogReturn == nsIToolkitProfileService::launchWithProfile) {
int32_t newArguments;
rv = ioParamBlock->GetInt(2, &newArguments);

if (NS_SUCCEEDED(rv) && newArguments > 0) {
char** newArgv = (char**)realloc(
gRestartArgv, sizeof(char*) * (gRestartArgc + newArguments + 1));
NS_ENSURE_TRUE(newArgv, NS_ERROR_OUT_OF_MEMORY);

gRestartArgv = newArgv;

for (auto i = 0; i < newArguments; i++) {
char16_t* arg;
ioParamBlock->GetString(i, &arg);
gRestartArgv[gRestartArgc++] =
strdup(NS_ConvertUTF16toUTF8(nsDependentString(arg)).get());
}

gRestartArgv[gRestartArgc] = nullptr;
}
}
}
}

Expand Down Expand Up @@ -5093,27 +5071,22 @@ int XREMain::XRE_mainStartup(bool* aExitFlag) {
}
#endif

// We now know there is no existing instance using the selected profile.

// We only ever show the profile selector if a specific profile wasn't chosen
// via command line arguments or environment variables.
if (wasDefaultSelection) {
// First check the old style profile manager
bool useSelectedProfile;
rv = mProfileSvc->GetStartWithLastProfile(&useSelectedProfile);
NS_ENSURE_SUCCESS(rv, 1);
bool useSelectedProfile;
rv = mProfileSvc->GetStartWithLastProfile(&useSelectedProfile);
NS_ENSURE_SUCCESS(rv, 1);

if (!useSelectedProfile) {
rv = ShowProfileManager(mProfileSvc, mNativeApp);
} else if (profile) {
// Now check the new profile group selector
bool showSelector = false;
profile->GetShowProfileSelector(&showSelector);
if (showSelector) {
rv = ShowProfileSelector(mProfileSvc, mNativeApp);
} else {
rv = NS_OK;
}
// We now know there is no existing instance using the selected profile. If
// the profile wasn't selected by specific command line arguments and the
// user has chosen to show the profile manager on startup then do that.
if (wasDefaultSelection && !useSelectedProfile) {
rv = ShowProfileManager(mProfileSvc, mNativeApp);
} else if (profile) {
bool showSelector = false;
profile->GetShowProfileSelector(&showSelector);
if (showSelector) {
rv = ShowProfileSelector(mProfileSvc, mNativeApp);
} else {
rv = NS_OK;
}
}

Expand Down

0 comments on commit 492b37c

Please sign in to comment.