| 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/extensions/api/desktop_capture/desktop_capture_api.h" | 5 #include "chrome/browser/extensions/api/desktop_capture/desktop_capture_api.h" |
| 6 | 6 |
| 7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "chrome/browser/extensions/extension_tab_util.h" | 9 #include "chrome/browser/extensions/extension_tab_util.h" |
| 10 #include "chrome/browser/media/desktop_streams_registry.h" | 10 #include "chrome/browser/media/desktop_streams_registry.h" |
| 11 #include "chrome/browser/media/media_capture_devices_dispatcher.h" | 11 #include "chrome/browser/media/media_capture_devices_dispatcher.h" |
| 12 #include "chrome/browser/media/native_desktop_media_list.h" |
| 12 #include "chrome/common/extensions/api/tabs.h" | 13 #include "chrome/common/extensions/api/tabs.h" |
| 13 #include "content/public/browser/browser_thread.h" | 14 #include "content/public/browser/browser_thread.h" |
| 14 #include "content/public/browser/render_process_host.h" | 15 #include "content/public/browser/render_process_host.h" |
| 15 #include "content/public/browser/render_view_host.h" | 16 #include "content/public/browser/render_view_host.h" |
| 16 #include "content/public/browser/web_contents.h" | 17 #include "content/public/browser/web_contents.h" |
| 17 #include "content/public/browser/web_contents_view.h" | 18 #include "content/public/browser/web_contents_view.h" |
| 18 #include "third_party/webrtc/modules/desktop_capture/screen_capturer.h" | 19 #include "third_party/webrtc/modules/desktop_capture/screen_capturer.h" |
| 19 #include "third_party/webrtc/modules/desktop_capture/window_capturer.h" | 20 #include "third_party/webrtc/modules/desktop_capture/window_capturer.h" |
| 20 | 21 |
| 21 namespace extensions { | 22 namespace extensions { |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 error_ = kTabCaptureNotSupportedError; | 154 error_ = kTabCaptureNotSupportedError; |
| 154 return false; | 155 return false; |
| 155 } | 156 } |
| 156 } | 157 } |
| 157 | 158 |
| 158 if (!screen_capturer && !window_capturer) { | 159 if (!screen_capturer && !window_capturer) { |
| 159 error_ = kEmptySourcesListError; | 160 error_ = kEmptySourcesListError; |
| 160 return false; | 161 return false; |
| 161 } | 162 } |
| 162 | 163 |
| 163 scoped_ptr<DesktopMediaPickerModel> model; | 164 scoped_ptr<DesktopMediaList> media_list; |
| 164 if (g_picker_factory) { | 165 if (g_picker_factory) { |
| 165 model = g_picker_factory->CreateModel( | 166 media_list = g_picker_factory->CreateModel( |
| 166 screen_capturer.Pass(), window_capturer.Pass()); | 167 screen_capturer.Pass(), window_capturer.Pass()); |
| 167 picker_ = g_picker_factory->CreatePicker(); | 168 picker_ = g_picker_factory->CreatePicker(); |
| 168 } else { | 169 } else { |
| 169 // DesktopMediaPicker is implemented only for Windows, OSX and | 170 // DesktopMediaPicker is implemented only for Windows, OSX and |
| 170 // Aura Linux builds. | 171 // Aura Linux builds. |
| 171 #if (defined(TOOLKIT_VIEWS) && !defined(OS_CHROMEOS)) || defined(OS_MACOSX) | 172 #if (defined(TOOLKIT_VIEWS) && !defined(OS_CHROMEOS)) || defined(OS_MACOSX) |
| 172 model.reset(new DesktopMediaPickerModelImpl( | 173 media_list.reset(new NativeDesktopMediaList( |
| 173 screen_capturer.Pass(), window_capturer.Pass())); | 174 screen_capturer.Pass(), window_capturer.Pass())); |
| 174 picker_ = DesktopMediaPicker::Create(); | 175 picker_ = DesktopMediaPicker::Create(); |
| 175 #else | 176 #else |
| 176 const char kNotImplementedError[] = | 177 const char kNotImplementedError[] = |
| 177 "Desktop Capture API is not yet implemented for this platform."; | 178 "Desktop Capture API is not yet implemented for this platform."; |
| 178 error_ = kNotImplementedError; | 179 error_ = kNotImplementedError; |
| 179 return false; | 180 return false; |
| 180 #endif | 181 #endif |
| 181 } | 182 } |
| 182 DesktopMediaPicker::DoneCallback callback = base::Bind( | 183 DesktopMediaPicker::DoneCallback callback = base::Bind( |
| 183 &DesktopCaptureChooseDesktopMediaFunction::OnPickerDialogResults, this); | 184 &DesktopCaptureChooseDesktopMediaFunction::OnPickerDialogResults, this); |
| 184 | 185 |
| 185 picker_->Show(parent_window, parent_window, | 186 picker_->Show(parent_window, parent_window, |
| 186 UTF8ToUTF16(GetExtension()->name()), | 187 UTF8ToUTF16(GetExtension()->name()), |
| 187 model.Pass(), callback); | 188 media_list.Pass(), callback); |
| 188 return true; | 189 return true; |
| 189 } | 190 } |
| 190 | 191 |
| 191 void DesktopCaptureChooseDesktopMediaFunction::OnPickerDialogResults( | 192 void DesktopCaptureChooseDesktopMediaFunction::OnPickerDialogResults( |
| 192 content::DesktopMediaID source) { | 193 content::DesktopMediaID source) { |
| 193 std::string result; | 194 std::string result; |
| 194 if (source.type != content::DesktopMediaID::TYPE_NONE) { | 195 if (source.type != content::DesktopMediaID::TYPE_NONE) { |
| 195 DesktopStreamsRegistry* registry = | 196 DesktopStreamsRegistry* registry = |
| 196 MediaCaptureDevicesDispatcher::GetInstance()-> | 197 MediaCaptureDevicesDispatcher::GetInstance()-> |
| 197 GetDesktopStreamsRegistry(); | 198 GetDesktopStreamsRegistry(); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 | 257 |
| 257 void DesktopCaptureRequestsRegistry::CancelRequest(int process_id, | 258 void DesktopCaptureRequestsRegistry::CancelRequest(int process_id, |
| 258 int request_id) { | 259 int request_id) { |
| 259 RequestsMap::iterator it = requests_.find(RequestId(process_id, request_id)); | 260 RequestsMap::iterator it = requests_.find(RequestId(process_id, request_id)); |
| 260 if (it != requests_.end()) | 261 if (it != requests_.end()) |
| 261 it->second->Cancel(); | 262 it->second->Cancel(); |
| 262 } | 263 } |
| 263 | 264 |
| 264 | 265 |
| 265 } // namespace extensions | 266 } // namespace extensions |
| OLD | NEW |