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

Side by Side Diff: chrome/browser/permissions/permission_queue_controller.cc

Issue 2250053002: Clean up the PermissionInfoBarDelegate hierarchy. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@permission-infobar-remember-decision
Patch Set: Created 4 years, 4 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 "chrome/browser/chrome_notification_types.h" 7 #include "chrome/browser/chrome_notification_types.h"
8 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" 8 #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
9 #include "chrome/browser/geolocation/geolocation_infobar_delegate_android.h" 9 #include "chrome/browser/geolocation/geolocation_infobar_delegate_android.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_android.h" 11 #include "chrome/browser/media/midi_permission_infobar_delegate_android.h"
12 #include "chrome/browser/media/protected_media_identifier_infobar_delegate_andro id.h" 12 #include "chrome/browser/media/protected_media_identifier_infobar_delegate_andro id.h"
13 #include "chrome/browser/notifications/notification_permission_infobar_delegate. h" 13 #include "chrome/browser/notifications/notification_permission_infobar_delegate. h"
14 #include "chrome/browser/permissions/permission_infobar_delegate.h"
14 #include "chrome/browser/permissions/permission_request.h" 15 #include "chrome/browser/permissions/permission_request.h"
15 #include "chrome/browser/permissions/permission_request_id.h" 16 #include "chrome/browser/permissions/permission_request_id.h"
16 #include "chrome/browser/permissions/permission_uma_util.h" 17 #include "chrome/browser/permissions/permission_uma_util.h"
17 #include "chrome/browser/profiles/profile.h" 18 #include "chrome/browser/profiles/profile.h"
18 #include "chrome/browser/tab_contents/tab_util.h" 19 #include "chrome/browser/tab_contents/tab_util.h"
19 #include "components/content_settings/core/browser/host_content_settings_map.h" 20 #include "components/content_settings/core/browser/host_content_settings_map.h"
20 #include "components/content_settings/core/common/content_settings.h" 21 #include "components/content_settings/core/common/content_settings.h"
21 #include "components/infobars/core/infobar.h" 22 #include "components/infobars/core/infobar.h"
22 #include "content/public/browser/browser_thread.h" 23 #include "content/public/browser/browser_thread.h"
23 #include "content/public/browser/notification_details.h" 24 #include "content/public/browser/notification_details.h"
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 ContentSetting content_setting) { 113 ContentSetting content_setting) {
113 callback_.Run(content_setting); 114 callback_.Run(content_setting);
114 } 115 }
115 116
116 void PermissionQueueController::PendingInfobarRequest::CreateInfoBar( 117 void PermissionQueueController::PendingInfobarRequest::CreateInfoBar(
117 PermissionQueueController* controller) { 118 PermissionQueueController* controller) {
118 // Controller can be Unretained because the lifetime of the infobar 119 // Controller can be Unretained because the lifetime of the infobar
119 // is tied to that of the queue controller. Before QueueController 120 // is tied to that of the queue controller. Before QueueController
120 // is destroyed, all requests will be cancelled and so all delegates 121 // is destroyed, all requests will be cancelled and so all delegates
121 // will be destroyed. 122 // will be destroyed.
122 PermissionInfobarDelegate::PermissionSetCallback callback = base::Bind( 123 PermissionInfoBarDelegate::PermissionSetCallback callback = base::Bind(
123 &PermissionQueueController::OnPermissionSet, base::Unretained(controller), 124 &PermissionQueueController::OnPermissionSet, base::Unretained(controller),
124 id_, requesting_frame_, embedder_, user_gesture_); 125 id_, requesting_frame_, embedder_, user_gesture_);
125 switch (type_) { 126 switch (type_) {
126 case content::PermissionType::GEOLOCATION: 127 case content::PermissionType::GEOLOCATION:
127 infobar_ = GeolocationInfoBarDelegateAndroid::Create( 128 infobar_ = GeolocationInfoBarDelegateAndroid::Create(
128 GetInfoBarService(id_), requesting_frame_, user_gesture_, profile_, 129 GetInfoBarService(id_), requesting_frame_, user_gesture_, profile_,
129 callback); 130 callback);
130 break; 131 break;
131 #if defined(ENABLE_NOTIFICATIONS) 132 #if defined(ENABLE_NOTIFICATIONS)
132 case content::PermissionType::NOTIFICATIONS: 133 case content::PermissionType::NOTIFICATIONS:
133 infobar_ = NotificationPermissionInfobarDelegate::Create( 134 infobar_ = NotificationPermissionInfoBarDelegate::Create(
134 GetInfoBarService(id_), requesting_frame_, user_gesture_, profile_, 135 GetInfoBarService(id_), requesting_frame_, user_gesture_, profile_,
135 callback); 136 callback);
136 break; 137 break;
137 #endif // ENABLE_NOTIFICATIONS 138 #endif // ENABLE_NOTIFICATIONS
138 case content::PermissionType::MIDI_SYSEX: 139 case content::PermissionType::MIDI_SYSEX:
139 infobar_ = MidiPermissionInfoBarDelegateAndroid::Create( 140 infobar_ = MidiPermissionInfoBarDelegateAndroid::Create(
140 GetInfoBarService(id_), requesting_frame_, user_gesture_, profile_, 141 GetInfoBarService(id_), requesting_frame_, user_gesture_, profile_,
141 callback); 142 callback);
142 break; 143 break;
143 case content::PermissionType::PROTECTED_MEDIA_IDENTIFIER: 144 case content::PermissionType::PROTECTED_MEDIA_IDENTIFIER:
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 } 412 }
412 413
413 ContentSetting content_setting = 414 ContentSetting content_setting =
414 (decision == GRANTED) ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK; 415 (decision == GRANTED) ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK;
415 416
416 HostContentSettingsMapFactory::GetForProfile(profile_) 417 HostContentSettingsMapFactory::GetForProfile(profile_)
417 ->SetContentSettingDefaultScope( 418 ->SetContentSettingDefaultScope(
418 requesting_frame.GetOrigin(), embedder.GetOrigin(), 419 requesting_frame.GetOrigin(), embedder.GetOrigin(),
419 content_settings_type_, std::string(), content_setting); 420 content_settings_type_, std::string(), content_setting);
420 } 421 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698