... |
... |
@@ -2599,91 +2599,8 @@ nsresult LaunchChild(bool aBlankCommandLine, bool aTryExec) { |
2599
|
2599
|
return NS_ERROR_LAUNCHED_CHILD_PROCESS;
|
2600
|
2600
|
}
|
2601
|
2601
|
|
2602
|
|
-static nsresult GetOverrideStringBundleForLocale(nsIStringBundleService* aSBS,
|
2603
|
|
- const char* aTorbuttonURI,
|
2604
|
|
- const char* aLocale,
|
2605
|
|
- nsIStringBundle** aResult) {
|
2606
|
|
- NS_ENSURE_ARG(aSBS);
|
2607
|
|
- NS_ENSURE_ARG(aTorbuttonURI);
|
2608
|
|
- NS_ENSURE_ARG(aLocale);
|
2609
|
|
- NS_ENSURE_ARG(aResult);
|
2610
|
|
-
|
2611
|
|
- const char* kFormatStr =
|
2612
|
|
- "jar:%s!/chrome/torbutton/locale/%s/torbutton.properties";
|
2613
|
|
- nsPrintfCString strBundleURL(kFormatStr, aTorbuttonURI, aLocale);
|
2614
|
|
- nsresult rv = aSBS->CreateBundle(strBundleURL.get(), aResult);
|
2615
|
|
- NS_ENSURE_SUCCESS(rv, rv);
|
2616
|
|
-
|
2617
|
|
- // To ensure that we have a valid string bundle, try to retrieve a string
|
2618
|
|
- // that we know exists.
|
2619
|
|
- nsAutoString val;
|
2620
|
|
- rv = (*aResult)->GetStringFromName("profileProblemTitle", val);
|
2621
|
|
- if (!NS_SUCCEEDED(rv)) *aResult = nullptr; // No good. Discard it.
|
2622
|
|
-
|
2623
|
|
- return rv;
|
2624
|
|
-}
|
2625
|
|
-
|
2626
|
|
-static void GetOverrideStringBundle(nsIStringBundleService* aSBS,
|
2627
|
|
- nsIStringBundle** aResult) {
|
2628
|
|
- if (!aSBS || !aResult) return;
|
2629
|
|
-
|
2630
|
|
- *aResult = nullptr;
|
2631
|
|
-
|
2632
|
|
- // Build Torbutton file URI string by starting from GREDir.
|
2633
|
|
- RefPtr<nsXREDirProvider> dirProvider = nsXREDirProvider::GetSingleton();
|
2634
|
|
- if (!dirProvider) return;
|
2635
|
|
-
|
2636
|
|
- nsCOMPtr<nsIFile> greDir = dirProvider->GetGREDir();
|
2637
|
|
- if (!greDir) return;
|
2638
|
|
-
|
2639
|
|
- // Create file URI, extract as string, and append omni.ja relative path.
|
2640
|
|
- nsCOMPtr<nsIURI> uri;
|
2641
|
|
- nsAutoCString uriString;
|
2642
|
|
- if (NS_FAILED(NS_NewFileURI(getter_AddRefs(uri), greDir)) ||
|
2643
|
|
- NS_FAILED(uri->GetSpec(uriString))) {
|
2644
|
|
- return;
|
2645
|
|
- }
|
2646
|
|
-
|
2647
|
|
- uriString.Append("omni.ja");
|
2648
|
|
-
|
2649
|
|
- nsAutoCString userAgentLocale;
|
2650
|
|
- if (!NS_SUCCEEDED(
|
2651
|
|
- Preferences::GetCString("intl.locale.requested", userAgentLocale))) {
|
2652
|
|
- return;
|
2653
|
|
- }
|
2654
|
|
-
|
2655
|
|
- nsresult rv = GetOverrideStringBundleForLocale(
|
2656
|
|
- aSBS, uriString.get(), userAgentLocale.get(), aResult);
|
2657
|
|
- if (NS_FAILED(rv)) {
|
2658
|
|
- // Try again using base locale, e.g., "en" vs. "en-US".
|
2659
|
|
- int16_t offset = userAgentLocale.FindChar('-', 1);
|
2660
|
|
- if (offset > 0) {
|
2661
|
|
- nsAutoCString shortLocale(Substring(userAgentLocale, 0, offset));
|
2662
|
|
- rv = GetOverrideStringBundleForLocale(aSBS, uriString.get(),
|
2663
|
|
- shortLocale.get(), aResult);
|
2664
|
|
- }
|
2665
|
|
- }
|
2666
|
|
-}
|
2667
|
|
-
|
2668
|
|
-static nsresult GetFormattedString(nsIStringBundle* aOverrideBundle,
|
2669
|
|
- nsIStringBundle* aMainBundle,
|
2670
|
|
- const char* aName,
|
2671
|
|
- const nsTArray<nsString>& aParams,
|
2672
|
|
- nsAString& aResult) {
|
2673
|
|
- NS_ENSURE_ARG(aName);
|
2674
|
|
-
|
2675
|
|
- nsresult rv = NS_ERROR_FAILURE;
|
2676
|
|
- if (aOverrideBundle) {
|
2677
|
|
- rv = aOverrideBundle->FormatStringFromName(aName, aParams, aResult);
|
2678
|
|
- }
|
2679
|
|
-
|
2680
|
|
- // If string was not found in override bundle, use main (browser) bundle.
|
2681
|
|
- if (NS_FAILED(rv) && aMainBundle)
|
2682
|
|
- rv = aMainBundle->FormatStringFromName(aName, aParams, aResult);
|
2683
|
|
-
|
2684
|
|
- return rv;
|
2685
|
|
-}
|
2686
|
|
-
|
|
2602
|
+static const char kBrandProperties[] =
|
|
2603
|
+ "chrome://branding/locale/brand.properties";
|
2687
|
2604
|
static const char kProfileProperties[] =
|
2688
|
2605
|
"chrome://mozapps/locale/profile/profileSelection.properties";
|
2689
|
2606
|
|
... |
... |
@@ -2753,12 +2670,20 @@ static nsresult ProfileMissingDialog(nsINativeAppSupport* aNative) { |
2753
|
2670
|
mozilla::components::StringBundle::Service();
|
2754
|
2671
|
NS_ENSURE_TRUE(sbs, NS_ERROR_FAILURE);
|
2755
|
2672
|
|
|
2673
|
+ nsCOMPtr<nsIStringBundle> brandBundle;
|
|
2674
|
+ sbs->CreateBundle(kBrandProperties, getter_AddRefs(brandBundle));
|
|
2675
|
+ NS_ENSURE_TRUE_LOG(sbs, NS_ERROR_FAILURE);
|
2756
|
2676
|
nsCOMPtr<nsIStringBundle> sb;
|
2757
|
2677
|
sbs->CreateBundle(kProfileProperties, getter_AddRefs(sb));
|
2758
|
2678
|
NS_ENSURE_TRUE_LOG(sbs, NS_ERROR_FAILURE);
|
2759
|
2679
|
|
2760
|
|
- NS_ConvertUTF8toUTF16 appName(MOZ_APP_DISPLAYNAME);
|
2761
|
|
- AutoTArray<nsString, 2> params = {appName, appName};
|
|
2680
|
+ nsAutoString appName;
|
|
2681
|
+ rv = brandBundle->GetStringFromName("brandShortName", appName);
|
|
2682
|
+ NS_ENSURE_SUCCESS(rv, NS_ERROR_ABORT);
|
|
2683
|
+
|
|
2684
|
+ AutoTArray<nsString, 2> params;
|
|
2685
|
+ params.AppendElement(appName);
|
|
2686
|
+ params.AppendElement(appName);
|
2762
|
2687
|
|
2763
|
2688
|
// profileMissing
|
2764
|
2689
|
nsAutoString missingMessage;
|
... |
... |
@@ -2782,12 +2707,11 @@ static nsresult ProfileMissingDialog(nsINativeAppSupport* aNative) { |
2782
|
2707
|
|
2783
|
2708
|
// If aUnlocker is NULL, it is also OK for the following arguments to be NULL:
|
2784
|
2709
|
// aProfileDir, aProfileLocalDir, aResult.
|
2785
|
|
-static ReturnAbortOnError ProfileErrorDialog(nsIFile* aProfileDir,
|
2786
|
|
- nsIFile* aProfileLocalDir,
|
2787
|
|
- ProfileStatus aStatus,
|
2788
|
|
- nsIProfileUnlocker* aUnlocker,
|
2789
|
|
- nsINativeAppSupport* aNative,
|
2790
|
|
- nsIProfileLock** aResult) {
|
|
2710
|
+static ReturnAbortOnError ProfileLockedDialog(nsIFile* aProfileDir,
|
|
2711
|
+ nsIFile* aProfileLocalDir,
|
|
2712
|
+ nsIProfileUnlocker* aUnlocker,
|
|
2713
|
+ nsINativeAppSupport* aNative,
|
|
2714
|
+ nsIProfileLock** aResult) {
|
2791
|
2715
|
nsresult rv;
|
2792
|
2716
|
|
2793
|
2717
|
if (aProfileDir) {
|
... |
... |
@@ -2821,43 +2745,37 @@ static ReturnAbortOnError ProfileErrorDialog(nsIFile* aProfileDir, |
2821
|
2745
|
mozilla::components::StringBundle::Service();
|
2822
|
2746
|
NS_ENSURE_TRUE(sbs, NS_ERROR_FAILURE);
|
2823
|
2747
|
|
|
2748
|
+ nsCOMPtr<nsIStringBundle> brandBundle;
|
|
2749
|
+ sbs->CreateBundle(kBrandProperties, getter_AddRefs(brandBundle));
|
|
2750
|
+ NS_ENSURE_TRUE_LOG(sbs, NS_ERROR_FAILURE);
|
2824
|
2751
|
nsCOMPtr<nsIStringBundle> sb;
|
2825
|
2752
|
sbs->CreateBundle(kProfileProperties, getter_AddRefs(sb));
|
2826
|
2753
|
NS_ENSURE_TRUE_LOG(sbs, NS_ERROR_FAILURE);
|
2827
|
2754
|
|
2828
|
|
- nsCOMPtr<nsIStringBundle> overrideSB;
|
2829
|
|
- GetOverrideStringBundle(sbs, getter_AddRefs(overrideSB));
|
|
2755
|
+ nsAutoString appName;
|
|
2756
|
+ rv = brandBundle->GetStringFromName("brandShortName", appName);
|
|
2757
|
+ NS_ENSURE_SUCCESS(rv, NS_ERROR_ABORT);
|
2830
|
2758
|
|
2831
|
|
- NS_ConvertUTF8toUTF16 appName(MOZ_APP_DISPLAYNAME);
|
2832
|
|
- AutoTArray<nsString, 3> params = {appName, appName, appName};
|
|
2759
|
+ AutoTArray<nsString, 3> params;
|
|
2760
|
+ params.AppendElement(appName);
|
|
2761
|
+ params.AppendElement(appName);
|
|
2762
|
+ params.AppendElement(appName);
|
2833
|
2763
|
|
2834
|
2764
|
nsAutoString killMessage;
|
2835
|
2765
|
#ifndef XP_MACOSX
|
2836
|
|
- static const char kRestartUnlocker[] = "restartMessageUnlocker";
|
2837
|
|
- static const char kRestartNoUnlocker[] = "restartMessageNoUnlocker2";
|
2838
|
|
- static const char kReadOnly[] = "profileReadOnly";
|
|
2766
|
+ rv = sb->FormatStringFromName(
|
|
2767
|
+ aUnlocker ? "restartMessageUnlocker" : "restartMessageNoUnlocker2",
|
|
2768
|
+ params, killMessage);
|
2839
|
2769
|
#else
|
2840
|
|
- static const char kRestartUnlocker[] = "restartMessageUnlockerMac";
|
2841
|
|
- static const char kRestartNoUnlocker[] = "restartMessageNoUnlockerMac";
|
2842
|
|
- static const char kReadOnly[] = "profileReadOnlyMac";
|
2843
|
|
-#endif
|
2844
|
|
- static const char kAccessDenied[] = "profileAccessDenied";
|
2845
|
|
-
|
2846
|
|
- const char* errorKey = aUnlocker ? kRestartUnlocker : kRestartNoUnlocker;
|
2847
|
|
- if (PROFILE_STATUS_READ_ONLY == aStatus)
|
2848
|
|
- errorKey = kReadOnly;
|
2849
|
|
- else if (PROFILE_STATUS_ACCESS_DENIED == aStatus)
|
2850
|
|
- errorKey = kAccessDenied;
|
2851
|
|
- rv = GetFormattedString(overrideSB, sb, errorKey, params, killMessage);
|
|
2770
|
+ rv = sb->FormatStringFromName(
|
|
2771
|
+ aUnlocker ? "restartMessageUnlockerMac" : "restartMessageNoUnlockerMac",
|
|
2772
|
+ params, killMessage);
|
|
2773
|
+#endif
|
2852
|
2774
|
NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);
|
2853
|
2775
|
|
2854
|
|
- const char* titleKey = ((PROFILE_STATUS_READ_ONLY == aStatus) ||
|
2855
|
|
- (PROFILE_STATUS_ACCESS_DENIED == aStatus))
|
2856
|
|
- ? "profileProblemTitle"
|
2857
|
|
- : "restartTitle";
|
2858
|
2776
|
params.SetLength(1);
|
2859
|
2777
|
nsAutoString killTitle;
|
2860
|
|
- rv = sb->FormatStringFromName(titleKey, params, killTitle);
|
|
2778
|
+ rv = sb->FormatStringFromName("restartTitle", params, killTitle);
|
2861
|
2779
|
NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);
|
2862
|
2780
|
|
2863
|
2781
|
#ifdef MOZ_BACKGROUNDTASKS
|
... |
... |
@@ -3028,24 +2946,6 @@ static ReturnAbortOnError ShowProfileManager( |
3028
|
2946
|
return LaunchChild(false, true);
|
3029
|
2947
|
}
|
3030
|
2948
|
|
3031
|
|
-#ifdef XP_MACOSX
|
3032
|
|
-static ProfileStatus CheckTorBrowserDataWriteAccess() {
|
3033
|
|
- // Check whether we can write to the directory that will contain
|
3034
|
|
- // TorBrowser-Data.
|
3035
|
|
- RefPtr<nsXREDirProvider> singleton = nsXREDirProvider::GetSingleton();
|
3036
|
|
- if (!singleton) {
|
3037
|
|
- return PROFILE_STATUS_OTHER_ERROR;
|
3038
|
|
- }
|
3039
|
|
- nsCOMPtr<nsIFile> tbDataDir;
|
3040
|
|
- nsresult rv = singleton->GetTorBrowserUserDataDir(getter_AddRefs(tbDataDir));
|
3041
|
|
- NS_ENSURE_SUCCESS(rv, PROFILE_STATUS_OTHER_ERROR);
|
3042
|
|
- nsCOMPtr<nsIFile> tbDataDirParent;
|
3043
|
|
- rv = tbDataDir->GetParent(getter_AddRefs(tbDataDirParent));
|
3044
|
|
- NS_ENSURE_SUCCESS(rv, PROFILE_STATUS_OTHER_ERROR);
|
3045
|
|
- return nsToolkitProfileService::CheckProfileWriteAccess(tbDataDirParent);
|
3046
|
|
-}
|
3047
|
|
-#endif
|
3048
|
|
-
|
3049
|
2949
|
static bool gDoMigration = false;
|
3050
|
2950
|
static bool gDoProfileReset = false;
|
3051
|
2951
|
static nsCOMPtr<nsIToolkitProfile> gResetOldProfile;
|
... |
... |
@@ -3053,13 +2953,6 @@ static nsCOMPtr<nsIToolkitProfile> gResetOldProfile; |
3053
|
2953
|
static nsresult LockProfile(nsINativeAppSupport* aNative, nsIFile* aRootDir,
|
3054
|
2954
|
nsIFile* aLocalDir, nsIToolkitProfile* aProfile,
|
3055
|
2955
|
nsIProfileLock** aResult) {
|
3056
|
|
- ProfileStatus status =
|
3057
|
|
- (aProfile ? nsToolkitProfileService::CheckProfileWriteAccess(aProfile)
|
3058
|
|
- : nsToolkitProfileService::CheckProfileWriteAccess(aRootDir));
|
3059
|
|
- if (PROFILE_STATUS_OK != status)
|
3060
|
|
- return ProfileErrorDialog(aRootDir, aLocalDir, status, nullptr, aNative,
|
3061
|
|
- aResult);
|
3062
|
|
-
|
3063
|
2956
|
// If you close Firefox and very quickly reopen it, the old Firefox may
|
3064
|
2957
|
// still be closing down. Rather than immediately showing the
|
3065
|
2958
|
// "Firefox is running but is not responding" message, we spend a few
|
... |
... |
@@ -3086,8 +2979,7 @@ static nsresult LockProfile(nsINativeAppSupport* aNative, nsIFile* aRootDir, |
3086
|
2979
|
} while (TimeStamp::Now() - start <
|
3087
|
2980
|
TimeDuration::FromSeconds(kLockRetrySeconds));
|
3088
|
2981
|
|
3089
|
|
- return ProfileErrorDialog(aRootDir, aLocalDir, PROFILE_STATUS_IS_LOCKED,
|
3090
|
|
- unlocker, aNative, aResult);
|
|
2982
|
+ return ProfileLockedDialog(aRootDir, aLocalDir, unlocker, aNative, aResult);
|
3091
|
2983
|
}
|
3092
|
2984
|
|
3093
|
2985
|
// Pick a profile. We need to end up with a profile root dir, local dir and
|
... |
... |
@@ -3102,8 +2994,7 @@ static nsresult LockProfile(nsINativeAppSupport* aNative, nsIFile* aRootDir, |
3102
|
2994
|
static nsresult SelectProfile(nsToolkitProfileService* aProfileSvc,
|
3103
|
2995
|
nsINativeAppSupport* aNative, nsIFile** aRootDir,
|
3104
|
2996
|
nsIFile** aLocalDir, nsIToolkitProfile** aProfile,
|
3105
|
|
- bool* aWasDefaultSelection,
|
3106
|
|
- nsIProfileLock** aResult) {
|
|
2997
|
+ bool* aWasDefaultSelection) {
|
3107
|
2998
|
StartupTimeline::Record(StartupTimeline::SELECT_PROFILE);
|
3108
|
2999
|
|
3109
|
3000
|
nsresult rv;
|
... |
... |
@@ -3141,14 +3032,9 @@ static nsresult SelectProfile(nsToolkitProfileService* aProfileSvc, |
3141
|
3032
|
|
3142
|
3033
|
// Ask the profile manager to select the profile directories to use.
|
3143
|
3034
|
bool didCreate = false;
|
3144
|
|
- ProfileStatus profileStatus = PROFILE_STATUS_OK;
|
3145
|
|
- rv = aProfileSvc->SelectStartupProfile(
|
3146
|
|
- &gArgc, gArgv, gDoProfileReset, aRootDir, aLocalDir, aProfile, &didCreate,
|
3147
|
|
- aWasDefaultSelection, profileStatus);
|
3148
|
|
- if (PROFILE_STATUS_OK != profileStatus) {
|
3149
|
|
- return ProfileErrorDialog(*aRootDir, *aLocalDir, profileStatus, nullptr,
|
3150
|
|
- aNative, aResult);
|
3151
|
|
- }
|
|
3035
|
+ rv = aProfileSvc->SelectStartupProfile(&gArgc, gArgv, gDoProfileReset,
|
|
3036
|
+ aRootDir, aLocalDir, aProfile,
|
|
3037
|
+ &didCreate, aWasDefaultSelection);
|
3152
|
3038
|
|
3153
|
3039
|
if (rv == NS_ERROR_SHOW_PROFILE_MANAGER) {
|
3154
|
3040
|
return ShowProfileManager(aProfileSvc, aNative);
|
... |
... |
@@ -5062,19 +4948,6 @@ int XREMain::XRE_mainStartup(bool* aExitFlag) { |
5062
|
4948
|
|
5063
|
4949
|
mProfileSvc = NS_GetToolkitProfileService();
|
5064
|
4950
|
if (!mProfileSvc) {
|
5065
|
|
-#ifdef XP_MACOSX
|
5066
|
|
- // NS_NewToolkitProfileService() returns a generic NS_ERROR_FAILURE error
|
5067
|
|
- // if creation of the TorBrowser-Data directory fails due to access denied
|
5068
|
|
- // or because of a read-only disk volume. Do an extra check here to detect
|
5069
|
|
- // these errors so we can display an informative error message.
|
5070
|
|
- ProfileStatus status = CheckTorBrowserDataWriteAccess();
|
5071
|
|
- if ((PROFILE_STATUS_ACCESS_DENIED == status) ||
|
5072
|
|
- (PROFILE_STATUS_READ_ONLY == status)) {
|
5073
|
|
- ProfileErrorDialog(nullptr, nullptr, status, nullptr, mNativeApp,
|
5074
|
|
- nullptr);
|
5075
|
|
- return 1;
|
5076
|
|
- }
|
5077
|
|
-#endif
|
5078
|
4951
|
// We failed to choose or create profile - notify user and quit
|
5079
|
4952
|
ProfileMissingDialog(mNativeApp);
|
5080
|
4953
|
return 1;
|
... |
... |
@@ -5084,7 +4957,7 @@ int XREMain::XRE_mainStartup(bool* aExitFlag) { |
5084
|
4957
|
nsCOMPtr<nsIToolkitProfile> profile;
|
5085
|
4958
|
rv = SelectProfile(mProfileSvc, mNativeApp, getter_AddRefs(mProfD),
|
5086
|
4959
|
getter_AddRefs(mProfLD), getter_AddRefs(profile),
|
5087
|
|
- &wasDefaultSelection, getter_AddRefs(mProfileLock));
|
|
4960
|
+ &wasDefaultSelection);
|
5088
|
4961
|
if (rv == NS_ERROR_LAUNCHED_CHILD_PROCESS || rv == NS_ERROR_ABORT) {
|
5089
|
4962
|
*aExitFlag = true;
|
5090
|
4963
|
return 0;
|