Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(96)

Side by Side Diff: chrome/browser/extensions/api/desktop_capture/desktop_capture_base.cc

Issue 1871713002: Convert //chrome/browser/extensions from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase and fix header Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
12 #include "build/build_config.h" 13 #include "build/build_config.h"
13 #include "chrome/browser/extensions/extension_tab_util.h" 14 #include "chrome/browser/extensions/extension_tab_util.h"
14 #include "chrome/browser/media/combined_desktop_media_list.h" 15 #include "chrome/browser/media/combined_desktop_media_list.h"
15 #include "chrome/browser/media/desktop_media_list_ash.h" 16 #include "chrome/browser/media/desktop_media_list_ash.h"
16 #include "chrome/browser/media/desktop_streams_registry.h" 17 #include "chrome/browser/media/desktop_streams_registry.h"
17 #include "chrome/browser/media/media_capture_devices_dispatcher.h" 18 #include "chrome/browser/media/media_capture_devices_dispatcher.h"
18 #include "chrome/browser/media/native_desktop_media_list.h" 19 #include "chrome/browser/media/native_desktop_media_list.h"
19 #include "chrome/browser/media/tab_desktop_media_list.h" 20 #include "chrome/browser/media/tab_desktop_media_list.h"
20 #include "chrome/browser/ui/ash/ash_util.h" 21 #include "chrome/browser/ui/ash/ash_util.h"
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 } 120 }
120 } 121 }
121 122
122 if (!show_screens && !show_windows && !show_tabs) { 123 if (!show_screens && !show_windows && !show_tabs) {
123 error_ = kEmptySourcesListError; 124 error_ = kEmptySourcesListError;
124 return false; 125 return false;
125 } 126 }
126 127
127 const gfx::NativeWindow parent_window = 128 const gfx::NativeWindow parent_window =
128 web_contents->GetTopLevelNativeWindow(); 129 web_contents->GetTopLevelNativeWindow();
129 scoped_ptr<DesktopMediaList> media_list; 130 std::unique_ptr<DesktopMediaList> media_list;
130 if (g_picker_factory) { 131 if (g_picker_factory) {
131 media_list = g_picker_factory->CreateModel(show_screens, show_windows, 132 media_list = g_picker_factory->CreateModel(show_screens, show_windows,
132 show_tabs, request_audio); 133 show_tabs, request_audio);
133 picker_ = g_picker_factory->CreatePicker(); 134 picker_ = g_picker_factory->CreatePicker();
134 } else { 135 } else {
135 std::vector<scoped_ptr<DesktopMediaList>> media_lists; 136 std::vector<std::unique_ptr<DesktopMediaList>> media_lists;
136 // Create a screens/windows list and push it into media_lists. 137 // Create a screens/windows list and push it into media_lists.
137 if (show_screens || show_windows) { 138 if (show_screens || show_windows) {
138 #if defined(USE_ASH) 139 #if defined(USE_ASH)
139 if (chrome::IsNativeWindowInAsh(parent_window)) { 140 if (chrome::IsNativeWindowInAsh(parent_window)) {
140 media_lists.push_back(make_scoped_ptr(new DesktopMediaListAsh( 141 media_lists.push_back(base::WrapUnique(new DesktopMediaListAsh(
141 (show_screens ? DesktopMediaListAsh::SCREENS : 0) | 142 (show_screens ? DesktopMediaListAsh::SCREENS : 0) |
142 (show_windows ? DesktopMediaListAsh::WINDOWS : 0)))); 143 (show_windows ? DesktopMediaListAsh::WINDOWS : 0))));
143 } 144 }
144 #endif 145 #endif
145 if (!media_list) { 146 if (!media_list) {
146 webrtc::DesktopCaptureOptions options = 147 webrtc::DesktopCaptureOptions options =
147 webrtc::DesktopCaptureOptions::CreateDefault(); 148 webrtc::DesktopCaptureOptions::CreateDefault();
148 options.set_disable_effects(false); 149 options.set_disable_effects(false);
149 scoped_ptr<webrtc::ScreenCapturer> screen_capturer( 150 std::unique_ptr<webrtc::ScreenCapturer> screen_capturer(
150 show_screens ? webrtc::ScreenCapturer::Create(options) : NULL); 151 show_screens ? webrtc::ScreenCapturer::Create(options) : NULL);
151 scoped_ptr<webrtc::WindowCapturer> window_capturer( 152 std::unique_ptr<webrtc::WindowCapturer> window_capturer(
152 show_windows ? webrtc::WindowCapturer::Create(options) : NULL); 153 show_windows ? webrtc::WindowCapturer::Create(options) : NULL);
153 154
154 media_lists.push_back(make_scoped_ptr(new NativeDesktopMediaList( 155 media_lists.push_back(base::WrapUnique(new NativeDesktopMediaList(
155 std::move(screen_capturer), std::move(window_capturer)))); 156 std::move(screen_capturer), std::move(window_capturer))));
156 } 157 }
157 } 158 }
158 159
159 if (show_tabs) 160 if (show_tabs)
160 media_lists.push_back(make_scoped_ptr(new TabDesktopMediaList())); 161 media_lists.push_back(base::WrapUnique(new TabDesktopMediaList()));
161 162
162 DCHECK(!media_lists.empty()); 163 DCHECK(!media_lists.empty());
163 164
164 if (media_lists.size() == 1) { 165 if (media_lists.size() == 1) {
165 media_list = std::move(media_lists[0]); 166 media_list = std::move(media_lists[0]);
166 } else { 167 } else {
167 media_list.reset(new CombinedDesktopMediaList(media_lists)); 168 media_list.reset(new CombinedDesktopMediaList(media_lists));
168 } 169 }
169 170
170 // DesktopMediaPicker is implemented only for Windows, OSX and 171 // DesktopMediaPicker is implemented only for Windows, OSX and
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 268
268 void DesktopCaptureRequestsRegistry::CancelRequest(int process_id, 269 void DesktopCaptureRequestsRegistry::CancelRequest(int process_id,
269 int request_id) { 270 int request_id) {
270 RequestsMap::iterator it = requests_.find(RequestId(process_id, request_id)); 271 RequestsMap::iterator it = requests_.find(RequestId(process_id, request_id));
271 if (it != requests_.end()) 272 if (it != requests_.end())
272 it->second->Cancel(); 273 it->second->Cancel();
273 } 274 }
274 275
275 276
276 } // namespace extensions 277 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698