OLD | NEW |
---|---|
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" | |
10 #include "chrome/browser/infobars/infobar_service.h" | 9 #include "chrome/browser/infobars/infobar_service.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" | |
13 #include "chrome/browser/notifications/notification_permission_infobar_delegate. h" | |
14 #include "chrome/browser/permissions/permission_infobar_delegate.h" | 10 #include "chrome/browser/permissions/permission_infobar_delegate.h" |
15 #include "chrome/browser/permissions/permission_request.h" | 11 #include "chrome/browser/permissions/permission_request.h" |
16 #include "chrome/browser/permissions/permission_request_id.h" | 12 #include "chrome/browser/permissions/permission_request_id.h" |
17 #include "chrome/browser/permissions/permission_uma_util.h" | 13 #include "chrome/browser/permissions/permission_uma_util.h" |
18 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
19 #include "chrome/browser/tab_contents/tab_util.h" | 15 #include "chrome/browser/tab_contents/tab_util.h" |
20 #include "components/content_settings/core/browser/host_content_settings_map.h" | 16 #include "components/content_settings/core/browser/host_content_settings_map.h" |
21 #include "components/content_settings/core/common/content_settings.h" | 17 #include "components/content_settings/core/common/content_settings.h" |
22 #include "components/infobars/core/infobar.h" | 18 #include "components/infobars/core/infobar.h" |
23 #include "content/public/browser/browser_thread.h" | 19 #include "content/public/browser/browser_thread.h" |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
116 | 112 |
117 void PermissionQueueController::PendingInfobarRequest::CreateInfoBar( | 113 void PermissionQueueController::PendingInfobarRequest::CreateInfoBar( |
118 PermissionQueueController* controller) { | 114 PermissionQueueController* controller) { |
119 // Controller can be Unretained because the lifetime of the infobar | 115 // Controller can be Unretained because the lifetime of the infobar |
120 // is tied to that of the queue controller. Before QueueController | 116 // is tied to that of the queue controller. Before QueueController |
121 // is destroyed, all requests will be cancelled and so all delegates | 117 // is destroyed, all requests will be cancelled and so all delegates |
122 // will be destroyed. | 118 // will be destroyed. |
123 PermissionInfoBarDelegate::PermissionSetCallback callback = base::Bind( | 119 PermissionInfoBarDelegate::PermissionSetCallback callback = base::Bind( |
124 &PermissionQueueController::OnPermissionSet, base::Unretained(controller), | 120 &PermissionQueueController::OnPermissionSet, base::Unretained(controller), |
125 id_, requesting_frame_, embedder_, user_gesture_); | 121 id_, requesting_frame_, embedder_, user_gesture_); |
126 switch (type_) { | 122 |
127 case content::PermissionType::GEOLOCATION: | 123 DCHECK(type_ == content::PermissionType::GEOLOCATION || |
128 infobar_ = GeolocationInfoBarDelegateAndroid::Create( | 124 type_ == content::PermissionType::NOTIFICATIONS || |
129 GetInfoBarService(id_), requesting_frame_, user_gesture_, profile_, | 125 type_ == content::PermissionType::PUSH_MESSAGING || |
130 callback); | 126 type_ == content::PermissionType::MIDI_SYSEX || |
131 break; | 127 type_ == content::PermissionType::PROTECTED_MEDIA_IDENTIFIER); |
raymes
2016/10/24 01:00:36
nit: I'm not sure this is necessary as we should h
dominickn
2016/10/24 01:42:00
Done.
| |
132 #if defined(ENABLE_NOTIFICATIONS) | 128 infobar_ = PermissionInfoBarDelegate::Create(type_, GetInfoBarService(id_), |
133 case content::PermissionType::NOTIFICATIONS: | 129 requesting_frame_, user_gesture_, |
134 case content::PermissionType::PUSH_MESSAGING: | 130 profile_, callback); |
135 infobar_ = NotificationPermissionInfoBarDelegate::Create( | |
136 GetInfoBarService(id_), requesting_frame_, user_gesture_, profile_, | |
137 callback); | |
138 break; | |
139 #endif // ENABLE_NOTIFICATIONS | |
140 case content::PermissionType::MIDI_SYSEX: | |
141 infobar_ = MidiPermissionInfoBarDelegateAndroid::Create( | |
142 GetInfoBarService(id_), requesting_frame_, user_gesture_, profile_, | |
143 callback); | |
144 break; | |
145 case content::PermissionType::PROTECTED_MEDIA_IDENTIFIER: | |
146 infobar_ = ProtectedMediaIdentifierInfoBarDelegateAndroid::Create( | |
147 GetInfoBarService(id_), requesting_frame_, user_gesture_, profile_, | |
148 callback); | |
149 break; | |
150 default: | |
151 NOTREACHED(); | |
152 break; | |
153 } | |
154 } | 131 } |
155 | 132 |
156 PermissionQueueController::PermissionQueueController( | 133 PermissionQueueController::PermissionQueueController( |
157 Profile* profile, | 134 Profile* profile, |
158 content::PermissionType permission_type, | 135 content::PermissionType permission_type, |
159 ContentSettingsType content_settings_type) | 136 ContentSettingsType content_settings_type) |
160 : profile_(profile), | 137 : profile_(profile), |
161 permission_type_(permission_type), | 138 permission_type_(permission_type), |
162 content_settings_type_(content_settings_type), | 139 content_settings_type_(content_settings_type), |
163 in_shutdown_(false) {} | 140 in_shutdown_(false) {} |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
413 } | 390 } |
414 | 391 |
415 ContentSetting content_setting = | 392 ContentSetting content_setting = |
416 (decision == GRANTED) ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK; | 393 (decision == GRANTED) ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK; |
417 | 394 |
418 HostContentSettingsMapFactory::GetForProfile(profile_) | 395 HostContentSettingsMapFactory::GetForProfile(profile_) |
419 ->SetContentSettingDefaultScope( | 396 ->SetContentSettingDefaultScope( |
420 requesting_frame.GetOrigin(), embedder.GetOrigin(), | 397 requesting_frame.GetOrigin(), embedder.GetOrigin(), |
421 content_settings_type_, std::string(), content_setting); | 398 content_settings_type_, std::string(), content_setting); |
422 } | 399 } |
OLD | NEW |