mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1102297: Obtain user GEOID from Windows; r=jimm
This commit is contained in:
parent
dd5c127fee
commit
5975175609
@ -9,7 +9,7 @@
|
||||
#define __mozilla_widget_GfxInfoBase_h__
|
||||
|
||||
#include "nsIGfxInfo.h"
|
||||
#ifdef XP_MACOSX
|
||||
#if defined(XP_MACOSX) || defined(XP_WIN)
|
||||
#include "nsIGfxInfo2.h"
|
||||
#endif
|
||||
#include "nsCOMPtr.h"
|
||||
@ -28,7 +28,7 @@ namespace mozilla {
|
||||
namespace widget {
|
||||
|
||||
class GfxInfoBase : public nsIGfxInfo,
|
||||
#ifdef XP_MACOSX
|
||||
#if defined(XP_MACOSX) || defined(XP_WIN)
|
||||
public nsIGfxInfo2,
|
||||
#endif
|
||||
public nsIObserver,
|
||||
|
@ -15,6 +15,7 @@ if toolkit == 'windows':
|
||||
DIRS += ['windows']
|
||||
|
||||
XPIDL_SOURCES += [
|
||||
'nsIGfxInfo2.idl',
|
||||
'nsIJumpListBuilder.idl',
|
||||
'nsIJumpListItem.idl',
|
||||
'nsIPrintSettingsWin.idl',
|
||||
|
@ -27,7 +27,9 @@ using namespace mozilla;
|
||||
using namespace mozilla::widget;
|
||||
|
||||
#ifdef DEBUG
|
||||
NS_IMPL_ISUPPORTS_INHERITED(GfxInfo, GfxInfoBase, nsIGfxInfoDebug)
|
||||
NS_IMPL_ISUPPORTS_INHERITED(GfxInfo, GfxInfoBase, nsIGfxInfo2, nsIGfxInfoDebug)
|
||||
#else
|
||||
NS_IMPL_ISUPPORTS_INHERITED(GfxInfo, GfxInfoBase, nsIGfxInfo2)
|
||||
#endif
|
||||
|
||||
static const uint32_t allWindowsVersions = 0xffffffff;
|
||||
@ -549,6 +551,8 @@ GfxInfo::Init()
|
||||
|
||||
AddCrashReportAnnotations();
|
||||
|
||||
GetCountryCode();
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
@ -715,6 +719,15 @@ CheckForCiscoVPN() {
|
||||
}
|
||||
#endif
|
||||
|
||||
/* interface nsIGfxInfo2 */
|
||||
/* readonly attribute DOMString countryCode; */
|
||||
NS_IMETHODIMP
|
||||
GfxInfo::GetCountryCode(nsAString& aCountryCode)
|
||||
{
|
||||
aCountryCode = mCountryCode;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
GfxInfo::AddCrashReportAnnotations()
|
||||
{
|
||||
@ -796,6 +809,28 @@ GfxInfo::AddCrashReportAnnotations()
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
GfxInfo::GetCountryCode()
|
||||
{
|
||||
GEOID geoid = GetUserGeoID(GEOCLASS_NATION);
|
||||
if (geoid == GEOID_NOT_AVAILABLE) {
|
||||
return;
|
||||
}
|
||||
// Get required length
|
||||
int numChars = GetGeoInfoW(geoid, GEO_ISO2, nullptr, 0, 0);
|
||||
if (!numChars) {
|
||||
return;
|
||||
}
|
||||
// Now get the string for real
|
||||
mCountryCode.SetLength(numChars);
|
||||
numChars = GetGeoInfoW(geoid, GEO_ISO2, mCountryCode.BeginWriting(),
|
||||
mCountryCode.Length(), 0);
|
||||
if (numChars) {
|
||||
// numChars includes null terminator
|
||||
mCountryCode.Truncate(numChars - 1);
|
||||
}
|
||||
}
|
||||
|
||||
static OperatingSystem
|
||||
WindowsVersionToOperatingSystem(int32_t aWindowsVersion)
|
||||
{
|
||||
|
@ -9,6 +9,7 @@
|
||||
#define __mozilla_widget_GfxInfo_h__
|
||||
|
||||
#include "GfxInfoBase.h"
|
||||
#include "nsIGfxInfo2.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace widget {
|
||||
@ -50,10 +51,11 @@ public:
|
||||
|
||||
virtual uint32_t OperatingSystemVersion() MOZ_OVERRIDE { return mWindowsVersion; }
|
||||
|
||||
#ifdef DEBUG
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
#ifdef DEBUG
|
||||
NS_DECL_NSIGFXINFODEBUG
|
||||
#endif
|
||||
NS_DECL_NSIGFXINFO2
|
||||
|
||||
protected:
|
||||
|
||||
@ -67,6 +69,9 @@ protected:
|
||||
private:
|
||||
|
||||
void AddCrashReportAnnotations();
|
||||
void GetCountryCode();
|
||||
|
||||
nsString mCountryCode;
|
||||
nsString mDeviceString;
|
||||
nsString mDeviceID;
|
||||
nsString mDriverVersion;
|
||||
|
Loading…
Reference in New Issue
Block a user