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/media/desktop_streams_registry.h" | 9 #include "chrome/browser/media/desktop_streams_registry.h" |
10 #include "chrome/browser/media/media_capture_devices_dispatcher.h" | 10 #include "chrome/browser/media/media_capture_devices_dispatcher.h" |
11 #include "content/public/browser/browser_thread.h" | 11 #include "content/public/browser/browser_thread.h" |
12 #include "third_party/webrtc/modules/desktop_capture/screen_capturer.h" | 12 #include "third_party/webrtc/modules/desktop_capture/screen_capturer.h" |
13 #include "third_party/webrtc/modules/desktop_capture/window_capturer.h" | 13 #include "third_party/webrtc/modules/desktop_capture/window_capturer.h" |
14 | 14 |
15 namespace extensions { | 15 namespace extensions { |
16 | 16 |
17 namespace { | 17 namespace { |
18 | 18 |
19 const char kNotImplementedError[] = | |
20 "Desktop Capture API is not yet implemented for this platform."; | |
21 const char kInvalidSourceNameError[] = "Invalid source type specified."; | 19 const char kInvalidSourceNameError[] = "Invalid source type specified."; |
22 const char kEmptySourcesListError[] = | 20 const char kEmptySourcesListError[] = |
23 "At least one source type must be specified."; | 21 "At least one source type must be specified."; |
24 const char kTabCaptureNotSupportedError[] = "Tab capture is not supported yet."; | 22 const char kTabCaptureNotSupportedError[] = "Tab capture is not supported yet."; |
25 | 23 |
26 DesktopCaptureChooseDesktopMediaFunction::PickerFactory* g_picker_factory = | 24 DesktopCaptureChooseDesktopMediaFunction::PickerFactory* g_picker_factory = |
27 NULL; | 25 NULL; |
28 | 26 |
29 } // namespace | 27 } // namespace |
30 | 28 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 screen_capturer.Pass(), window_capturer.Pass()); | 92 screen_capturer.Pass(), window_capturer.Pass()); |
95 picker_ = g_picker_factory->CreatePicker(); | 93 picker_ = g_picker_factory->CreatePicker(); |
96 } else { | 94 } else { |
97 // DesktopMediaPicker is implemented only for Windows, OSX and | 95 // DesktopMediaPicker is implemented only for Windows, OSX and |
98 // Aura Linux builds. | 96 // Aura Linux builds. |
99 #if (defined(TOOLKIT_VIEWS) && !defined(OS_CHROMEOS)) || defined(OS_MACOSX) | 97 #if (defined(TOOLKIT_VIEWS) && !defined(OS_CHROMEOS)) || defined(OS_MACOSX) |
100 model.reset(new DesktopMediaPickerModelImpl( | 98 model.reset(new DesktopMediaPickerModelImpl( |
101 screen_capturer.Pass(), window_capturer.Pass())); | 99 screen_capturer.Pass(), window_capturer.Pass())); |
102 picker_ = DesktopMediaPicker::Create(); | 100 picker_ = DesktopMediaPicker::Create(); |
103 #else | 101 #else |
| 102 const char kNotImplementedError[] = |
| 103 "Desktop Capture API is not yet implemented for this platform."; |
104 error_ = kNotImplementedError; | 104 error_ = kNotImplementedError; |
105 return false; | 105 return false; |
106 #endif | 106 #endif |
107 } | 107 } |
108 DesktopMediaPicker::DoneCallback callback = base::Bind( | 108 DesktopMediaPicker::DoneCallback callback = base::Bind( |
109 &DesktopCaptureChooseDesktopMediaFunction::OnPickerDialogResults, this); | 109 &DesktopCaptureChooseDesktopMediaFunction::OnPickerDialogResults, this); |
110 picker_->Show(NULL, NULL, UTF8ToUTF16(GetExtension()->name()), | 110 picker_->Show(NULL, NULL, UTF8ToUTF16(GetExtension()->name()), |
111 model.Pass(), callback); | 111 model.Pass(), callback); |
112 return true; | 112 return true; |
113 } | 113 } |
114 | 114 |
115 void DesktopCaptureChooseDesktopMediaFunction::OnPickerDialogResults( | 115 void DesktopCaptureChooseDesktopMediaFunction::OnPickerDialogResults( |
116 content::DesktopMediaID source) { | 116 content::DesktopMediaID source) { |
117 std::string result; | 117 std::string result; |
118 if (source.type != content::DesktopMediaID::TYPE_NONE) { | 118 if (source.type != content::DesktopMediaID::TYPE_NONE) { |
119 DesktopStreamsRegistry* registry = | 119 DesktopStreamsRegistry* registry = |
120 MediaCaptureDevicesDispatcher::GetInstance()-> | 120 MediaCaptureDevicesDispatcher::GetInstance()-> |
121 GetDesktopStreamsRegistry(); | 121 GetDesktopStreamsRegistry(); |
122 result = registry->RegisterStream(origin_, source); | 122 result = registry->RegisterStream(origin_, source); |
123 } | 123 } |
124 | 124 |
125 SetResult(new base::StringValue(result)); | 125 SetResult(new base::StringValue(result)); |
126 SendResponse(true); | 126 SendResponse(true); |
127 } | 127 } |
128 | 128 |
129 } // namespace extensions | 129 } // namespace extensions |
OLD | NEW |