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 // Implements the Chrome Extensions Tab Capture API. | 5 // Implements the Chrome Extensions Tab Capture API. |
6 | 6 |
7 #include "chrome/browser/extensions/api/tab_capture/tab_capture_api.h" | 7 #include "chrome/browser/extensions/api/tab_capture/tab_capture_api.h" |
8 | 8 |
9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 constraints.push_back(params->options.video_constraints.get()); | 99 constraints.push_back(params->options.video_constraints.get()); |
100 } | 100 } |
101 | 101 |
102 // Device id we use for Tab Capture. | 102 // Device id we use for Tab Capture. |
103 std::string device_id = | 103 std::string device_id = |
104 base::StringPrintf("%i:%i", render_process_id, routing_id); | 104 base::StringPrintf("%i:%i", render_process_id, routing_id); |
105 | 105 |
106 // Append chrome specific tab constraints. | 106 // Append chrome specific tab constraints. |
107 for (std::vector<MediaStreamConstraint*>::iterator it = constraints.begin(); | 107 for (std::vector<MediaStreamConstraint*>::iterator it = constraints.begin(); |
108 it != constraints.end(); ++it) { | 108 it != constraints.end(); ++it) { |
109 base::DictionaryValue* constraint = &(*it)->mandatory.additional_properties; | 109 (*it)->mandatory.additional_properties[kMediaStreamSource] = |
110 constraint->SetString(kMediaStreamSource, kMediaStreamSourceTab); | 110 linked_ptr<base::Value>(new base::StringValue(kMediaStreamSourceTab)); |
111 constraint->SetString(kMediaStreamSourceId, device_id); | 111 (*it)->mandatory.additional_properties[kMediaStreamSourceId] = |
| 112 linked_ptr<base::Value>(new base::StringValue(device_id)); |
112 } | 113 } |
113 | 114 |
114 extensions::TabCaptureRegistry* registry = | 115 extensions::TabCaptureRegistry* registry = |
115 extensions::TabCaptureRegistryFactory::GetForProfile(profile()); | 116 extensions::TabCaptureRegistryFactory::GetForProfile(profile()); |
116 if (!registry->AddRequest( | 117 if (!registry->AddRequest( |
117 std::make_pair(render_process_id, routing_id), | 118 std::make_pair(render_process_id, routing_id), |
118 TabCaptureRegistry::TabCaptureRequest( | 119 TabCaptureRegistry::TabCaptureRequest( |
119 GetExtension()->id(), tab_id, | 120 GetExtension()->id(), |
120 tab_capture::TAB_CAPTURE_TAB_CAPTURE_STATE_NONE))) { | 121 tab_id, |
| 122 tab_capture::TAB_CAPTURE_STATE_NONE))) { |
121 error_ = kCapturingSameTab; | 123 error_ = kCapturingSameTab; |
122 return false; | 124 return false; |
123 } | 125 } |
124 | 126 |
125 // Copy the result from our modified input parameters. This will be | 127 // Copy the result from our modified input parameters. This will be |
126 // intercepted by custom bindings which will build and send the special | 128 // intercepted by custom bindings which will build and send the special |
127 // WebRTC user media request. | 129 // WebRTC user media request. |
128 base::DictionaryValue* result = new base::DictionaryValue(); | 130 base::DictionaryValue* result = new base::DictionaryValue(); |
129 result->MergeDictionary(params->options.ToValue().get()); | 131 result->MergeDictionary(params->options.ToValue().get()); |
130 | 132 |
(...skipping 20 matching lines...) Expand all Loading... |
151 info->tab_id = it->tab_id; | 153 info->tab_id = it->tab_id; |
152 info->status = it->status; | 154 info->status = it->status; |
153 list->Append(info->ToValue().release()); | 155 list->Append(info->ToValue().release()); |
154 } | 156 } |
155 | 157 |
156 SetResult(list); | 158 SetResult(list); |
157 return true; | 159 return true; |
158 } | 160 } |
159 | 161 |
160 } // namespace extensions | 162 } // namespace extensions |
OLD | NEW |