mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1131325 - Move system country code from nsIGfxInfo2 to a more appropriate location. r=aklotz,smichaud
This commit is contained in:
parent
e6ae684afe
commit
94b4c66a23
@ -97,11 +97,7 @@ using namespace mozilla::widget;
|
||||
using namespace mozilla::gfx;
|
||||
using namespace mozilla;
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
NS_IMPL_ISUPPORTS(GfxInfoBase, nsIGfxInfo, nsIGfxInfo2, nsIObserver, nsISupportsWeakReference)
|
||||
#else
|
||||
NS_IMPL_ISUPPORTS(GfxInfoBase, nsIGfxInfo, nsIObserver, nsISupportsWeakReference)
|
||||
#endif
|
||||
|
||||
#define BLACKLIST_PREF_BRANCH "gfx.blacklist."
|
||||
#define SUGGESTED_VERSION_PREF BLACKLIST_PREF_BRANCH "suggested-driver-version"
|
||||
|
@ -9,9 +9,6 @@
|
||||
#define __mozilla_widget_GfxInfoBase_h__
|
||||
|
||||
#include "nsIGfxInfo.h"
|
||||
#if defined(XP_MACOSX) || defined(XP_WIN)
|
||||
#include "nsIGfxInfo2.h"
|
||||
#endif
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIObserver.h"
|
||||
#include "nsWeakReference.h"
|
||||
@ -29,9 +26,6 @@ namespace mozilla {
|
||||
namespace widget {
|
||||
|
||||
class GfxInfoBase : public nsIGfxInfo,
|
||||
#if defined(XP_MACOSX) || defined(XP_WIN)
|
||||
public nsIGfxInfo2,
|
||||
#endif
|
||||
public nsIObserver,
|
||||
public nsSupportsWeakReference
|
||||
#ifdef DEBUG
|
||||
|
@ -9,7 +9,6 @@
|
||||
#define __mozilla_widget_GfxInfo_h__
|
||||
|
||||
#include "GfxInfoBase.h"
|
||||
#include "nsIGfxInfo2.h"
|
||||
|
||||
#include "nsString.h"
|
||||
|
||||
@ -51,11 +50,10 @@ public:
|
||||
|
||||
virtual nsresult Init() override;
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
#ifdef DEBUG
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_NSIGFXINFODEBUG
|
||||
#endif
|
||||
NS_DECL_NSIGFXINFO2
|
||||
|
||||
virtual uint32_t OperatingSystemVersion() override { return mOSXVersion; }
|
||||
|
||||
@ -87,8 +85,6 @@ private:
|
||||
nsString mAdapterVendorID;
|
||||
nsString mAdapterDeviceID;
|
||||
|
||||
nsString mCountryCode;
|
||||
|
||||
uint32_t mOSXVersion;
|
||||
};
|
||||
|
||||
|
@ -28,9 +28,7 @@ using namespace mozilla;
|
||||
using namespace mozilla::widget;
|
||||
|
||||
#ifdef DEBUG
|
||||
NS_IMPL_ISUPPORTS_INHERITED(GfxInfo, GfxInfoBase, nsIGfxInfo2, nsIGfxInfoDebug)
|
||||
#else
|
||||
NS_IMPL_ISUPPORTS_INHERITED(GfxInfo, GfxInfoBase, nsIGfxInfo2)
|
||||
NS_IMPL_ISUPPORTS_INHERITED(GfxInfo, GfxInfoBase, nsIGfxInfoDebug)
|
||||
#endif
|
||||
|
||||
GfxInfo::GfxInfo()
|
||||
@ -98,20 +96,6 @@ GfxInfo::GetDeviceInfo()
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
GfxInfo::GetSelectedCityInfo()
|
||||
{
|
||||
NSDictionary* selected_city =
|
||||
[[NSUserDefaults standardUserDefaults]
|
||||
objectForKey:@"com.apple.preferences.timezone.selected_city"];
|
||||
NSString *countryCode = (NSString *)
|
||||
[selected_city objectForKey:@"CountryCode"];
|
||||
const char *countryCodeUTF8 = [countryCode UTF8String];
|
||||
if (countryCodeUTF8) {
|
||||
AppendUTF8toUTF16(countryCodeUTF8, mCountryCode);
|
||||
}
|
||||
}
|
||||
|
||||
nsresult
|
||||
GfxInfo::Init()
|
||||
{
|
||||
@ -123,8 +107,6 @@ GfxInfo::Init()
|
||||
|
||||
GetDeviceInfo();
|
||||
|
||||
GetSelectedCityInfo();
|
||||
|
||||
AddCrashReportAnnotations();
|
||||
|
||||
mOSXVersion = nsCocoaFeatures::OSXVersion();
|
||||
@ -284,15 +266,6 @@ GfxInfo::GetIsGPU2Active(bool* aIsGPU2Active)
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
/* interface nsIGfxInfo2 */
|
||||
/* readonly attribute DOMString countryCode; */
|
||||
NS_IMETHODIMP
|
||||
GfxInfo::GetCountryCode(nsAString & aCountryCode)
|
||||
{
|
||||
aCountryCode = mCountryCode;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
GfxInfo::AddCrashReportAnnotations()
|
||||
{
|
||||
|
@ -15,7 +15,6 @@ if toolkit == 'windows':
|
||||
DIRS += ['windows']
|
||||
|
||||
XPIDL_SOURCES += [
|
||||
'nsIGfxInfo2.idl',
|
||||
'nsIJumpListBuilder.idl',
|
||||
'nsIJumpListItem.idl',
|
||||
'nsIPrintSettingsWin.idl',
|
||||
@ -31,7 +30,6 @@ if toolkit == 'windows':
|
||||
]
|
||||
elif toolkit == 'cocoa':
|
||||
XPIDL_SOURCES += [
|
||||
'nsIGfxInfo2.idl',
|
||||
'nsIMacDockSupport.idl',
|
||||
'nsIMacWebAppUtils.idl',
|
||||
'nsIStandaloneNativeMenu.idl',
|
||||
|
@ -1,24 +0,0 @@
|
||||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
/**
|
||||
* nsIGfxInfo2 is a separately implemented extension of nsIGfxInfo, to
|
||||
* allow us (in effect) to tack things onto the nsIGfxInfo interface
|
||||
* without changing it.
|
||||
*/
|
||||
|
||||
[scriptable, uuid(9C8D8F44-6D52-45AA-8921-734EF4DF5DFE)]
|
||||
interface nsIGfxInfo2 : nsISupports
|
||||
{
|
||||
/**
|
||||
* Not really Gfx-related. Here for convenience,
|
||||
* possibly only temporarily. See bug 1102295.
|
||||
*/
|
||||
readonly attribute DOMString countryCode;
|
||||
};
|
||||
|
@ -29,9 +29,7 @@ using namespace mozilla;
|
||||
using namespace mozilla::widget;
|
||||
|
||||
#ifdef DEBUG
|
||||
NS_IMPL_ISUPPORTS_INHERITED(GfxInfo, GfxInfoBase, nsIGfxInfo2, nsIGfxInfoDebug)
|
||||
#else
|
||||
NS_IMPL_ISUPPORTS_INHERITED(GfxInfo, GfxInfoBase, nsIGfxInfo2)
|
||||
NS_IMPL_ISUPPORTS_INHERITED(GfxInfo, GfxInfoBase, nsIGfxInfoDebug)
|
||||
#endif
|
||||
|
||||
static const uint32_t allWindowsVersions = 0xffffffff;
|
||||
@ -562,8 +560,6 @@ GfxInfo::Init()
|
||||
|
||||
AddCrashReportAnnotations();
|
||||
|
||||
GetCountryCode();
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
@ -713,14 +709,6 @@ CheckForCiscoVPN() {
|
||||
}
|
||||
#endif
|
||||
|
||||
/* interface nsIGfxInfo2 */
|
||||
NS_IMETHODIMP
|
||||
GfxInfo::GetCountryCode(nsAString& aCountryCode)
|
||||
{
|
||||
aCountryCode = mCountryCode;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
GfxInfo::AddCrashReportAnnotations()
|
||||
{
|
||||
@ -802,28 +790,6 @@ 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, wwc(mCountryCode.BeginWriting()),
|
||||
mCountryCode.Length(), 0);
|
||||
if (numChars) {
|
||||
// numChars includes null terminator
|
||||
mCountryCode.Truncate(numChars - 1);
|
||||
}
|
||||
}
|
||||
|
||||
static OperatingSystem
|
||||
WindowsVersionToOperatingSystem(int32_t aWindowsVersion)
|
||||
{
|
||||
|
@ -9,7 +9,6 @@
|
||||
#define __mozilla_widget_GfxInfo_h__
|
||||
|
||||
#include "GfxInfoBase.h"
|
||||
#include "nsIGfxInfo2.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace widget {
|
||||
@ -53,11 +52,10 @@ public:
|
||||
|
||||
nsresult FindMonitors(JSContext* cx, JS::HandleObject array) override;
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
#ifdef DEBUG
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_NSIGFXINFODEBUG
|
||||
#endif
|
||||
NS_DECL_NSIGFXINFO2
|
||||
|
||||
protected:
|
||||
|
||||
@ -73,9 +71,7 @@ protected:
|
||||
private:
|
||||
|
||||
void AddCrashReportAnnotations();
|
||||
void GetCountryCode();
|
||||
|
||||
nsString mCountryCode;
|
||||
nsString mDeviceString;
|
||||
nsString mDeviceID;
|
||||
nsString mDriverVersion;
|
||||
|
18
xpcom/base/MacHelpers.h
Normal file
18
xpcom/base/MacHelpers.h
Normal file
@ -0,0 +1,18 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef mozilla_MacHelpers_h
|
||||
#define mozilla_MacHelpers_h
|
||||
|
||||
#include "nsString.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
nsresult GetSelectedCityInfo(nsAString& aCountryCode);
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
#endif
|
33
xpcom/base/MacHelpers.mm
Normal file
33
xpcom/base/MacHelpers.mm
Normal file
@ -0,0 +1,33 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "nsString.h"
|
||||
#include "MacHelpers.h"
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
nsresult
|
||||
GetSelectedCityInfo(nsAString& aCountryCode)
|
||||
{
|
||||
NSDictionary* selected_city =
|
||||
[[NSUserDefaults standardUserDefaults]
|
||||
objectForKey:@"com.apple.preferences.timezone.selected_city"];
|
||||
NSString *countryCode = (NSString *)
|
||||
[selected_city objectForKey:@"CountryCode"];
|
||||
const char *countryCodeUTF8 = [countryCode UTF8String];
|
||||
|
||||
if (!countryCodeUTF8) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
AppendUTF8toUTF16(countryCodeUTF8, aCountryCode);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
} // namespace Mozilla
|
||||
|
@ -33,6 +33,12 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
|
||||
XPIDL_SOURCES += [
|
||||
'nsIMacUtils.idl',
|
||||
]
|
||||
EXPORTS.mozilla += [
|
||||
'MacHelpers.h',
|
||||
]
|
||||
UNIFIED_SOURCES += [
|
||||
'MacHelpers.mm',
|
||||
]
|
||||
|
||||
XPIDL_MODULE = 'xpcom_base'
|
||||
|
||||
|
@ -25,6 +25,10 @@
|
||||
#include "nsWindowsHelpers.h"
|
||||
#endif
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
#include "MacHelpers.h"
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_WIDGET_GTK
|
||||
#include <gtk/gtk.h>
|
||||
#endif
|
||||
@ -172,6 +176,30 @@ nsresult GetInstallYear(uint32_t& aYear)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult GetCountryCode(nsAString& aCountryCode)
|
||||
{
|
||||
GEOID geoid = GetUserGeoID(GEOCLASS_NATION);
|
||||
if (geoid == GEOID_NOT_AVAILABLE) {
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
// Get required length
|
||||
int numChars = GetGeoInfoW(geoid, GEO_ISO2, nullptr, 0, 0);
|
||||
if (!numChars) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
// Now get the string for real
|
||||
aCountryCode.SetLength(numChars);
|
||||
numChars = GetGeoInfoW(geoid, GEO_ISO2, wwc(aCountryCode.BeginWriting()),
|
||||
aCountryCode.Length(), 0);
|
||||
if (!numChars) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// numChars includes null terminator
|
||||
aCountryCode.Truncate(numChars - 1);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
#endif // defined(XP_WIN)
|
||||
|
||||
@ -295,6 +323,12 @@ nsSystemInfo::Init()
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
nsAutoString countryCode;
|
||||
if (NS_SUCCEEDED(GetCountryCode(countryCode))) {
|
||||
rv = SetPropertyAsAString(NS_LITERAL_STRING("countryCode"), countryCode);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
uint32_t installYear = 0;
|
||||
if (NS_SUCCEEDED(GetInstallYear(installYear))) {
|
||||
rv = SetPropertyAsUint32(NS_LITERAL_STRING("installYear"), installYear);
|
||||
@ -304,6 +338,14 @@ nsSystemInfo::Init()
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(XP_MACOSX)
|
||||
nsAutoString countryCode;
|
||||
if (NS_SUCCEEDED(GetSelectedCityInfo(countryCode))) {
|
||||
rv = SetPropertyAsAString(NS_LITERAL_STRING("countryCode"), countryCode);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(MOZ_WIDGET_GTK)
|
||||
// This must be done here because NSPR can only separate OS's when compiled, not libraries.
|
||||
char* gtkver = PR_smprintf("GTK %u.%u.%u", gtk_major_version,
|
||||
|
Loading…
Reference in New Issue
Block a user