| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_infobar_request.h" | 5 #include "chrome/browser/permissions/permission_infobar_request.h" |
| 6 | 6 |
| 7 #include "base/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
| 8 #include "chrome/browser/android/permissions/permission_group_infobar_delegate_a
ndroid.h" |
| 8 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" | 9 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
| 9 #include "chrome/browser/geolocation/geolocation_infobar_delegate.h" | 10 #include "chrome/browser/geolocation/geolocation_infobar_delegate.h" |
| 10 #include "chrome/browser/infobars/infobar_service.h" | 11 #include "chrome/browser/infobars/infobar_service.h" |
| 11 #include "chrome/browser/media/midi_permission_infobar_delegate.h" | 12 #include "chrome/browser/media/midi_permission_infobar_delegate.h" |
| 12 #include "chrome/browser/notifications/notification_permission_infobar_delegate.
h" | 13 #include "chrome/browser/notifications/notification_permission_infobar_delegate.
h" |
| 13 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 14 #include "chrome/browser/storage/durable_storage_permission_infobar_delegate.h" | 15 #include "chrome/browser/storage/durable_storage_permission_infobar_delegate.h" |
| 16 #include "chrome/browser/ui/android/infobars/permission_group_infobar_android.h" |
| 15 #include "chrome/common/pref_names.h" | 17 #include "chrome/common/pref_names.h" |
| 16 #include "components/content_settings/core/browser/host_content_settings_map.h" | 18 #include "components/content_settings/core/browser/host_content_settings_map.h" |
| 17 #include "components/infobars/core/infobar.h" | 19 #include "components/infobars/core/infobar.h" |
| 18 #include "content/public/browser/browser_thread.h" | 20 #include "content/public/browser/browser_thread.h" |
| 19 | 21 |
| 20 #if defined(OS_ANDROID) || defined(OS_CHROMEOS) | 22 #if defined(OS_ANDROID) || defined(OS_CHROMEOS) |
| 21 #include "chrome/browser/media/protected_media_identifier_infobar_delegate.h" | 23 #include "chrome/browser/media/protected_media_identifier_infobar_delegate.h" |
| 22 #endif | 24 #endif |
| 23 | 25 |
| 24 PermissionInfoBarRequest::PermissionRequest::PermissionRequest( | 26 PermissionInfoBarRequest::PermissionRequest::PermissionRequest( |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 if (requests_.size() == 1) { | 72 if (requests_.size() == 1) { |
| 71 CreateInfoBar( | 73 CreateInfoBar( |
| 72 infobar_service, | 74 infobar_service, |
| 73 requests_[0], | 75 requests_[0], |
| 74 display_languages, | 76 display_languages, |
| 75 base::Bind(&PermissionInfoBarRequest::OnPermissionSet, | 77 base::Bind(&PermissionInfoBarRequest::OnPermissionSet, |
| 76 weak_factory_.GetWeakPtr())); | 78 weak_factory_.GetWeakPtr())); |
| 77 return true; | 79 return true; |
| 78 } | 80 } |
| 79 | 81 |
| 80 // TODO(lalitm) once multiple permissions is ready to land, this | 82 std::vector<int> permissions; |
| 81 // should be implemented properly. | 83 permissions.reserve(requests_.size()); |
| 82 NOTIMPLEMENTED(); | 84 for (const auto& request : requests_) |
| 83 for (size_t i = 0; i < requests_.size(); ++i) | 85 permissions.push_back(request.type()); |
| 84 requests_[i].non_user_callback().Run(false, CONTENT_SETTING_DEFAULT); | 86 |
| 85 return false; | 87 scoped_ptr<PermissionGroupInfoBarDelegateAndroid> delegate( |
| 88 new PermissionGroupInfoBarDelegateAndroid( |
| 89 requesting_frame_, |
| 90 display_languages, |
| 91 base::Bind(&PermissionInfoBarRequest::OnPermissionsSet, |
| 92 weak_factory_.GetWeakPtr()))); |
| 93 infobar_ = infobar_service->AddInfoBar(make_scoped_ptr( |
| 94 new PermissionGroupInfoBarAndroid(delegate.Pass(), permissions))); |
| 95 DCHECK(infobar_); |
| 96 return infobar_; |
| 86 } | 97 } |
| 87 | 98 |
| 88 void PermissionInfoBarRequest::Cancel(bool allowed) { | 99 void PermissionInfoBarRequest::Cancel(bool allowed) { |
| 89 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 100 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 90 DCHECK(infobar_); | 101 DCHECK(infobar_); |
| 91 | 102 |
| 92 infobar_->RemoveSelf(); | 103 infobar_->RemoveSelf(); |
| 93 infobar_ = nullptr; | 104 infobar_ = nullptr; |
| 94 finished_callback_.Run(true); | 105 finished_callback_.Run(true); |
| 95 } | 106 } |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 case CONTENT_SETTINGS_TYPE_DURABLE_STORAGE: | 179 case CONTENT_SETTINGS_TYPE_DURABLE_STORAGE: |
| 169 infobar_ = DurableStoragePermissionInfoBarDelegate::Create( | 180 infobar_ = DurableStoragePermissionInfoBarDelegate::Create( |
| 170 infobar_service, requesting_frame_, | 181 infobar_service, requesting_frame_, |
| 171 display_languages, request.type(), callback); | 182 display_languages, request.type(), callback); |
| 172 break; | 183 break; |
| 173 default: | 184 default: |
| 174 NOTREACHED(); | 185 NOTREACHED(); |
| 175 break; | 186 break; |
| 176 } | 187 } |
| 177 } | 188 } |
| OLD | NEW |