mirror of
https://github.com/zen-browser/desktop.git
synced 2026-03-06 00:37:03 +00:00
88 lines
3.9 KiB
C++
88 lines
3.9 KiB
C++
diff --git a/toolkit/profile/nsToolkitProfileService.cpp b/toolkit/profile/nsToolkitProfileService.cpp
|
|
index 6e40f51cfc6e76fbd63d87fe7a416481fe9bb2f6..3bc78e3077264387415a06a52a3a8fbc56339484 100644
|
|
--- a/toolkit/profile/nsToolkitProfileService.cpp
|
|
+++ b/toolkit/profile/nsToolkitProfileService.cpp
|
|
@@ -234,7 +234,7 @@ void RemoveProfileFiles(nsIToolkitProfile* aProfile, bool aInBackground) {
|
|
}
|
|
|
|
nsToolkitProfile::nsToolkitProfile(const nsACString& aName, nsIFile* aRootDir,
|
|
- nsIFile* aLocalDir, bool aFromDB,
|
|
+ nsIFile* aLocalDir, bool aFromDB, const nsACString& aZenAvatarPath,
|
|
const nsACString& aStoreID = VoidCString(),
|
|
bool aShowProfileSelector = false)
|
|
: mName(aName),
|
|
@@ -244,7 +244,8 @@ nsToolkitProfile::nsToolkitProfile(const nsACString& aName, nsIFile* aRootDir,
|
|
mShowProfileSelector(aShowProfileSelector),
|
|
mLock(nullptr),
|
|
mIndex(0),
|
|
- mSection("Profile") {
|
|
+ mSection("Profile"),
|
|
+ mZenAvatarPath(aZenAvatarPath) {
|
|
NS_ASSERTION(aRootDir, "No file!");
|
|
|
|
RefPtr<nsToolkitProfile> prev =
|
|
@@ -259,6 +260,10 @@ nsToolkitProfile::nsToolkitProfile(const nsACString& aName, nsIFile* aRootDir,
|
|
// If this profile isn't in the database already add it.
|
|
if (!aFromDB) {
|
|
nsINIParser* db = &nsToolkitProfileService::gService->mProfileDB;
|
|
+ if (mZenAvatarPath == ""_ns) {
|
|
+ auto randomId = std::rand() % 100;
|
|
+ mZenAvatarPath = ("chrome://browser/content/zen-avatars/avatar-" + std::to_string(randomId) + ".svg").c_str();
|
|
+ }
|
|
db->SetString(mSection.get(), "Name", mName.get());
|
|
|
|
bool isRelative = false;
|
|
@@ -268,6 +273,7 @@ nsToolkitProfile::nsToolkitProfile(const nsACString& aName, nsIFile* aRootDir,
|
|
|
|
db->SetString(mSection.get(), "IsRelative", isRelative ? "1" : "0");
|
|
db->SetString(mSection.get(), "Path", descriptor.get());
|
|
+ db->SetString(mSection.get(), "ZenAvatarPath", mZenAvatarPath.get());
|
|
if (!mStoreID.IsVoid()) {
|
|
db->SetString(mSection.get(), "StoreID",
|
|
PromiseFlatCString(mStoreID).get());
|
|
@@ -466,6 +472,8 @@ nsToolkitProfile::SetShowProfileSelector(bool aShowProfileSelector) {
|
|
#endif
|
|
}
|
|
|
|
+#include "zenProfileMethodsOverride.inc.cpp"
|
|
+
|
|
nsresult nsToolkitProfile::RemoveInternal(bool aRemoveFiles,
|
|
bool aInBackground) {
|
|
NS_ASSERTION(nsToolkitProfileService::gService, "Whoa, my service is gone.");
|
|
@@ -1158,8 +1166,15 @@ nsresult nsToolkitProfileService::Init() {
|
|
}
|
|
}
|
|
|
|
- currentProfile = new nsToolkitProfile(name, rootDir, localDir, true,
|
|
- storeID, showProfileSelector);
|
|
+ nsAutoCString zenProfileAvatar;
|
|
+
|
|
+ rv = mProfileDB.GetString(profileID.get(), "ZenAvatarPath", zenProfileAvatar);
|
|
+ if (NS_FAILED(rv)) {
|
|
+ NS_ERROR("Malformed profiles.ini: ZenAvatarPath= not found");
|
|
+ continue;
|
|
+ }
|
|
+
|
|
+ currentProfile = new nsToolkitProfile(name, rootDir, localDir, true, zenProfileAvatar, storeID, showProfileSelector);
|
|
|
|
// If a user has modified the ini file path it may make for a valid profile
|
|
// path but not match what we would have serialised and so may not match
|
|
@@ -1384,7 +1399,7 @@ nsresult nsToolkitProfileService::CreateDefaultProfile(
|
|
if (mUseDevEditionProfile) {
|
|
name.AssignLiteral(DEV_EDITION_NAME);
|
|
} else if (mUseDedicatedProfile) {
|
|
- name.AppendPrintf("default-%s", mUpdateChannel.get());
|
|
+ name.AppendPrintf("Default (%s)", mUpdateChannel.get());
|
|
} else {
|
|
name.AssignLiteral(DEFAULT_NAME);
|
|
}
|
|
@@ -2180,7 +2195,7 @@ nsToolkitProfileService::CreateProfile(nsIFile* aRootDir,
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
nsCOMPtr<nsIToolkitProfile> profile =
|
|
- new nsToolkitProfile(aName, rootDir, localDir, false);
|
|
+ new nsToolkitProfile(aName, rootDir, localDir, false, ""_ns);
|
|
|
|
if (aName.Equals(DEV_EDITION_NAME)) {
|
|
mDevEditionDefault = profile;
|