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 "ash/shell.h" | 7 #include "ash/shell.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 error_ = kTabCaptureNotSupportedError; | 157 error_ = kTabCaptureNotSupportedError; |
158 return false; | 158 return false; |
159 } | 159 } |
160 } | 160 } |
161 | 161 |
162 if (!show_screens && !show_windows) { | 162 if (!show_screens && !show_windows) { |
163 error_ = kEmptySourcesListError; | 163 error_ = kEmptySourcesListError; |
164 return false; | 164 return false; |
165 } | 165 } |
166 | 166 |
167 const gfx::NativeWindow parent_window = | |
168 web_contents->GetTopLevelNativeWindow(); | |
169 scoped_ptr<DesktopMediaList> media_list; | 167 scoped_ptr<DesktopMediaList> media_list; |
170 if (g_picker_factory) { | 168 if (g_picker_factory) { |
171 media_list = g_picker_factory->CreateModel( | 169 media_list = g_picker_factory->CreateModel( |
172 show_screens, show_windows); | 170 show_screens, show_windows); |
173 picker_ = g_picker_factory->CreatePicker(); | 171 picker_ = g_picker_factory->CreatePicker(); |
174 } else { | 172 } else { |
175 #if defined(USE_ASH) | 173 #if defined(USE_ASH) |
176 if (chrome::IsNativeWindowInAsh(parent_window)) { | 174 if (chrome::IsNativeWindowInAsh(web_contents->GetTopLevelNativeWindow())) { |
177 media_list.reset(new DesktopMediaListAsh( | 175 media_list.reset(new DesktopMediaListAsh( |
178 (show_screens ? DesktopMediaListAsh::SCREENS : 0) | | 176 (show_screens ? DesktopMediaListAsh::SCREENS : 0) | |
179 (show_windows ? DesktopMediaListAsh::WINDOWS : 0))); | 177 (show_windows ? DesktopMediaListAsh::WINDOWS : 0))); |
180 } else | 178 } else |
181 #endif | 179 #endif |
182 { | 180 { |
183 webrtc::DesktopCaptureOptions options = | 181 webrtc::DesktopCaptureOptions options = |
184 webrtc::DesktopCaptureOptions::CreateDefault(); | 182 webrtc::DesktopCaptureOptions::CreateDefault(); |
185 options.set_disable_effects(false); | 183 options.set_disable_effects(false); |
186 scoped_ptr<webrtc::ScreenCapturer> screen_capturer( | 184 scoped_ptr<webrtc::ScreenCapturer> screen_capturer( |
(...skipping 11 matching lines...) Expand all Loading... |
198 picker_ = DesktopMediaPicker::Create(); | 196 picker_ = DesktopMediaPicker::Create(); |
199 #else | 197 #else |
200 error_ = "Desktop Capture API is not yet implemented for this platform."; | 198 error_ = "Desktop Capture API is not yet implemented for this platform."; |
201 return false; | 199 return false; |
202 #endif | 200 #endif |
203 } | 201 } |
204 DesktopMediaPicker::DoneCallback callback = base::Bind( | 202 DesktopMediaPicker::DoneCallback callback = base::Bind( |
205 &DesktopCaptureChooseDesktopMediaFunction::OnPickerDialogResults, this); | 203 &DesktopCaptureChooseDesktopMediaFunction::OnPickerDialogResults, this); |
206 | 204 |
207 picker_->Show(web_contents, | 205 picker_->Show(web_contents, |
208 parent_window, | |
209 parent_window, | |
210 base::UTF8ToUTF16(extension()->name()), | 206 base::UTF8ToUTF16(extension()->name()), |
211 target_name, | 207 target_name, |
212 media_list.Pass(), | 208 media_list.Pass(), |
213 callback); | 209 callback); |
214 return true; | 210 return true; |
215 } | 211 } |
216 | 212 |
217 void DesktopCaptureChooseDesktopMediaFunction::WebContentsDestroyed() { | 213 void DesktopCaptureChooseDesktopMediaFunction::WebContentsDestroyed() { |
218 Cancel(); | 214 Cancel(); |
219 } | 215 } |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 | 292 |
297 void DesktopCaptureRequestsRegistry::CancelRequest(int process_id, | 293 void DesktopCaptureRequestsRegistry::CancelRequest(int process_id, |
298 int request_id) { | 294 int request_id) { |
299 RequestsMap::iterator it = requests_.find(RequestId(process_id, request_id)); | 295 RequestsMap::iterator it = requests_.find(RequestId(process_id, request_id)); |
300 if (it != requests_.end()) | 296 if (it != requests_.end()) |
301 it->second->Cancel(); | 297 it->second->Cancel(); |
302 } | 298 } |
303 | 299 |
304 | 300 |
305 } // namespace extensions | 301 } // namespace extensions |
OLD | NEW |