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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/permissions/permission_queue_controller.h" 5 #include "chrome/browser/permissions/permission_queue_controller.h"
6 6
7 #include "base/prefs/pref_service.h" 7 #include "base/prefs/pref_service.h"
8 #include "chrome/browser/chrome_notification_types.h" 8 #include "chrome/browser/chrome_notification_types.h"
9 #include "chrome/browser/geolocation/geolocation_infobar_delegate.h" 9 #include "chrome/browser/geolocation/geolocation_infobar_delegate.h"
10 #include "chrome/browser/infobars/infobar_service.h" 10 #include "chrome/browser/infobars/infobar_service.h"
11 #include "chrome/browser/media/midi_permission_infobar_delegate.h" 11 #include "chrome/browser/media/midi_permission_infobar_delegate.h"
12 #include "chrome/browser/notifications/notification_permission_infobar_delegate. h" 12 #include "chrome/browser/notifications/notification_permission_infobar_delegate. h"
13 #include "chrome/browser/permissions/permission_context_uma_util.h" 13 #include "chrome/browser/permissions/permission_context_uma_util.h"
14 #include "chrome/browser/permissions/permission_request_id.h"
14 #include "chrome/browser/profiles/profile.h" 15 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/browser/storage/durable_storage_permission_infobar_delegate.h" 16 #include "chrome/browser/storage/durable_storage_permission_infobar_delegate.h"
16 #include "chrome/browser/tab_contents/tab_util.h" 17 #include "chrome/browser/tab_contents/tab_util.h"
17 #include "chrome/common/pref_names.h" 18 #include "chrome/common/pref_names.h"
18 #include "components/content_settings/core/browser/host_content_settings_map.h" 19 #include "components/content_settings/core/browser/host_content_settings_map.h"
19 #include "components/content_settings/core/common/content_settings.h" 20 #include "components/content_settings/core/common/content_settings.h"
20 #include "components/infobars/core/infobar.h" 21 #include "components/infobars/core/infobar.h"
21 #include "content/public/browser/browser_thread.h" 22 #include "content/public/browser/browser_thread.h"
22 #include "content/public/browser/notification_details.h" 23 #include "content/public/browser/notification_details.h"
23 #include "content/public/browser/notification_source.h" 24 #include "content/public/browser/notification_source.h"
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 } 107 }
107 108
108 void PermissionQueueController::PendingInfobarRequest::RunCallback( 109 void PermissionQueueController::PendingInfobarRequest::RunCallback(
109 ContentSetting content_setting) { 110 ContentSetting content_setting) {
110 callback_.Run(content_setting); 111 callback_.Run(content_setting);
111 } 112 }
112 113
113 void PermissionQueueController::PendingInfobarRequest::CreateInfoBar( 114 void PermissionQueueController::PendingInfobarRequest::CreateInfoBar(
114 PermissionQueueController* controller, 115 PermissionQueueController* controller,
115 const std::string& display_languages) { 116 const std::string& display_languages) {
117 // Controller can be Unretained because the lifetime of the infobar
118 // is tied to that of the queue controller. Before QueueController
119 // is destroyed, all requests will be cancelled and so all delegates
120 // will be destroyed.
121 PermissionInfobarDelegate::PermissionSetCallback callback =
122 base::Bind(&PermissionQueueController::OnPermissionSet,
123 base::Unretained(controller),
124 id_,
125 requesting_frame_,
126 embedder_);
116 switch (type_) { 127 switch (type_) {
117 case CONTENT_SETTINGS_TYPE_GEOLOCATION: 128 case CONTENT_SETTINGS_TYPE_GEOLOCATION:
118 infobar_ = GeolocationInfoBarDelegate::Create( 129 infobar_ = GeolocationInfoBarDelegate::Create(
119 GetInfoBarService(id_), controller, id_, requesting_frame_, 130 GetInfoBarService(id_), requesting_frame_,
120 display_languages); 131 display_languages, callback);
121 break; 132 break;
122 #if defined(ENABLE_NOTIFICATIONS) 133 #if defined(ENABLE_NOTIFICATIONS)
123 case CONTENT_SETTINGS_TYPE_NOTIFICATIONS: 134 case CONTENT_SETTINGS_TYPE_NOTIFICATIONS:
124 infobar_ = NotificationPermissionInfobarDelegate::Create( 135 infobar_ = NotificationPermissionInfobarDelegate::Create(
125 GetInfoBarService(id_), controller, id_, requesting_frame_, 136 GetInfoBarService(id_), requesting_frame_,
126 display_languages); 137 display_languages, callback);
127 break; 138 break;
128 #endif // ENABLE_NOTIFICATIONS 139 #endif // ENABLE_NOTIFICATIONS
129 case CONTENT_SETTINGS_TYPE_MIDI_SYSEX: 140 case CONTENT_SETTINGS_TYPE_MIDI_SYSEX:
130 infobar_ = MidiPermissionInfoBarDelegate::Create( 141 infobar_ = MidiPermissionInfoBarDelegate::Create(
131 GetInfoBarService(id_), controller, id_, requesting_frame_, 142 GetInfoBarService(id_), requesting_frame_,
132 display_languages, type_); 143 display_languages, type_, callback);
133 break; 144 break;
134 #if defined(OS_ANDROID) || defined(OS_CHROMEOS) 145 #if defined(OS_ANDROID) || defined(OS_CHROMEOS)
135 case CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER: 146 case CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER:
136 infobar_ = ProtectedMediaIdentifierInfoBarDelegate::Create( 147 infobar_ = ProtectedMediaIdentifierInfoBarDelegate::Create(
137 GetInfoBarService(id_), controller, id_, requesting_frame_, 148 GetInfoBarService(id_), requesting_frame_,
138 display_languages); 149 display_languages, callback);
139 break; 150 break;
140 #endif 151 #endif
141 case CONTENT_SETTINGS_TYPE_DURABLE_STORAGE: 152 case CONTENT_SETTINGS_TYPE_DURABLE_STORAGE:
142 infobar_ = DurableStoragePermissionInfoBarDelegate::Create( 153 infobar_ = DurableStoragePermissionInfoBarDelegate::Create(
143 GetInfoBarService(id_), controller, id_, requesting_frame_, 154 GetInfoBarService(id_), requesting_frame_,
144 display_languages, type_); 155 display_languages, type_, callback);
145 break; 156 break;
146 default: 157 default:
147 NOTREACHED(); 158 NOTREACHED();
148 break; 159 break;
149 } 160 }
150 } 161 }
151 162
152 163
153 PermissionQueueController::PermissionQueueController(Profile* profile, 164 PermissionQueueController::PermissionQueueController(Profile* profile,
154 ContentSettingsType type) 165 ContentSettingsType type)
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 ContentSettingsPattern::Wildcard() : 408 ContentSettingsPattern::Wildcard() :
398 ContentSettingsPattern::FromURLNoWildcard(embedder.GetOrigin()); 409 ContentSettingsPattern::FromURLNoWildcard(embedder.GetOrigin());
399 410
400 profile_->GetHostContentSettingsMap()->SetContentSetting( 411 profile_->GetHostContentSettingsMap()->SetContentSetting(
401 ContentSettingsPattern::FromURLNoWildcard(requesting_frame.GetOrigin()), 412 ContentSettingsPattern::FromURLNoWildcard(requesting_frame.GetOrigin()),
402 embedder_pattern, 413 embedder_pattern,
403 type_, 414 type_,
404 std::string(), 415 std::string(),
405 content_setting); 416 content_setting);
406 } 417 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698