Investigate whether we can get country data from Windows APIs

RESOLVED FIXED in Firefox 37

Status

()

Core
Widget: Win32
RESOLVED FIXED
4 years ago
3 years ago

People

(Reporter: Benjamin Smedberg, Assigned: aklotz)

Tracking

(Blocks: 1 bug)

unspecified
mozilla38
All
Windows 7
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(firefox36 wontfix, firefox37+ fixed, firefox38 fixed)

Details

Attachments

(1 attachment, 1 obsolete attachment)

(Reporter)

Description

4 years ago
+++ This bug was initially created as a clone of Bug #1102295 +++

In order to target the new Yahoo! search default, we'd like to be able to change the default of users within the US but not some other countries (particularly asian countries).

Our base plan is to do this by time zone, but we'd like to investigate targeting this a little more carefully by country based on information already contained in the OS. Jim, can you provide an overview what other information we can obtain from Windows about the user's country, and the APIs?

This is extremely urgent, if you can't provide info by today please let me know.
Flags: needinfo?(jmathies)
No longer depends on: 1102295

Comment 1

4 years ago
Getting actual regional location probably isn't possible without hitting the network, but win32 does have the concept of a language locale, which includes information about language regions. (for example en-US, en-ZA, ..).

Would this suffice?

here's nice page on apis available:

https://www.globalyzer.com/gzserver/help/reference/localeSensitiveMethods/winlocalefunc.html
Flags: needinfo?(jmathies)
(Reporter)

Comment 2

4 years ago
I suspect that data will not be good enough for the use case.

Is there anything that will let us distinguish between nothern-hemisphere and southern-hemisphere (by time zone setting, for example)?
Flags: needinfo?(jmathies)

Comment 3

4 years ago
(In reply to Benjamin Smedberg  [:bsmedberg] from comment #2)
> I suspect that data will not be good enough for the use case.
> Is there anything that will let us distinguish between nothern-hemisphere
> and southern-hemisphere (by time zone setting, for example)?

Time zones might work although it looks like we'll be dealing with strings vs. an identifier, which could be problematic since the strings are also localized.

GetTimeZoneInformation:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms724421%28v=vs.85%29.aspx
http://msdn.microsoft.com/en-us/library/windows/desktop/ms725481%28v=vs.85%29.aspx

I also found GetUserGeoID which works on XP and up - 

api: http://msdn.microsoft.com/en-us/library/dd318138.aspx
ids: http://msdn.microsoft.com/en-us/library/dd374073.aspx

I've never worked with this api so I'm not sure how reliable it is. We could add a telemetry probe to pick this up, see what we get..
Flags: needinfo?(jmathies)
(Reporter)

Comment 4

4 years ago
  don't think we can trust this data enough to do anything for 34. I'm going to leave this open for the future, but it's not an immediate priority. Thanks for the research.
status-firefox34: --- → affected
status-firefox35: --- → affected
status-firefox36: --- → affected
tracking-firefox34: --- → +
tracking-firefox35: --- → +
tracking-firefox36: --- → +
Blocks: 1102416
No longer blocks: 1101642
status-firefox34: affected → wontfix
tracking-firefox34: + → -
GetUserGeoID() will take the value from the [Location] tab of the [Region] control panel applet.
http://www.integration.co.nz/images/win7-locale.png
Or [PC Settings]-[Time and language]-[Region and language]-[Country or region].
http://www.7tutorials.com/files/img/win8_keyb_input/keyboard_language20.png
GetUserGeoID sounds like what we want. Looks to be supported on XP and later. We can combine that with a call to GetGeoInfo (with GeoType=GEO_ISO2) to map the GEOID to a 2-letter country code.

Benjamin, can someone on your team take this and get it uplifted to 36? I'd like to get this and bug 1102295 used instead of the timezone fallback in that release. We can use the interface added in bug 1102295 to expose this for now.
status-firefox35: affected → wontfix
tracking-firefox35: + → -
Flags: needinfo?(benjamin)
Hardware: x86 → All
No longer blocks: 1102416
(Reporter)

Comment 8

3 years ago
I don't think we should actually use this until we've proofed it, probably by including the value in the telemetry ping and cross-checking it against geoIP for mismatches.

But yes, I will find somebody to get the API added.
Flags: needinfo?(benjamin)
Taking in account comment #8, we probably have this feature ready for 36. Tracking for 37.
status-firefox36: affected → wontfix
status-firefox37: --- → affected
tracking-firefox37: --- → +
(Assignee)

Updated

3 years ago
Assignee: nobody → aklotz
Status: NEW → ASSIGNED
Is this a dup or superseded by bug 1109120?
Flags: needinfo?(benjamin)
(Reporter)

Comment 11

3 years ago
It's not a dup, but I don't know whether it's still wanted. This was Gavin's request.
Flags: needinfo?(benjamin) → needinfo?(gavin.sharp)
We still want bug 1115106 as a followup/supplement to bug 1109120. This bug blocks bug 1115106.
Flags: needinfo?(gavin.sharp)
(Assignee)

Comment 13

3 years ago
Created attachment 8561099 [details] [diff] [review]
Obtain the user GEOID

This uses the same interface that smichaud used for the Mac in bug 1102295 and adds Windows support.
Attachment #8561099 - Flags: review?(jmathies)

Comment 14

3 years ago
I don't think this should be in nsIGfxInfo, it has nothing to do with graphics.

Comment 15

3 years ago
Gavin, shouldn't this move? Maybe we were in a rush or something in bug 1102295?
Flags: needinfo?(gavin.sharp)
Yes, we were in a rush in bug 1102295. And we may want to uplift this still, actually, so I think we should put it in nsIGfxInfo2 now, and we can clean both up later.
Flags: needinfo?(gavin.sharp)

Comment 17

3 years ago
> and we can clean both up later.

yeah right! :)

Comment 18

3 years ago
Comment on attachment 8561099 [details] [diff] [review]
Obtain the user GEOID

Review of attachment 8561099 [details] [diff] [review]:
-----------------------------------------------------------------

::: widget/windows/GfxInfo.cpp
@@ +28,5 @@
>  
>  #ifdef DEBUG
>  NS_IMPL_ISUPPORTS_INHERITED(GfxInfo, GfxInfoBase, nsIGfxInfoDebug)
> +#else
> +NS_IMPL_ISUPPORTS_INHERITED(GfxInfo, GfxInfoBase, nsIGfxInfo2)

aren't you skipping adding support for the new interface in debug builds?
Attachment #8561099 - Flags: review?(jmathies) → review+
(Assignee)

Comment 19

3 years ago
Created attachment 8561701 [details] [diff] [review]
Obtain the user GEOID (r2)

(In reply to Jim Mathies [:jimm] from comment #18)
> Comment on attachment 8561099 [details] [diff] [review]
> Obtain the user GEOID
> 
> Review of attachment 8561099 [details] [diff] [review]:
> -----------------------------------------------------------------
> 
> ::: widget/windows/GfxInfo.cpp
> @@ +28,5 @@
> >  
> >  #ifdef DEBUG
> >  NS_IMPL_ISUPPORTS_INHERITED(GfxInfo, GfxInfoBase, nsIGfxInfoDebug)
> > +#else
> > +NS_IMPL_ISUPPORTS_INHERITED(GfxInfo, GfxInfoBase, nsIGfxInfo2)
> 
> aren't you skipping adding support for the new interface in debug builds?

Good catch, fixed before landing.

https://hg.mozilla.org/integration/fx-team/rev/f74a7a410dd3
Attachment #8561099 - Attachment is obsolete: true
Attachment #8561701 - Flags: review+
(Assignee)

Comment 20

3 years ago
(In reply to Jim Mathies [:jimm] from comment #17)
> > and we can clean both up later.
> 
> yeah right! :)

Filed bug 1131325 ;-)
Component: XPCOM → Widget: Win32
https://hg.mozilla.org/mozilla-central/rev/f74a7a410dd3
Status: ASSIGNED → RESOLVED
Last Resolved: 3 years ago
status-firefox38: --- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla38
(Assignee)

Comment 22

3 years ago
Comment on attachment 8561701 [details] [diff] [review]
Obtain the user GEOID (r2)

Approval Request Comment
[Feature/regressing bug #]: Platform support for country id
[User impact if declined]: Chrome code won't be able to query for system country id on Windows.
[Describe test coverage new/current, TreeHerder]: Manually
[Risks and why]: None; code is self contained, uses existing interfaces already used by Mac implementation.
[String/UUID change made/needed]: None
Attachment #8561701 - Flags: approval-mozilla-beta?
Attachment #8561701 - Flags: approval-mozilla-aurora?
Gavin, you confirm that you want this patch in 36?
Flags: needinfo?(gavin.sharp)
Not needed for 36, but we should get it on 37.
Flags: needinfo?(gavin.sharp)
status-firefox34: wontfix → ---
status-firefox35: wontfix → ---
status-firefox36: wontfix → ---
tracking-firefox34: - → ---
tracking-firefox35: - → ---
tracking-firefox36: + → ---
Comment on attachment 8561701 [details] [diff] [review]
Obtain the user GEOID (r2)

OK, thanks. Taking it for aurora only then
Attachment #8561701 - Flags: approval-mozilla-beta?
Attachment #8561701 - Flags: approval-mozilla-beta-
Attachment #8561701 - Flags: approval-mozilla-aurora?
Attachment #8561701 - Flags: approval-mozilla-aurora+

Comment 26

3 years ago
Unified_cpp_widget0.cpp
Unified_cpp_widget1.cpp
Unified_cpp_manager_boot_src0.cpp
c:\t1\hg\comm-central\mozilla\widget\GfxInfoBase.h(13) : fatal error C1083: Cannot open include file: 'nsIGfxInfo2.h': No such file or directory
c:/t1/hg/comm-central/mozilla/config/rules.mk:930: recipe for target 'Unified_cpp_widget0.obj' failed
mozmake[4]: *** [Unified_cpp_widget0.obj] Error 2
(In reply to Philip Chee from comment #26)

Needs-clobber.
status-firefox36: --- → wontfix

Comment 29

3 years ago
I landed a trivial mingw fixup:

https://hg.mozilla.org/integration/mozilla-inbound/rev/5e50387c02f1
You need to log in before you can comment on or make changes to this bug.