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/content_settings/permission_queue_controller.h" | 5 #include "chrome/browser/content_settings/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/content_settings/host_content_settings_map.h" | 9 #include "chrome/browser/content_settings/host_content_settings_map.h" |
10 #include "chrome/browser/geolocation/geolocation_infobar_delegate.h" | 10 #include "chrome/browser/geolocation/geolocation_infobar_delegate.h" |
11 #include "chrome/browser/infobars/infobar.h" | |
12 #include "chrome/browser/infobars/infobar_service.h" | 11 #include "chrome/browser/infobars/infobar_service.h" |
13 #include "chrome/browser/media/midi_permission_infobar_delegate.h" | 12 #include "chrome/browser/media/midi_permission_infobar_delegate.h" |
14 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
15 #include "chrome/browser/tab_contents/tab_util.h" | 14 #include "chrome/browser/tab_contents/tab_util.h" |
16 #include "chrome/common/content_settings.h" | 15 #include "chrome/common/content_settings.h" |
17 #include "chrome/common/pref_names.h" | 16 #include "chrome/common/pref_names.h" |
| 17 #include "components/infobars/core/infobar.h" |
18 #include "content/public/browser/browser_thread.h" | 18 #include "content/public/browser/browser_thread.h" |
19 #include "content/public/browser/notification_details.h" | 19 #include "content/public/browser/notification_details.h" |
20 #include "content/public/browser/notification_source.h" | 20 #include "content/public/browser/notification_source.h" |
21 #include "content/public/browser/notification_types.h" | 21 #include "content/public/browser/notification_types.h" |
22 #include "content/public/browser/web_contents.h" | 22 #include "content/public/browser/web_contents.h" |
23 | 23 |
24 #if defined(OS_ANDROID) | 24 #if defined(OS_ANDROID) |
25 #include "chrome/browser/media/protected_media_identifier_infobar_delegate.h" | 25 #include "chrome/browser/media/protected_media_identifier_infobar_delegate.h" |
26 #endif | 26 #endif |
27 | 27 |
(...skipping 17 matching lines...) Expand all Loading... |
45 const std::string& accept_button_label, | 45 const std::string& accept_button_label, |
46 PermissionDecidedCallback callback); | 46 PermissionDecidedCallback callback); |
47 ~PendingInfobarRequest(); | 47 ~PendingInfobarRequest(); |
48 | 48 |
49 bool IsForPair(const GURL& requesting_frame, | 49 bool IsForPair(const GURL& requesting_frame, |
50 const GURL& embedder) const; | 50 const GURL& embedder) const; |
51 | 51 |
52 const PermissionRequestID& id() const { return id_; } | 52 const PermissionRequestID& id() const { return id_; } |
53 const GURL& requesting_frame() const { return requesting_frame_; } | 53 const GURL& requesting_frame() const { return requesting_frame_; } |
54 bool has_infobar() const { return !!infobar_; } | 54 bool has_infobar() const { return !!infobar_; } |
55 InfoBar* infobar() { return infobar_; } | 55 infobars::InfoBar* infobar() { return infobar_; } |
56 | 56 |
57 void RunCallback(bool allowed); | 57 void RunCallback(bool allowed); |
58 void CreateInfoBar(PermissionQueueController* controller, | 58 void CreateInfoBar(PermissionQueueController* controller, |
59 const std::string& display_languages); | 59 const std::string& display_languages); |
60 | 60 |
61 private: | 61 private: |
62 ContentSettingsType type_; | 62 ContentSettingsType type_; |
63 PermissionRequestID id_; | 63 PermissionRequestID id_; |
64 GURL requesting_frame_; | 64 GURL requesting_frame_; |
65 GURL embedder_; | 65 GURL embedder_; |
66 std::string accept_button_label_; | 66 std::string accept_button_label_; |
67 PermissionDecidedCallback callback_; | 67 PermissionDecidedCallback callback_; |
68 InfoBar* infobar_; | 68 infobars::InfoBar* infobar_; |
69 | 69 |
70 // Purposefully do not disable copying, as this is stored in STL containers. | 70 // Purposefully do not disable copying, as this is stored in STL containers. |
71 }; | 71 }; |
72 | 72 |
73 PermissionQueueController::PendingInfobarRequest::PendingInfobarRequest( | 73 PermissionQueueController::PendingInfobarRequest::PendingInfobarRequest( |
74 ContentSettingsType type, | 74 ContentSettingsType type, |
75 const PermissionRequestID& id, | 75 const PermissionRequestID& id, |
76 const GURL& requesting_frame, | 76 const GURL& requesting_frame, |
77 const GURL& embedder, | 77 const GURL& embedder, |
78 const std::string& accept_button_label, | 78 const std::string& accept_button_label, |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 DCHECK_EQ(chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, type); | 269 DCHECK_EQ(chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, type); |
270 // We will receive this notification for all infobar closures, so we need to | 270 // We will receive this notification for all infobar closures, so we need to |
271 // check whether this is the geolocation infobar we're tracking. Note that the | 271 // check whether this is the geolocation infobar we're tracking. Note that the |
272 // InfoBarContainer (if any) may have received this notification before us and | 272 // InfoBarContainer (if any) may have received this notification before us and |
273 // caused the infobar to be deleted, so it's not safe to dereference the | 273 // caused the infobar to be deleted, so it's not safe to dereference the |
274 // contents of the infobar. The address of the infobar, however, is OK to | 274 // contents of the infobar. The address of the infobar, however, is OK to |
275 // use to find the PendingInfobarRequest to remove because | 275 // use to find the PendingInfobarRequest to remove because |
276 // pending_infobar_requests_ will not have received any new entries between | 276 // pending_infobar_requests_ will not have received any new entries between |
277 // the NotificationService's call to InfoBarContainer::Observe and this | 277 // the NotificationService's call to InfoBarContainer::Observe and this |
278 // method. | 278 // method. |
279 InfoBar* infobar = content::Details<InfoBar::RemovedDetails>(details)->first; | 279 infobars::InfoBar* infobar = |
| 280 content::Details<infobars::InfoBar::RemovedDetails>(details)->first; |
280 for (PendingInfobarRequests::iterator i = pending_infobar_requests_.begin(); | 281 for (PendingInfobarRequests::iterator i = pending_infobar_requests_.begin(); |
281 i != pending_infobar_requests_.end(); ++i) { | 282 i != pending_infobar_requests_.end(); ++i) { |
282 if (i->infobar() == infobar) { | 283 if (i->infobar() == infobar) { |
283 PermissionRequestID id(i->id()); | 284 PermissionRequestID id(i->id()); |
284 pending_infobar_requests_.erase(i); | 285 pending_infobar_requests_.erase(i); |
285 ShowQueuedInfoBarForTab(id); | 286 ShowQueuedInfoBarForTab(id); |
286 return; | 287 return; |
287 } | 288 } |
288 } | 289 } |
289 } | 290 } |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
379 | 380 |
380 ContentSetting content_setting = | 381 ContentSetting content_setting = |
381 allowed ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK; | 382 allowed ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK; |
382 profile_->GetHostContentSettingsMap()->SetContentSetting( | 383 profile_->GetHostContentSettingsMap()->SetContentSetting( |
383 ContentSettingsPattern::FromURLNoWildcard(requesting_frame.GetOrigin()), | 384 ContentSettingsPattern::FromURLNoWildcard(requesting_frame.GetOrigin()), |
384 ContentSettingsPattern::FromURLNoWildcard(embedder.GetOrigin()), | 385 ContentSettingsPattern::FromURLNoWildcard(embedder.GetOrigin()), |
385 type_, | 386 type_, |
386 std::string(), | 387 std::string(), |
387 content_setting); | 388 content_setting); |
388 } | 389 } |
OLD | NEW |