| 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_media_list_ash.h" |
| 10 #include "chrome/browser/media/desktop_streams_registry.h" | 11 #include "chrome/browser/media/desktop_streams_registry.h" |
| 11 #include "chrome/browser/media/media_capture_devices_dispatcher.h" | 12 #include "chrome/browser/media/media_capture_devices_dispatcher.h" |
| 12 #include "chrome/browser/media/native_desktop_media_list.h" | 13 #include "chrome/browser/media/native_desktop_media_list.h" |
| 14 #include "chrome/browser/ui/ash/ash_util.h" |
| 13 #include "chrome/common/extensions/api/tabs.h" | 15 #include "chrome/common/extensions/api/tabs.h" |
| 14 #include "content/public/browser/browser_thread.h" | 16 #include "content/public/browser/browser_thread.h" |
| 15 #include "content/public/browser/render_process_host.h" | 17 #include "content/public/browser/render_process_host.h" |
| 16 #include "content/public/browser/render_view_host.h" | 18 #include "content/public/browser/render_view_host.h" |
| 17 #include "content/public/browser/web_contents.h" | 19 #include "content/public/browser/web_contents.h" |
| 18 #include "content/public/browser/web_contents_view.h" | 20 #include "content/public/browser/web_contents_view.h" |
| 19 #include "third_party/webrtc/modules/desktop_capture/desktop_capture_options.h" | 21 #include "third_party/webrtc/modules/desktop_capture/desktop_capture_options.h" |
| 20 #include "third_party/webrtc/modules/desktop_capture/screen_capturer.h" | 22 #include "third_party/webrtc/modules/desktop_capture/screen_capturer.h" |
| 21 #include "third_party/webrtc/modules/desktop_capture/window_capturer.h" | 23 #include "third_party/webrtc/modules/desktop_capture/window_capturer.h" |
| 22 | 24 |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 error_ = kEmptySourcesListError; | 158 error_ = kEmptySourcesListError; |
| 157 return false; | 159 return false; |
| 158 } | 160 } |
| 159 | 161 |
| 160 scoped_ptr<DesktopMediaList> media_list; | 162 scoped_ptr<DesktopMediaList> media_list; |
| 161 if (g_picker_factory) { | 163 if (g_picker_factory) { |
| 162 media_list = g_picker_factory->CreateModel( | 164 media_list = g_picker_factory->CreateModel( |
| 163 show_screens, show_windows); | 165 show_screens, show_windows); |
| 164 picker_ = g_picker_factory->CreatePicker(); | 166 picker_ = g_picker_factory->CreatePicker(); |
| 165 } else { | 167 } else { |
| 168 #if defined(USE_ASH) |
| 169 if (chrome::IsNativeWindowInAsh(parent_window)) { |
| 170 media_list.reset(new DesktopMediaListAsh( |
| 171 (show_screens ? DesktopMediaListAsh::SCREENS : 0) | |
| 172 (show_windows ? DesktopMediaListAsh::WINDOWS : 0))); |
| 173 } else |
| 174 #endif |
| 175 { |
| 176 webrtc::DesktopCaptureOptions options = |
| 177 webrtc::DesktopCaptureOptions::CreateDefault(); |
| 178 options.set_disable_effects(false); |
| 179 scoped_ptr<webrtc::ScreenCapturer> screen_capturer( |
| 180 show_screens ? webrtc::ScreenCapturer::Create(options) : NULL); |
| 181 scoped_ptr<webrtc::WindowCapturer> window_capturer( |
| 182 show_windows ? webrtc::WindowCapturer::Create(options) : NULL); |
| 183 |
| 184 media_list.reset(new NativeDesktopMediaList( |
| 185 screen_capturer.Pass(), window_capturer.Pass())); |
| 186 } |
| 187 |
| 166 // DesktopMediaPicker is implemented only for Windows, OSX and | 188 // DesktopMediaPicker is implemented only for Windows, OSX and |
| 167 // Aura Linux builds. | 189 // Aura Linux builds. |
| 168 #if (defined(TOOLKIT_VIEWS) && !defined(OS_CHROMEOS)) || defined(OS_MACOSX) | 190 #if defined(TOOLKIT_VIEWS) || defined(OS_MACOSX) |
| 169 webrtc::DesktopCaptureOptions options = | |
| 170 webrtc::DesktopCaptureOptions::CreateDefault(); | |
| 171 options.set_disable_effects(false); | |
| 172 scoped_ptr<webrtc::ScreenCapturer> screen_capturer( | |
| 173 show_screens ? webrtc::ScreenCapturer::Create(options) : NULL); | |
| 174 scoped_ptr<webrtc::WindowCapturer> window_capturer( | |
| 175 show_windows ? webrtc::WindowCapturer::Create(options) : NULL); | |
| 176 | |
| 177 media_list.reset(new NativeDesktopMediaList( | |
| 178 screen_capturer.Pass(), window_capturer.Pass())); | |
| 179 picker_ = DesktopMediaPicker::Create(); | 191 picker_ = DesktopMediaPicker::Create(); |
| 180 #else | 192 #else |
| 181 error_ = "Desktop Capture API is not yet implemented for this platform."; | 193 error_ = "Desktop Capture API is not yet implemented for this platform."; |
| 182 return false; | 194 return false; |
| 183 #endif | 195 #endif |
| 184 } | 196 } |
| 185 DesktopMediaPicker::DoneCallback callback = base::Bind( | 197 DesktopMediaPicker::DoneCallback callback = base::Bind( |
| 186 &DesktopCaptureChooseDesktopMediaFunction::OnPickerDialogResults, this); | 198 &DesktopCaptureChooseDesktopMediaFunction::OnPickerDialogResults, this); |
| 187 | 199 |
| 188 picker_->Show(parent_window, parent_window, | 200 picker_->Show(parent_window, parent_window, |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 | 271 |
| 260 void DesktopCaptureRequestsRegistry::CancelRequest(int process_id, | 272 void DesktopCaptureRequestsRegistry::CancelRequest(int process_id, |
| 261 int request_id) { | 273 int request_id) { |
| 262 RequestsMap::iterator it = requests_.find(RequestId(process_id, request_id)); | 274 RequestsMap::iterator it = requests_.find(RequestId(process_id, request_id)); |
| 263 if (it != requests_.end()) | 275 if (it != requests_.end()) |
| 264 it->second->Cancel(); | 276 it->second->Cancel(); |
| 265 } | 277 } |
| 266 | 278 |
| 267 | 279 |
| 268 } // namespace extensions | 280 } // namespace extensions |
| OLD | NEW |