OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/media_stream_devices_controller.h" | 5 #include "chrome/browser/media/media_stream_devices_controller.h" |
6 | 6 |
7 #include "base/stringprintf.h" | |
7 #include "base/values.h" | 8 #include "base/values.h" |
8 #include "chrome/browser/content_settings/content_settings_provider.h" | 9 #include "chrome/browser/content_settings/content_settings_provider.h" |
9 #include "chrome/browser/content_settings/host_content_settings_map.h" | 10 #include "chrome/browser/content_settings/host_content_settings_map.h" |
10 #include "chrome/browser/extensions/api/tab_capture/tab_capture_registry.h" | 11 #include "chrome/browser/extensions/api/tab_capture/tab_capture_registry.h" |
11 #include "chrome/browser/extensions/api/tab_capture/tab_capture_registry_factory .h" | 12 #include "chrome/browser/extensions/api/tab_capture/tab_capture_registry_factory .h" |
12 #include "chrome/browser/media/media_capture_devices_dispatcher.h" | 13 #include "chrome/browser/media/media_capture_devices_dispatcher.h" |
13 #include "chrome/browser/media/media_internals.h" | 14 #include "chrome/browser/media/media_internals.h" |
14 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 15 #include "chrome/browser/prefs/scoped_user_pref_update.h" |
15 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
16 #include "chrome/browser/ui/browser.h" | 17 #include "chrome/browser/ui/browser.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
49 has_audio_(content::IsAudioMediaType(request->audio_type)), | 50 has_audio_(content::IsAudioMediaType(request->audio_type)), |
50 has_video_(content::IsVideoMediaType(request->video_type)) { | 51 has_video_(content::IsVideoMediaType(request->video_type)) { |
51 DCHECK(request); | 52 DCHECK(request); |
52 } | 53 } |
53 | 54 |
54 MediaStreamDevicesController::~MediaStreamDevicesController() {} | 55 MediaStreamDevicesController::~MediaStreamDevicesController() {} |
55 | 56 |
56 bool MediaStreamDevicesController::DismissInfoBarAndTakeActionOnSettings() { | 57 bool MediaStreamDevicesController::DismissInfoBarAndTakeActionOnSettings() { |
57 if (request_.audio_type == content::MEDIA_TAB_AUDIO_CAPTURE || | 58 if (request_.audio_type == content::MEDIA_TAB_AUDIO_CAPTURE || |
58 request_.video_type == content::MEDIA_TAB_VIDEO_CAPTURE) { | 59 request_.video_type == content::MEDIA_TAB_VIDEO_CAPTURE) { |
59 Accept(false); | 60 extensions::TabCaptureRegistry* registry = |
61 extensions::TabCaptureRegistryFactory::GetForProfile(profile_); | |
62 | |
63 std::string device_id = base::StringPrintf( | |
64 "%i:%i", request_.render_process_id, request_.render_view_id); | |
no longer working on chromium
2012/12/05 17:38:37
this code looks a bit odd, can you consider change
| |
65 | |
66 if (!registry->VerifyRequest(device_id)) { | |
67 Deny(); | |
68 } else { | |
69 content::MediaStreamDevices devices; | |
70 | |
71 if (request_.video_type == content::MEDIA_TAB_VIDEO_CAPTURE) { | |
72 devices.push_back(content::MediaStreamDevice( | |
73 content::MEDIA_TAB_VIDEO_CAPTURE, "", "")); | |
74 } | |
75 if (request_.audio_type == content::MEDIA_TAB_AUDIO_CAPTURE) { | |
76 devices.push_back(content::MediaStreamDevice( | |
77 content::MEDIA_TAB_AUDIO_CAPTURE, "", "")); | |
78 } | |
79 | |
80 callback_.Run(devices); | |
81 } | |
82 | |
83 return true; | |
60 } | 84 } |
61 | 85 |
62 // Deny the request if the security origin is empty, this happens with | 86 // Deny the request if the security origin is empty, this happens with |
63 // file access without |--allow-file-access-from-files| flag. | 87 // file access without |--allow-file-access-from-files| flag. |
64 if (request_.security_origin.is_empty()) { | 88 if (request_.security_origin.is_empty()) { |
65 Deny(); | 89 Deny(); |
66 return true; | 90 return true; |
67 } | 91 } |
68 | 92 |
69 // Deny the request if there is no device attached to the OS. | 93 // Deny the request if there is no device attached to the OS. |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
197 | 221 |
198 ContentSettingsPattern primary_pattern = | 222 ContentSettingsPattern primary_pattern = |
199 ContentSettingsPattern::FromURLNoWildcard(request_.security_origin); | 223 ContentSettingsPattern::FromURLNoWildcard(request_.security_origin); |
200 profile_->GetHostContentSettingsMap()->SetWebsiteSetting( | 224 profile_->GetHostContentSettingsMap()->SetWebsiteSetting( |
201 primary_pattern, | 225 primary_pattern, |
202 ContentSettingsPattern::Wildcard(), | 226 ContentSettingsPattern::Wildcard(), |
203 CONTENT_SETTINGS_TYPE_MEDIASTREAM, | 227 CONTENT_SETTINGS_TYPE_MEDIASTREAM, |
204 NO_RESOURCE_IDENTIFIER, | 228 NO_RESOURCE_IDENTIFIER, |
205 dictionary_value); | 229 dictionary_value); |
206 } | 230 } |
OLD | NEW |