| 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/media/permission_bubble_media_access_handler.h" | 5 #include "chrome/browser/media/permission_bubble_media_access_handler.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/metrics/field_trial.h" | 9 #include "base/metrics/field_trial.h" |
| 10 #include "chrome/browser/media/media_permission.h" | 10 #include "chrome/browser/media/media_permission.h" |
| 11 #include "chrome/browser/media/media_stream_device_permissions.h" | 11 #include "chrome/browser/media/media_stream_device_permissions.h" |
| 12 #include "chrome/browser/media/media_stream_devices_controller.h" | 12 #include "chrome/browser/media/media_stream_devices_controller.h" |
| 13 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
| 14 #include "chrome/common/features.h" | 14 #include "chrome/common/features.h" |
| 15 #include "chrome/common/pref_names.h" | 15 #include "chrome/common/pref_names.h" |
| 16 #include "components/content_settings/core/browser/host_content_settings_map.h" | 16 #include "components/content_settings/core/browser/host_content_settings_map.h" |
| 17 #include "content/public/browser/browser_thread.h" | 17 #include "content/public/browser/browser_thread.h" |
| 18 #include "content/public/browser/notification_service.h" | 18 #include "content/public/browser/notification_service.h" |
| 19 #include "content/public/browser/notification_types.h" | 19 #include "content/public/browser/notification_types.h" |
| 20 #include "content/public/browser/web_contents.h" | 20 #include "content/public/browser/web_contents.h" |
| 21 | 21 |
| 22 #if BUILDFLAG(ANDROID_JAVA_UI) | 22 #if BUILDFLAG(ANDROID_JAVA_UI) |
| 23 #include <vector> | 23 #include <vector> |
| 24 | 24 |
| 25 #include "base/bind.h" | 25 #include "base/bind.h" |
| 26 #include "base/bind_helpers.h" | 26 #include "base/bind_helpers.h" |
| 27 #include "chrome/browser/media/media_stream_infobar_delegate_android.h" | 27 #include "chrome/browser/media/media_stream_infobar_delegate_android.h" |
| 28 #include "chrome/browser/permissions/permission_update_infobar_delegate_android.
h" | 28 #include "chrome/browser/permissions/permission_update_infobar_delegate_android.
h" |
| 29 #else | 29 #else |
| 30 #include "chrome/browser/ui/website_settings/permission_bubble_manager.h" | 30 #include "chrome/browser/permissions/permission_request_manager.h" |
| 31 #endif // BUILDFLAG(ANDROID_JAVA_UI) | 31 #endif // BUILDFLAG(ANDROID_JAVA_UI) |
| 32 | 32 |
| 33 #if BUILDFLAG(ANDROID_JAVA_UI) | 33 #if BUILDFLAG(ANDROID_JAVA_UI) |
| 34 namespace { | 34 namespace { |
| 35 // Callback for the permission update infobar when the site and Chrome | 35 // Callback for the permission update infobar when the site and Chrome |
| 36 // permissions are mismatched on Android. | 36 // permissions are mismatched on Android. |
| 37 void OnPermissionConflictResolved( | 37 void OnPermissionConflictResolved( |
| 38 std::unique_ptr<MediaStreamDevicesController> controller, | 38 std::unique_ptr<MediaStreamDevicesController> controller, |
| 39 bool allowed) { | 39 bool allowed) { |
| 40 if (allowed) | 40 if (allowed) |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 &OnPermissionConflictResolved, base::Passed(&controller))); | 156 &OnPermissionConflictResolved, base::Passed(&controller))); |
| 157 } | 157 } |
| 158 #endif | 158 #endif |
| 159 return; | 159 return; |
| 160 } | 160 } |
| 161 | 161 |
| 162 #if BUILDFLAG(ANDROID_JAVA_UI) | 162 #if BUILDFLAG(ANDROID_JAVA_UI) |
| 163 MediaStreamInfoBarDelegateAndroid::Create(web_contents, | 163 MediaStreamInfoBarDelegateAndroid::Create(web_contents, |
| 164 std::move(controller)); | 164 std::move(controller)); |
| 165 #else | 165 #else |
| 166 PermissionBubbleManager* bubble_manager = | 166 PermissionRequestManager* permission_request_manager = |
| 167 PermissionBubbleManager::FromWebContents(web_contents); | 167 PermissionRequestManager::FromWebContents(web_contents); |
| 168 if (bubble_manager) | 168 if (permission_request_manager) |
| 169 bubble_manager->AddRequest(controller.release()); | 169 permission_request_manager->AddRequest(controller.release()); |
| 170 #endif | 170 #endif |
| 171 } | 171 } |
| 172 | 172 |
| 173 void PermissionBubbleMediaAccessHandler::UpdateMediaRequestState( | 173 void PermissionBubbleMediaAccessHandler::UpdateMediaRequestState( |
| 174 int render_process_id, | 174 int render_process_id, |
| 175 int render_frame_id, | 175 int render_frame_id, |
| 176 int page_request_id, | 176 int page_request_id, |
| 177 content::MediaStreamType stream_type, | 177 content::MediaStreamType stream_type, |
| 178 content::MediaRequestState state) { | 178 content::MediaRequestState state) { |
| 179 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 179 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 | 235 |
| 236 void PermissionBubbleMediaAccessHandler::Observe( | 236 void PermissionBubbleMediaAccessHandler::Observe( |
| 237 int type, | 237 int type, |
| 238 const content::NotificationSource& source, | 238 const content::NotificationSource& source, |
| 239 const content::NotificationDetails& details) { | 239 const content::NotificationDetails& details) { |
| 240 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 240 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 241 DCHECK_EQ(content::NOTIFICATION_WEB_CONTENTS_DESTROYED, type); | 241 DCHECK_EQ(content::NOTIFICATION_WEB_CONTENTS_DESTROYED, type); |
| 242 | 242 |
| 243 pending_requests_.erase(content::Source<content::WebContents>(source).ptr()); | 243 pending_requests_.erase(content::Source<content::WebContents>(source).ptr()); |
| 244 } | 244 } |
| OLD | NEW |