зеркало из https://github.com/mozilla/gecko-dev.git
Bug 935361 - Use CheckPermission in the PContentParent Geolocation message handlers. r=dougt
This commit is contained in:
Родитель
91e4dd3fd6
Коммит
17c82478d7
|
@ -2843,51 +2843,14 @@ ContentParent::RecvAddGeolocationListener(const IPC::Principal& aPrincipal,
|
|||
const bool& aHighAccuracy)
|
||||
{
|
||||
#ifdef MOZ_CHILD_PERMISSIONS
|
||||
if (Preferences::GetBool("geo.testing.ignore_ipc_principal", false) == false) {
|
||||
nsIPrincipal* principal = aPrincipal;
|
||||
if (principal == nullptr) {
|
||||
KillHard();
|
||||
return true;
|
||||
}
|
||||
|
||||
uint32_t principalAppId;
|
||||
nsresult rv = principal->GetAppId(&principalAppId);
|
||||
if (NS_FAILED(rv)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool found = false;
|
||||
const InfallibleTArray<PBrowserParent*>& browsers = ManagedPBrowserParent();
|
||||
for (uint32_t i = 0; i < browsers.Length(); ++i) {
|
||||
TabParent* tab = static_cast<TabParent*>(browsers[i]);
|
||||
nsCOMPtr<mozIApplication> app = tab->GetOwnOrContainingApp();
|
||||
uint32_t appId;
|
||||
app->GetLocalId(&appId);
|
||||
if (appId == principalAppId) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// We need to ensure that this permission has been set.
|
||||
// If it hasn't, just noop
|
||||
nsCOMPtr<nsIPermissionManager> pm = do_GetService(NS_PERMISSIONMANAGER_CONTRACTID);
|
||||
if (!pm) {
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32_t permission = nsIPermissionManager::UNKNOWN_ACTION;
|
||||
rv = pm->TestPermissionFromPrincipal(principal, "geolocation", &permission);
|
||||
if (NS_FAILED(rv) || permission != nsIPermissionManager::ALLOW_ACTION) {
|
||||
KillHard();
|
||||
if (!Preferences::GetBool("geo.testing.ignore_ipc_principal", false)) {
|
||||
uint32_t permission = mozilla::CheckPermission(this, aPrincipal,
|
||||
"geolocation");
|
||||
if (permission != nsIPermissionManager::ALLOW_ACTION) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif /* MOZ_CHILD_PERMISSIONS */
|
||||
|
||||
// To ensure no geolocation updates are skipped, we always force the
|
||||
// creation of a new listener.
|
||||
|
|
Загрузка…
Ссылка в новой задаче