Closed Bug 519468 Opened 16 years ago Closed 16 years ago

matchOS is read from default prefs at startup

Categories

(Toolkit :: Startup and Profile System, defect)

defect
Not set
normal

Tracking

()

VERIFIED FIXED
mozilla1.9.3a1
Tracking Status
status1.9.2 --- beta2-fixed

People

(Reporter: vingtetun, Assigned: vingtetun)

References

Details

(Whiteboard: [fennec l10n][l10n])

Attachments

(1 file, 7 obsolete files)

Attached patch dirty workaround (obsolete) — Splinter Review
yeah, that a dupe of 429033, but I'm not sure we want to correct the original bug instead of using a workaround for B4, so I'm duplicating the bug. Furthermore, my workaround is dirty! :)
This bug probably belongs wherever bug 429033 belongs. From the chat in #developers, it's not really clear what this means in cooperation with fastload.
Attached patch WIP-2 (obsolete) — Splinter Review
this one looks more like what it's actually done for the command line overriding of the locale.
Attachment #403502 - Attachment is obsolete: true
Comment on attachment 403633 [details] [diff] [review] WIP-2 >+ if (matchOS) { >+ // compute lang and region code only when needed! >+ nsCAutoString uiLocale; >+ rv = getUILangCountry(uiLocale); >+ if (NS_SUCCEEDED(rv)) >+ mSelectedLocale = uiLocale; We should also remove any observer for SELECTED_LOCALE_PREF like we do above. But only if matchOS is true >+ } >+ else { >+ nsXPIDLCString provider; >+ rv = prefs->GetCharPref(SELECTED_LOCALE_PREF, getter_Copies(provider)); >+ if (NS_SUCCEEDED(rv)) >+ mSelectedLocale = provider; And we probably need to add an observer for SELECTED_LOCALE_PREF here, just to mimic the behavior that happens in ::Init() I think this patch has potential. Hopefully we won't need to flush any fastload caches.
Component: General → Startup and Profile System
Product: Fennec → Toolkit
QA Contact: general → startup
Attached patch WIP-3 (obsolete) — Splinter Review
* Address comments * Add a test to see if matchOS is different from the default one once the user prefs has been loaded
Attachment #403633 - Attachment is obsolete: true
Comment on attachment 403762 [details] [diff] [review] WIP-3 This patch is modeled on the way the UILocale commandline flag works. This patch listens for "profile-after-change" to adjust the selected locale from the user prefs. It is actually fired sooner than the UILocale code. The UILocale code does not call FlushAllCaches. Since this patch fires before UILocale, it doesn't call FlushAllCaches either. That might be an oversight for UILocale and therefore something we would need to do.
Attachment #403762 - Flags: review?(benjamin)
Comment on attachment 403762 [details] [diff] [review] WIP-3 That's a big hunk of code you've just duplicated. Please make a helper function to avoid the duplication.
Attachment #403762 - Flags: review?(benjamin) → review-
But I don't actually understand why you need to do it this way... can't you just install a pref observer for matchos, the same way there's already a pref observer for the locale/skin prefs?
Attached patch WIP-4 (obsolete) — Splinter Review
* Use an helper function * Remove the "profile-after-change" observer to an observer on the matchOS pref
Attachment #403762 - Attachment is obsolete: true
Attached patch WIP-5 (obsolete) — Splinter Review
Attachment #407583 - Attachment is obsolete: true
Comment on attachment 407627 [details] [diff] [review] WIP-5 I think you should register the SELECTED_LOCALE_PREF observer in nsChromeRegistry::Init in the same place you register the MATCH_OS and SELECTED_SKIN observers. Then in ::Observe, just call SelectLocalePref whenever matchOS or the selected locale changes. And this needs an xpcshell test.
Attachment #407627 - Flags: review?(benjamin) → review-
Attached patch Patch (obsolete) — Splinter Review
all the selected locale change and matchOS are handle through SelectLocalePref now. There is no more any removeObserver/addObserver calls into it, which means we are going to enter and refresh mSelectedLocale every time the selected locale pref change, even if we are into a 'matchOS mode'.
Attachment #407627 - Attachment is obsolete: true
Attachment #408757 - Flags: review?
Comment on attachment 408757 [details] [diff] [review] Patch canceling review because I suspect the patch to be wrong
Attached patch Patch v0.2 + xpcshell test (obsolete) — Splinter Review
Add the xpcshell test
Attachment #408757 - Attachment is obsolete: true
Attachment #408869 - Flags: review?
+ don' call FlushAllCache at startup
Attachment #408869 - Flags: review?(benjamin) → review-
Comment on attachment 408869 [details] [diff] [review] Patch v0.2 + xpcshell test >diff --git a/chrome/src/nsChromeRegistry.cpp b/chrome/src/nsChromeRegistry.cpp >+nsresult >+nsChromeRegistry::SelectLocalePref(nsIPrefBranch* prefs) >+{ >+ nsresult rv; >+ nsCOMPtr<nsIPrefBranch2> prefs2 (do_QueryInterface(prefs)); Remove prefs2, you're not using it any more. >+ PRBool matchOSLocale = PR_FALSE; >+ rv = prefs->GetBoolPref(MATCH_OS_LOCALE_PREF, &matchOSLocale); >+ >+ if (NS_SUCCEEDED(rv) && matchOSLocale) { >+ // compute lang and region code only when needed! >+ nsCAutoString uiLocale; >+ rv = getUILangCountry(uiLocale); >+ if (NS_SUCCEEDED(rv)) >+ mSelectedLocale = uiLocale; You never call FlushAllCaches in this block. mSelectedLocale will be correct but the chrome caches won't reflect it. >+ else { >+ nsXPIDLCString provider; >+ rv = prefs->GetCharPref(SELECTED_LOCALE_PREF, getter_Copies(provider)); >+ if (NS_SUCCEEDED(rv)) { >+ mSelectedLocale = provider; >+ >+ if (!mInitialized) >+ FlushAllCaches(); If *not* mInitialized? Shouldn't it be the other way, we flush caches if we *are* initialized? Isn't what you really mean "if the user changes the pref after the profile has been initialized". If that's what you mean, you should use a profile-initial-state observer and only call FlushAllCaches once that notification has been received. Although I see now that we don't actually send any profile-initial-state notifications. We should do that here: http://mxr.mozilla.org/mozilla-central/source/toolkit/xre/nsXREDirProvider.cpp#816 >diff --git a/chrome/test/unit/data/test_bug519468.manifest b/chrome/test/unit/data/test_bug519468.manifest >+locale global en-US jar:en-US.jar!/locale/en-US/global/ >+locale global fr-FR jar:en-US.jar!/locale/en-US/global/ I think you'd be better off using a dummy packagename rather than "global", since there are various services in mozilla which use global locale stuff to initialize error messages and might get confused here.
Attached patch Patch v0.3Splinter Review
(In reply to comment #15) > (From update of attachment 408869 [details] [diff] [review]) > >diff --git a/chrome/src/nsChromeRegistry.cpp b/chrome/src/nsChromeRegistry.cpp > > >+nsresult > >+nsChromeRegistry::SelectLocalePref(nsIPrefBranch* prefs) > >+{ > >+ nsresult rv; > >+ nsCOMPtr<nsIPrefBranch2> prefs2 (do_QueryInterface(prefs)); > > Remove prefs2, you're not using it any more. Done. > > >+ PRBool matchOSLocale = PR_FALSE; > >+ rv = prefs->GetBoolPref(MATCH_OS_LOCALE_PREF, &matchOSLocale); > >+ > >+ if (NS_SUCCEEDED(rv) && matchOSLocale) { > >+ // compute lang and region code only when needed! > >+ nsCAutoString uiLocale; > >+ rv = getUILangCountry(uiLocale); > >+ if (NS_SUCCEEDED(rv)) > >+ mSelectedLocale = uiLocale; > > You never call FlushAllCaches in this block. mSelectedLocale will be correct > but the chrome caches won't reflect it. I've move the FlushAllCaches call in the observer method. > >+ else { > >+ nsXPIDLCString provider; > >+ rv = prefs->GetCharPref(SELECTED_LOCALE_PREF, getter_Copies(provider)); > >+ if (NS_SUCCEEDED(rv)) { > >+ mSelectedLocale = provider; > >+ > >+ if (!mInitialized) > >+ FlushAllCaches(); > > If *not* mInitialized? Shouldn't it be the other way, we flush caches if we > *are* initialized? Isn't what you really mean "if the user changes the pref > after the profile has been initialized". If that's what you mean, you should > use a profile-initial-state observer and only call FlushAllCaches once that > notification has been received. my bad, you're perfectly right. > Although I see now that we don't actually send any profile-initial-state > notifications. We should do that here: > http://mxr.mozilla.org/mozilla-central/source/toolkit/xre/nsXREDirProvider.cpp#816 Done. > >diff --git a/chrome/test/unit/data/test_bug519468.manifest b/chrome/test/unit/data/test_bug519468.manifest > > >+locale global en-US jar:en-US.jar!/locale/en-US/global/ > >+locale global fr-FR jar:en-US.jar!/locale/en-US/global/ > > I think you'd be better off using a dummy packagename rather than "global", > since there are various services in mozilla which use global locale stuff to > initialize error messages and might get confused here. I have replace 'global' by 'testmatchos'
Attachment #408869 - Attachment is obsolete: true
Attachment #409643 - Flags: review?
Attachment #409643 - Flags: review?(benjamin) → review+
Blocks: 519684, 525257
Whiteboard: [fennec l10n][l10n]
Status: NEW → RESOLVED
Closed: 16 years ago
Resolution: --- → FIXED
Comment on attachment 409643 [details] [diff] [review] Patch v0.3 Needed for Fennec beta 5
Attachment #409643 - Flags: approval1.9.2?
Attachment #409643 - Flags: approval1.9.2? → approval1.9.2+
I might be seeing a regression of this in my n810 fennec nightly. It insists on coming up in German, even though my OS locale is set to en-US. That's a Moailla/5.0 (X11; U; Linux armv6l; de; rv:1.9.2b2pre) Gecko/20091103 about:buildconfig references http://hg.mozilla.org/releases/mozilla-1.9.2/rev/bae033362017.
We definitely need this in our BFT's and Smoketests on litmus.
Axel, works for me on francais and English (en-US), so verified FIXED with en-US: Mozilla/5.0 (X11; U; Linux armv7l; Nokia N900; en-US; rv:1.9.2b2pre) Gecko/20091104 Firefox/3.6b2pre Fennec/1.0b5 and Mozilla/5.0 (X11; U; Linux armv6l; Nokia N8xx; en-US; rv:1.9.3a1pre) Gecko/20091104 Firefox/3.7a1pre Fennec/1.0b5 If you see any new issues, go ahead an file a new bug.
Status: RESOLVED → VERIFIED
Flags: in-litmus?
This fails for me on a German system: TEST-UNEXPECTED-FAIL | .../mozilla/_tests/xpcshell/test_chrome/unit/test_bug519468.js | en-US == de-DE
Assignee: nobody → 21
Flags: in-testsuite+
Target Milestone: --- → mozilla1.9.3a1
Filed bug 557024 about the test failure.
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: