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

Side by Side Diff: chrome/browser/extensions/api/tab_capture/tab_capture_api.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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // Implements the Chrome Extensions Tab Capture API. 5 // Implements the Chrome Extensions Tab Capture API.
6 6
7 #include "chrome/browser/extensions/api/tab_capture/tab_capture_api.h" 7 #include "chrome/browser/extensions/api/tab_capture/tab_capture_api.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <set> 10 #include <set>
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 // http://crbug.com/579729 82 // http://crbug.com/579729
83 void FilterDeprecatedGoogConstraints(TabCapture::CaptureOptions* options) { 83 void FilterDeprecatedGoogConstraints(TabCapture::CaptureOptions* options) {
84 const auto FilterGoogKeysFromDictionary = [](base::DictionaryValue* dict) { 84 const auto FilterGoogKeysFromDictionary = [](base::DictionaryValue* dict) {
85 std::vector<std::string> bad_keys; 85 std::vector<std::string> bad_keys;
86 base::DictionaryValue::Iterator it(*dict); 86 base::DictionaryValue::Iterator it(*dict);
87 for (; !it.IsAtEnd(); it.Advance()) { 87 for (; !it.IsAtEnd(); it.Advance()) {
88 if (it.key().find("goog") == 0) 88 if (it.key().find("goog") == 0)
89 bad_keys.push_back(it.key()); 89 bad_keys.push_back(it.key());
90 } 90 }
91 for (const std::string& k : bad_keys) { 91 for (const std::string& k : bad_keys) {
92 scoped_ptr<base::Value> ignored; 92 std::unique_ptr<base::Value> ignored;
93 dict->RemoveWithoutPathExpansion(k, &ignored); 93 dict->RemoveWithoutPathExpansion(k, &ignored);
94 } 94 }
95 }; 95 };
96 96
97 if (options->audio_constraints) { 97 if (options->audio_constraints) {
98 FilterGoogKeysFromDictionary( 98 FilterGoogKeysFromDictionary(
99 &options->audio_constraints->mandatory.additional_properties); 99 &options->audio_constraints->mandatory.additional_properties);
100 if (options->audio_constraints->optional) { 100 if (options->audio_constraints->optional) {
101 FilterGoogKeysFromDictionary( 101 FilterGoogKeysFromDictionary(
102 &options->audio_constraints->optional->additional_properties); 102 &options->audio_constraints->optional->additional_properties);
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 kStableChromecastExtensionId, // Google Cast Stable 191 kStableChromecastExtensionId, // Google Cast Stable
192 "hlgmmjhlnlapooncikdpiiokdjcdpjme", // Test cast extension 192 "hlgmmjhlnlapooncikdpiiokdjcdpjme", // Test cast extension
193 }; 193 };
194 194
195 const char* const kMediaRouterExtensionIds[] = { 195 const char* const kMediaRouterExtensionIds[] = {
196 "pkedcjkdefgpdelpbcmbmeomcjbeemfm", // Stable 196 "pkedcjkdefgpdelpbcmbmeomcjbeemfm", // Stable
197 "ekpaaapppgpmolpcldedioblbkmijaca", // Beta 197 "ekpaaapppgpmolpcldedioblbkmijaca", // Beta
198 }; 198 };
199 199
200 bool TabCaptureCaptureFunction::RunSync() { 200 bool TabCaptureCaptureFunction::RunSync() {
201 scoped_ptr<api::tab_capture::Capture::Params> params = 201 std::unique_ptr<api::tab_capture::Capture::Params> params =
202 TabCapture::Capture::Params::Create(*args_); 202 TabCapture::Capture::Params::Create(*args_);
203 EXTENSION_FUNCTION_VALIDATE(params); 203 EXTENSION_FUNCTION_VALIDATE(params);
204 204
205 // Figure out the active WebContents and retrieve the needed ids. 205 // Figure out the active WebContents and retrieve the needed ids.
206 Browser* target_browser = 206 Browser* target_browser =
207 chrome::FindAnyBrowser(GetProfile(), include_incognito()); 207 chrome::FindAnyBrowser(GetProfile(), include_incognito());
208 if (!target_browser) { 208 if (!target_browser) {
209 error_ = kFindingTabError; 209 error_ = kFindingTabError;
210 return false; 210 return false;
211 } 211 }
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 bool TabCaptureGetCapturedTabsFunction::RunSync() { 266 bool TabCaptureGetCapturedTabsFunction::RunSync() {
267 TabCaptureRegistry* registry = TabCaptureRegistry::Get(GetProfile()); 267 TabCaptureRegistry* registry = TabCaptureRegistry::Get(GetProfile());
268 base::ListValue* const list = new base::ListValue(); 268 base::ListValue* const list = new base::ListValue();
269 if (registry) 269 if (registry)
270 registry->GetCapturedTabs(extension()->id(), list); 270 registry->GetCapturedTabs(extension()->id(), list);
271 SetResult(list); 271 SetResult(list);
272 return true; 272 return true;
273 } 273 }
274 274
275 bool TabCaptureCaptureOffscreenTabFunction::RunSync() { 275 bool TabCaptureCaptureOffscreenTabFunction::RunSync() {
276 scoped_ptr<TabCapture::CaptureOffscreenTab::Params> params = 276 std::unique_ptr<TabCapture::CaptureOffscreenTab::Params> params =
277 TabCapture::CaptureOffscreenTab::Params::Create(*args_); 277 TabCapture::CaptureOffscreenTab::Params::Create(*args_);
278 EXTENSION_FUNCTION_VALIDATE(params); 278 EXTENSION_FUNCTION_VALIDATE(params);
279 279
280 // Make sure the extension is whitelisted for using this API, regardless of 280 // Make sure the extension is whitelisted for using this API, regardless of
281 // Chrome channel. 281 // Chrome channel.
282 // 282 //
283 // TODO(miu): Use _api_features.json and extensions::Feature library instead. 283 // TODO(miu): Use _api_features.json and extensions::Feature library instead.
284 // http://crbug.com/537732 284 // http://crbug.com/537732
285 const bool is_whitelisted_extension = 285 const bool is_whitelisted_extension =
286 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( 286 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 } 382 }
383 } 383 }
384 384
385 // No maximum size was provided, so just return the default size bounded by 385 // No maximum size was provided, so just return the default size bounded by
386 // the minimum size. 386 // the minimum size.
387 return gfx::Size(std::max(kDefaultWidth, min_size.width()), 387 return gfx::Size(std::max(kDefaultWidth, min_size.width()),
388 std::max(kDefaultHeight, min_size.height())); 388 std::max(kDefaultHeight, min_size.height()));
389 } 389 }
390 390
391 } // namespace extensions 391 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698