mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-17 22:32:51 +00:00
Bug 1262591 - Add ability to add device ID to user agent for Fennec; r=jduell
--HG-- extra : rebase_source : 6abc6abd4a5fd41c2c274647b522df8798d30fc7
This commit is contained in:
parent
8b4ee660aa
commit
aecd563cf7
@ -126,6 +126,18 @@ NewURI(const nsACString &aSpec,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
static nsCString
|
||||
GetDeviceModelId() {
|
||||
nsCOMPtr<nsIPropertyBag2> infoService = do_GetService("@mozilla.org/system-info;1");
|
||||
MOZ_ASSERT(infoService, "Could not find a system info service");
|
||||
nsAutoString androidDevice;
|
||||
nsresult rv = infoService->GetPropertyAsAString(NS_LITERAL_STRING("device"), androidDevice);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
return NS_LossyConvertUTF16toASCII(androidDevice);
|
||||
}
|
||||
return EmptyCString();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// nsHttpHandler <public>
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -779,6 +791,10 @@ nsHttpHandler::InitUserAgentComponents()
|
||||
mCompatDevice.AssignLiteral("Mobile");
|
||||
}
|
||||
}
|
||||
|
||||
if (Preferences::GetBool(UA_PREF("use_device"), false)) {
|
||||
mDeviceModelId = mozilla::net::GetDeviceModelId();
|
||||
}
|
||||
#endif // ANDROID
|
||||
|
||||
#ifdef MOZ_MULET
|
||||
@ -957,6 +973,18 @@ nsHttpHandler::PrefsChanged(nsIPrefBranch *prefs, const char *pref)
|
||||
mUserAgentIsDirty = true;
|
||||
}
|
||||
|
||||
#ifdef ANDROID
|
||||
// general.useragent.use_device
|
||||
if (PREF_CHANGED(UA_PREF("use_device"))) {
|
||||
if (Preferences::GetBool(UA_PREF("use_device"), false)) {
|
||||
mDeviceModelId = mozilla::net::GetDeviceModelId();
|
||||
} else {
|
||||
mDeviceModelId = EmptyCString();
|
||||
}
|
||||
mUserAgentIsDirty = true;
|
||||
}
|
||||
#endif
|
||||
|
||||
//
|
||||
// HTTP options
|
||||
//
|
||||
|
Loading…
x
Reference in New Issue
Block a user