diff --git a/widget/GfxInfoBase.cpp b/widget/GfxInfoBase.cpp index 1ce88da2cbf..71e3c158b41 100644 --- a/widget/GfxInfoBase.cpp +++ b/widget/GfxInfoBase.cpp @@ -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" diff --git a/widget/GfxInfoBase.h b/widget/GfxInfoBase.h index c0ec2f4ddb3..add932986be 100644 --- a/widget/GfxInfoBase.h +++ b/widget/GfxInfoBase.h @@ -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 diff --git a/widget/cocoa/GfxInfo.h b/widget/cocoa/GfxInfo.h index 386b0544976..58552efe07b 100644 --- a/widget/cocoa/GfxInfo.h +++ b/widget/cocoa/GfxInfo.h @@ -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; }; diff --git a/widget/cocoa/GfxInfo.mm b/widget/cocoa/GfxInfo.mm index 16d23c610bb..9eb7415f365 100644 --- a/widget/cocoa/GfxInfo.mm +++ b/widget/cocoa/GfxInfo.mm @@ -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() { diff --git a/widget/moz.build b/widget/moz.build index 26dcab0ca1b..eed3066e5d3 100644 --- a/widget/moz.build +++ b/widget/moz.build @@ -29,6 +29,7 @@ if toolkit == 'windows': ] elif toolkit == 'cocoa': XPIDL_SOURCES += [ + 'nsIGfxInfo2.idl', 'nsIMacDockSupport.idl', 'nsIMacWebAppUtils.idl', 'nsIStandaloneNativeMenu.idl', diff --git a/widget/nsIGfxInfo2.idl b/widget/nsIGfxInfo2.idl new file mode 100644 index 00000000000..f60f12c415e --- /dev/null +++ b/widget/nsIGfxInfo2.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; +}; +