Commit f2d77086 authored by leng@chromium.org's avatar leng@chromium.org

Add a null check for PermissionBubbleManager::FromWebcontents.

There is a small chance that the permission bubble manager for a given
web contents has been deleted before an asychronous permission request
has been handled.

BUG=371085

Review URL: https://codereview.chromium.org/282693002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@269987 0039d316-1c4b-4281-b951-d872f2087c98
parent 9d92bbc0
...@@ -283,11 +283,13 @@ void ChromeQuotaPermissionContext::RequestQuotaPermission( ...@@ -283,11 +283,13 @@ void ChromeQuotaPermissionContext::RequestQuotaPermission(
if (PermissionBubbleManager::Enabled()) { if (PermissionBubbleManager::Enabled()) {
PermissionBubbleManager* bubble_manager = PermissionBubbleManager* bubble_manager =
PermissionBubbleManager::FromWebContents(web_contents); PermissionBubbleManager::FromWebContents(web_contents);
bubble_manager->AddRequest(new QuotaPermissionRequest(this, if (bubble_manager) {
params.origin_url, params.requested_size, params.user_gesture, bubble_manager->AddRequest(new QuotaPermissionRequest(this,
Profile::FromBrowserContext(web_contents->GetBrowserContext())-> params.origin_url, params.requested_size, params.user_gesture,
GetPrefs()->GetString(prefs::kAcceptLanguages), Profile::FromBrowserContext(web_contents->GetBrowserContext())->
callback)); GetPrefs()->GetString(prefs::kAcceptLanguages),
callback));
}
return; return;
} }
......
...@@ -242,9 +242,11 @@ void ChromeGeolocationPermissionContext::DecidePermission( ...@@ -242,9 +242,11 @@ void ChromeGeolocationPermissionContext::DecidePermission(
if (PermissionBubbleManager::Enabled()) { if (PermissionBubbleManager::Enabled()) {
PermissionBubbleManager* mgr = PermissionBubbleManager* mgr =
PermissionBubbleManager::FromWebContents(web_contents); PermissionBubbleManager::FromWebContents(web_contents);
mgr->AddRequest(new GeolocationPermissionRequest( if (mgr) {
this, id, requesting_frame, user_gesture, callback, mgr->AddRequest(new GeolocationPermissionRequest(
profile_->GetPrefs()->GetString(prefs::kAcceptLanguages))); this, id, requesting_frame, user_gesture, callback,
profile_->GetPrefs()->GetString(prefs::kAcceptLanguages)));
}
} else { } else {
// setting == ask. Prompt the user. // setting == ask. Prompt the user.
QueueController()->CreateInfoBarRequest( QueueController()->CreateInfoBarRequest(
......
...@@ -199,10 +199,12 @@ void ChromeMidiPermissionContext::DecidePermission( ...@@ -199,10 +199,12 @@ void ChromeMidiPermissionContext::DecidePermission(
if (PermissionBubbleManager::Enabled()) { if (PermissionBubbleManager::Enabled()) {
PermissionBubbleManager* bubble_manager = PermissionBubbleManager* bubble_manager =
PermissionBubbleManager::FromWebContents(web_contents); PermissionBubbleManager::FromWebContents(web_contents);
bubble_manager->AddRequest(new MidiPermissionRequest( if (bubble_manager) {
this, id, requesting_frame, user_gesture, bubble_manager->AddRequest(new MidiPermissionRequest(
profile_->GetPrefs()->GetString(prefs::kAcceptLanguages), this, id, requesting_frame, user_gesture,
callback)); profile_->GetPrefs()->GetString(prefs::kAcceptLanguages),
callback));
}
return; return;
} }
......
...@@ -75,7 +75,7 @@ const content::MediaStreamDevice* FindDeviceWithId( ...@@ -75,7 +75,7 @@ const content::MediaStreamDevice* FindDeviceWithId(
} }
} }
return NULL; return NULL;
}; }
// This is a short-term solution to grant camera and/or microphone access to // This is a short-term solution to grant camera and/or microphone access to
// extensions: // extensions:
...@@ -631,8 +631,10 @@ void MediaCaptureDevicesDispatcher::ProcessQueuedAccessRequest( ...@@ -631,8 +631,10 @@ void MediaCaptureDevicesDispatcher::ProcessQueuedAccessRequest(
base::Unretained(this), web_contents))); base::Unretained(this), web_contents)));
if (controller->DismissInfoBarAndTakeActionOnSettings()) if (controller->DismissInfoBarAndTakeActionOnSettings())
return; return;
PermissionBubbleManager::FromWebContents(web_contents)-> PermissionBubbleManager* bubble_manager =
AddRequest(controller.release()); PermissionBubbleManager::FromWebContents(web_contents);
if (bubble_manager)
bubble_manager->AddRequest(controller.release());
return; return;
} }
......
...@@ -514,12 +514,14 @@ void DesktopNotificationService::RequestPermission( ...@@ -514,12 +514,14 @@ void DesktopNotificationService::RequestPermission(
if (PermissionBubbleManager::Enabled()) { if (PermissionBubbleManager::Enabled()) {
PermissionBubbleManager* bubble_manager = PermissionBubbleManager* bubble_manager =
PermissionBubbleManager::FromWebContents(web_contents); PermissionBubbleManager::FromWebContents(web_contents);
bubble_manager->AddRequest(new NotificationPermissionRequest( if (bubble_manager) {
this, bubble_manager->AddRequest(new NotificationPermissionRequest(
origin, this,
DisplayNameForOriginInProcessId( origin,
origin, render_frame_host->GetProcess()->GetID()), DisplayNameForOriginInProcessId(
callback)); origin, render_frame_host->GetProcess()->GetID()),
callback));
}
return; return;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment