Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1388)

Unified Diff: chrome/browser/geolocation/chrome_geolocation_permission_context.cc

Issue 265773002: [Media,Geolocation] Add permission bubble cancellation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix rebase Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/geolocation/chrome_geolocation_permission_context.cc
diff --git a/chrome/browser/geolocation/chrome_geolocation_permission_context.cc b/chrome/browser/geolocation/chrome_geolocation_permission_context.cc
index 6b3eb194fe6acadabffa0c994fc6329b340f242f..c55c563a4bfa0ad8b90492dfe3734b0d88f9d14d 100644
--- a/chrome/browser/geolocation/chrome_geolocation_permission_context.cc
+++ b/chrome/browser/geolocation/chrome_geolocation_permission_context.cc
@@ -114,11 +114,11 @@ void GeolocationPermissionRequest::PermissionDenied() {
}
void GeolocationPermissionRequest::Cancelled() {
- context_->NotifyPermissionSet(id_, requesting_frame_, callback_, false);
}
void GeolocationPermissionRequest::RequestFinished() {
- delete this;
+ // Deletes 'this'.
+ context_->RequestFinished(this);
}
@@ -210,7 +210,6 @@ void ChromeGeolocationPermissionContext::CancelGeolocationPermissionRequest(
guest->CancelGeolocationPermissionRequest(bridge_id);
return;
}
- // TODO(gbillock): cancel permission bubble request.
int render_process_id = web_contents->GetRenderProcessHost()->GetID();
int render_view_id = web_contents->GetRenderViewHost()->GetRoutingID();
CancelPendingInfobarRequest(PermissionRequestID(
@@ -243,9 +242,12 @@ void ChromeGeolocationPermissionContext::DecidePermission(
PermissionBubbleManager* mgr =
PermissionBubbleManager::FromWebContents(web_contents);
if (mgr) {
- mgr->AddRequest(new GeolocationPermissionRequest(
+ GeolocationPermissionRequest* request =
+ new GeolocationPermissionRequest(
this, id, requesting_frame, user_gesture, callback,
- profile_->GetPrefs()->GetString(prefs::kAcceptLanguages)));
+ profile_->GetPrefs()->GetString(prefs::kAcceptLanguages));
+ pending_requests_[id.ToString()] = request;
+ mgr->AddRequest(request);
}
} else {
// setting == ask. Prompt the user.
@@ -270,6 +272,19 @@ void ChromeGeolocationPermissionContext::CreateInfoBarRequest(
base::Unretained(this), id, requesting_frame, callback));
}
+void ChromeGeolocationPermissionContext::RequestFinished(
+ GeolocationPermissionRequest* request) {
+ std::map<std::string, GeolocationPermissionRequest*>::iterator it;
+ for (it = pending_requests_.begin(); it != pending_requests_.end(); it++) {
+ if (it->second == request) {
+ delete it->second;
+ pending_requests_.erase(it);
+ return;
+ }
+ }
+}
+
+
void ChromeGeolocationPermissionContext::ShutdownOnUIThread() {
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
permission_queue_controller_.reset();
@@ -326,6 +341,25 @@ void ChromeGeolocationPermissionContext::CancelPendingInfobarRequest(
if (shutting_down_)
return;
- // TODO(gbillock): handle permission bubble cancellation.
+ if (PermissionBubbleManager::Enabled()) {
+ GeolocationPermissionRequest* cancelling = NULL;
+ std::map<std::string, GeolocationPermissionRequest*>::iterator it;
+ for (it = pending_requests_.begin(); it != pending_requests_.end(); it++) {
+ if (it->first == id.ToString()) {
+ cancelling = it->second;
+ break;
+ }
+ }
+
+ content::WebContents* web_contents = tab_util::GetWebContentsByID(
+ id.render_process_id(), id.render_view_id());
+ if (cancelling != NULL && web_contents != NULL &&
+ PermissionBubbleManager::FromWebContents(web_contents) != NULL) {
+ PermissionBubbleManager::FromWebContents(web_contents)->
+ CancelRequest(cancelling);
+ }
+ return;
+ }
+
QueueController()->CancelInfoBarRequest(id);
}

Powered by Google App Engine
This is Rietveld 408576698