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

Unified Diff: chrome/browser/permissions/permission_queue_controller.cc

Issue 1332293002: permissions: switch from explicitly passing queue controller to callbacks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 3 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/permissions/permission_queue_controller.cc
diff --git a/chrome/browser/permissions/permission_queue_controller.cc b/chrome/browser/permissions/permission_queue_controller.cc
index 0cc6d40dc1ef55f0ad47dde586b40e8537365cd1..6c74d980eb3de3e035f79338223d9e9f8ed222fd 100644
--- a/chrome/browser/permissions/permission_queue_controller.cc
+++ b/chrome/browser/permissions/permission_queue_controller.cc
@@ -11,6 +11,7 @@
#include "chrome/browser/media/midi_permission_infobar_delegate.h"
#include "chrome/browser/notifications/notification_permission_infobar_delegate.h"
#include "chrome/browser/permissions/permission_context_uma_util.h"
+#include "chrome/browser/permissions/permission_request_id.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/storage/durable_storage_permission_infobar_delegate.h"
#include "chrome/browser/tab_contents/tab_util.h"
@@ -113,35 +114,45 @@ void PermissionQueueController::PendingInfobarRequest::RunCallback(
void PermissionQueueController::PendingInfobarRequest::CreateInfoBar(
PermissionQueueController* controller,
const std::string& display_languages) {
+ // Controller can be Unretained because the lifetime of the infobar
+ // is tied to that of the queue controller. Before QueueController
+ // is destroyed, all requests will be cancelled and so all delegates
+ // will be destroyed.
+ PermissionInfobarDelegate::PermissionSetCallback callback =
+ base::Bind(&PermissionQueueController::OnPermissionSet,
+ base::Unretained(controller),
+ id_,
+ requesting_frame_,
+ embedder_);
switch (type_) {
case CONTENT_SETTINGS_TYPE_GEOLOCATION:
infobar_ = GeolocationInfoBarDelegate::Create(
- GetInfoBarService(id_), controller, id_, requesting_frame_,
- display_languages);
+ GetInfoBarService(id_), requesting_frame_,
+ display_languages, callback);
break;
#if defined(ENABLE_NOTIFICATIONS)
case CONTENT_SETTINGS_TYPE_NOTIFICATIONS:
infobar_ = NotificationPermissionInfobarDelegate::Create(
- GetInfoBarService(id_), controller, id_, requesting_frame_,
- display_languages);
+ GetInfoBarService(id_), requesting_frame_,
+ display_languages, callback);
break;
#endif // ENABLE_NOTIFICATIONS
case CONTENT_SETTINGS_TYPE_MIDI_SYSEX:
infobar_ = MidiPermissionInfoBarDelegate::Create(
- GetInfoBarService(id_), controller, id_, requesting_frame_,
- display_languages, type_);
+ GetInfoBarService(id_), requesting_frame_,
+ display_languages, type_, callback);
break;
#if defined(OS_ANDROID) || defined(OS_CHROMEOS)
case CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER:
infobar_ = ProtectedMediaIdentifierInfoBarDelegate::Create(
- GetInfoBarService(id_), controller, id_, requesting_frame_,
- display_languages);
+ GetInfoBarService(id_), requesting_frame_,
+ display_languages, callback);
break;
#endif
case CONTENT_SETTINGS_TYPE_DURABLE_STORAGE:
infobar_ = DurableStoragePermissionInfoBarDelegate::Create(
- GetInfoBarService(id_), controller, id_, requesting_frame_,
- display_languages, type_);
+ GetInfoBarService(id_), requesting_frame_,
+ display_languages, type_, callback);
break;
default:
NOTREACHED();

Powered by Google App Engine
This is Rietveld 408576698