| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_base.h" | 5 #include "chrome/browser/extensions/api/desktop_capture/desktop_capture_base.h" |
| 6 | 6 |
| 7 #include <tuple> | 7 #include <tuple> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
| 12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
| 13 #include "build/build_config.h" | 13 #include "build/build_config.h" |
| 14 #include "chrome/browser/extensions/extension_tab_util.h" | 14 #include "chrome/browser/extensions/extension_tab_util.h" |
| 15 #include "chrome/browser/media/webrtc/desktop_media_list_ash.h" | 15 #include "chrome/browser/media/webrtc/desktop_media_list_ash.h" |
| 16 #include "chrome/browser/media/webrtc/desktop_streams_registry.h" | 16 #include "chrome/browser/media/webrtc/desktop_streams_registry.h" |
| 17 #include "chrome/browser/media/webrtc/media_capture_devices_dispatcher.h" | 17 #include "chrome/browser/media/webrtc/media_capture_devices_dispatcher.h" |
| 18 #include "chrome/browser/media/webrtc/native_desktop_media_list.h" | 18 #include "chrome/browser/media/webrtc/native_desktop_media_list.h" |
| 19 #include "chrome/browser/media/webrtc/tab_desktop_media_list.h" | 19 #include "chrome/browser/media/webrtc/tab_desktop_media_list.h" |
| 20 #include "chrome/browser/ui/browser_finder.h" |
| 21 #include "chrome/browser/ui/browser_window.h" |
| 20 #include "chrome/grit/chromium_strings.h" | 22 #include "chrome/grit/chromium_strings.h" |
| 21 #include "content/public/browser/render_frame_host.h" | 23 #include "content/public/browser/render_frame_host.h" |
| 22 #include "content/public/browser/render_process_host.h" | 24 #include "content/public/browser/render_process_host.h" |
| 23 #include "content/public/browser/web_contents.h" | 25 #include "content/public/browser/web_contents.h" |
| 24 #include "extensions/common/manifest.h" | 26 #include "extensions/common/manifest.h" |
| 25 #include "extensions/common/switches.h" | 27 #include "extensions/common/switches.h" |
| 26 #include "third_party/webrtc/modules/desktop_capture/desktop_capture_options.h" | 28 #include "third_party/webrtc/modules/desktop_capture/desktop_capture_options.h" |
| 27 #include "third_party/webrtc/modules/desktop_capture/screen_capturer.h" | 29 #include "third_party/webrtc/modules/desktop_capture/screen_capturer.h" |
| 28 #include "third_party/webrtc/modules/desktop_capture/window_capturer.h" | 30 #include "third_party/webrtc/modules/desktop_capture/window_capturer.h" |
| 29 #include "ui/base/l10n/l10n_util.h" | 31 #include "ui/base/l10n/l10n_util.h" |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 request_audio = !has_flag; | 113 request_audio = !has_flag; |
| 112 break; | 114 break; |
| 113 } | 115 } |
| 114 } | 116 } |
| 115 | 117 |
| 116 if (!show_screens && !show_windows && !show_tabs) { | 118 if (!show_screens && !show_windows && !show_tabs) { |
| 117 error_ = kEmptySourcesListError; | 119 error_ = kEmptySourcesListError; |
| 118 return false; | 120 return false; |
| 119 } | 121 } |
| 120 | 122 |
| 121 const gfx::NativeWindow parent_window = | 123 gfx::NativeWindow parent_window = web_contents->GetTopLevelNativeWindow(); |
| 122 web_contents->GetTopLevelNativeWindow(); | 124 // In case of coming from background extension page, |parent_window| will |
| 125 // be null. We are going to make the picker modal to the current browser |
| 126 // window. |
| 127 if (!parent_window) { |
| 128 Browser* target_browser = chrome::FindLastActiveWithProfile( |
| 129 Profile::FromBrowserContext(web_contents->GetBrowserContext())); |
| 130 |
| 131 if (target_browser) |
| 132 parent_window = target_browser->window()->GetNativeWindow(); |
| 133 } |
| 123 std::unique_ptr<DesktopMediaList> screen_list; | 134 std::unique_ptr<DesktopMediaList> screen_list; |
| 124 std::unique_ptr<DesktopMediaList> window_list; | 135 std::unique_ptr<DesktopMediaList> window_list; |
| 125 std::unique_ptr<DesktopMediaList> tab_list; | 136 std::unique_ptr<DesktopMediaList> tab_list; |
| 126 if (g_picker_factory) { | 137 if (g_picker_factory) { |
| 127 PickerFactory::MediaListArray media_lists = | 138 PickerFactory::MediaListArray media_lists = |
| 128 g_picker_factory->CreateModel(show_screens, show_windows, show_tabs, | 139 g_picker_factory->CreateModel(show_screens, show_windows, show_tabs, |
| 129 request_audio); | 140 request_audio); |
| 130 screen_list = std::move(media_lists[0]); | 141 screen_list = std::move(media_lists[0]); |
| 131 window_list = std::move(media_lists[1]); | 142 window_list = std::move(media_lists[1]); |
| 132 tab_list = std::move(media_lists[2]); | 143 tab_list = std::move(media_lists[2]); |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 | 296 |
| 286 void DesktopCaptureRequestsRegistry::CancelRequest(int process_id, | 297 void DesktopCaptureRequestsRegistry::CancelRequest(int process_id, |
| 287 int request_id) { | 298 int request_id) { |
| 288 RequestsMap::iterator it = requests_.find(RequestId(process_id, request_id)); | 299 RequestsMap::iterator it = requests_.find(RequestId(process_id, request_id)); |
| 289 if (it != requests_.end()) | 300 if (it != requests_.end()) |
| 290 it->second->Cancel(); | 301 it->second->Cancel(); |
| 291 } | 302 } |
| 292 | 303 |
| 293 | 304 |
| 294 } // namespace extensions | 305 } // namespace extensions |
| OLD | NEW |