зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1102295 - Get country data on the Mac. r=bsmedberg
This commit is contained in:
Родитель
91cd09280f
Коммит
86cf3dd3b0
|
@ -90,7 +90,11 @@ void InitGfxDriverInfoShutdownObserver()
|
|||
using namespace mozilla::widget;
|
||||
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,6 +9,9 @@
|
|||
#define __mozilla_widget_GfxInfoBase_h__
|
||||
|
||||
#include "nsIGfxInfo.h"
|
||||
#ifdef XP_MACOSX
|
||||
#include "nsIGfxInfo2.h"
|
||||
#endif
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIObserver.h"
|
||||
#include "nsWeakReference.h"
|
||||
|
@ -25,6 +28,9 @@ namespace mozilla {
|
|||
namespace widget {
|
||||
|
||||
class GfxInfoBase : public nsIGfxInfo,
|
||||
#ifdef XP_MACOSX
|
||||
public nsIGfxInfo2,
|
||||
#endif
|
||||
public nsIObserver,
|
||||
public nsSupportsWeakReference
|
||||
#ifdef DEBUG
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#define __mozilla_widget_GfxInfo_h__
|
||||
|
||||
#include "GfxInfoBase.h"
|
||||
#include "nsIGfxInfo2.h"
|
||||
|
||||
#include "nsString.h"
|
||||
|
||||
|
@ -50,10 +51,11 @@ public:
|
|||
|
||||
virtual nsresult Init();
|
||||
|
||||
#ifdef DEBUG
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
#ifdef DEBUG
|
||||
NS_DECL_NSIGFXINFODEBUG
|
||||
#endif
|
||||
NS_DECL_NSIGFXINFO2
|
||||
|
||||
virtual uint32_t OperatingSystemVersion() MOZ_OVERRIDE { return mOSXVersion; }
|
||||
|
||||
|
@ -71,6 +73,7 @@ protected:
|
|||
private:
|
||||
|
||||
void GetDeviceInfo();
|
||||
void GetSelectedCityInfo();
|
||||
void AddCrashReportAnnotations();
|
||||
|
||||
nsString mAdapterRAMString;
|
||||
|
@ -82,6 +85,8 @@ private:
|
|||
nsString mAdapterVendorID;
|
||||
nsString mAdapterDeviceID;
|
||||
|
||||
nsString mCountryCode;
|
||||
|
||||
uint32_t mOSXVersion;
|
||||
};
|
||||
|
||||
|
|
|
@ -34,7 +34,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
|
||||
|
||||
GfxInfo::GfxInfo()
|
||||
|
@ -96,6 +98,20 @@ 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()
|
||||
{
|
||||
|
@ -107,6 +123,8 @@ GfxInfo::Init()
|
|||
|
||||
GetDeviceInfo();
|
||||
|
||||
GetSelectedCityInfo();
|
||||
|
||||
AddCrashReportAnnotations();
|
||||
|
||||
mOSXVersion = nsCocoaFeatures::OSXVersion();
|
||||
|
@ -266,6 +284,15 @@ 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()
|
||||
{
|
||||
|
|
|
@ -29,6 +29,7 @@ if toolkit == 'windows':
|
|||
]
|
||||
elif toolkit == 'cocoa':
|
||||
XPIDL_SOURCES += [
|
||||
'nsIGfxInfo2.idl',
|
||||
'nsIMacDockSupport.idl',
|
||||
'nsIMacWebAppUtils.idl',
|
||||
'nsIStandaloneNativeMenu.idl',
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
/* -*- 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;
|
||||
};
|
||||
|
Загрузка…
Ссылка в новой задаче