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

Side by Side Diff: chrome/browser/extensions/api/webstore_private/webstore_private_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: 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 #include "chrome/browser/extensions/api/webstore_private/webstore_private_api.h" 5 #include "chrome/browser/extensions/api/webstore_private/webstore_private_api.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 namespace SetStoreLogin = api::webstore_private::SetStoreLogin; 57 namespace SetStoreLogin = api::webstore_private::SetStoreLogin;
58 58
59 namespace { 59 namespace {
60 60
61 // Holds the Approvals between the time we prompt and start the installs. 61 // Holds the Approvals between the time we prompt and start the installs.
62 class PendingApprovals { 62 class PendingApprovals {
63 public: 63 public:
64 PendingApprovals(); 64 PendingApprovals();
65 ~PendingApprovals(); 65 ~PendingApprovals();
66 66
67 void PushApproval(scoped_ptr<WebstoreInstaller::Approval> approval); 67 void PushApproval(std::unique_ptr<WebstoreInstaller::Approval> approval);
68 scoped_ptr<WebstoreInstaller::Approval> PopApproval( 68 std::unique_ptr<WebstoreInstaller::Approval> PopApproval(
69 Profile* profile, const std::string& id); 69 Profile* profile,
70 const std::string& id);
71
70 private: 72 private:
71 typedef ScopedVector<WebstoreInstaller::Approval> ApprovalList; 73 typedef ScopedVector<WebstoreInstaller::Approval> ApprovalList;
72 74
73 ApprovalList approvals_; 75 ApprovalList approvals_;
74 76
75 DISALLOW_COPY_AND_ASSIGN(PendingApprovals); 77 DISALLOW_COPY_AND_ASSIGN(PendingApprovals);
76 }; 78 };
77 79
78 PendingApprovals::PendingApprovals() {} 80 PendingApprovals::PendingApprovals() {}
79 PendingApprovals::~PendingApprovals() {} 81 PendingApprovals::~PendingApprovals() {}
80 82
81 void PendingApprovals::PushApproval( 83 void PendingApprovals::PushApproval(
82 scoped_ptr<WebstoreInstaller::Approval> approval) { 84 std::unique_ptr<WebstoreInstaller::Approval> approval) {
83 approvals_.push_back(approval.release()); 85 approvals_.push_back(approval.release());
84 } 86 }
85 87
86 scoped_ptr<WebstoreInstaller::Approval> PendingApprovals::PopApproval( 88 std::unique_ptr<WebstoreInstaller::Approval> PendingApprovals::PopApproval(
87 Profile* profile, const std::string& id) { 89 Profile* profile,
90 const std::string& id) {
88 for (size_t i = 0; i < approvals_.size(); ++i) { 91 for (size_t i = 0; i < approvals_.size(); ++i) {
89 WebstoreInstaller::Approval* approval = approvals_[i]; 92 WebstoreInstaller::Approval* approval = approvals_[i];
90 if (approval->extension_id == id && 93 if (approval->extension_id == id &&
91 profile->IsSameProfile(approval->profile)) { 94 profile->IsSameProfile(approval->profile)) {
92 approvals_.weak_erase(approvals_.begin() + i); 95 approvals_.weak_erase(approvals_.begin() + i);
93 return scoped_ptr<WebstoreInstaller::Approval>(approval); 96 return std::unique_ptr<WebstoreInstaller::Approval>(approval);
94 } 97 }
95 } 98 }
96 return scoped_ptr<WebstoreInstaller::Approval>(); 99 return std::unique_ptr<WebstoreInstaller::Approval>();
97 } 100 }
98 101
99 api::webstore_private::Result WebstoreInstallHelperResultToApiResult( 102 api::webstore_private::Result WebstoreInstallHelperResultToApiResult(
100 WebstoreInstallHelper::Delegate::InstallHelperResultCode result) { 103 WebstoreInstallHelper::Delegate::InstallHelperResultCode result) {
101 switch (result) { 104 switch (result) {
102 case WebstoreInstallHelper::Delegate::UNKNOWN_ERROR: 105 case WebstoreInstallHelper::Delegate::UNKNOWN_ERROR:
103 return api::webstore_private::RESULT_UNKNOWN_ERROR; 106 return api::webstore_private::RESULT_UNKNOWN_ERROR;
104 case WebstoreInstallHelper::Delegate::ICON_ERROR: 107 case WebstoreInstallHelper::Delegate::ICON_ERROR:
105 return api::webstore_private::RESULT_ICON_ERROR; 108 return api::webstore_private::RESULT_ICON_ERROR;
106 case WebstoreInstallHelper::Delegate::MANIFEST_ERROR: 109 case WebstoreInstallHelper::Delegate::MANIFEST_ERROR:
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 157
155 } // namespace 158 } // namespace
156 159
157 // static 160 // static
158 void WebstorePrivateApi::SetWebstoreInstallerDelegateForTesting( 161 void WebstorePrivateApi::SetWebstoreInstallerDelegateForTesting(
159 WebstoreInstaller::Delegate* delegate) { 162 WebstoreInstaller::Delegate* delegate) {
160 test_webstore_installer_delegate = delegate; 163 test_webstore_installer_delegate = delegate;
161 } 164 }
162 165
163 // static 166 // static
164 scoped_ptr<WebstoreInstaller::Approval> 167 std::unique_ptr<WebstoreInstaller::Approval>
165 WebstorePrivateApi::PopApprovalForTesting( 168 WebstorePrivateApi::PopApprovalForTesting(Profile* profile,
166 Profile* profile, const std::string& extension_id) { 169 const std::string& extension_id) {
167 return g_pending_approvals.Get().PopApproval(profile, extension_id); 170 return g_pending_approvals.Get().PopApproval(profile, extension_id);
168 } 171 }
169 172
170 WebstorePrivateBeginInstallWithManifest3Function:: 173 WebstorePrivateBeginInstallWithManifest3Function::
171 WebstorePrivateBeginInstallWithManifest3Function() : chrome_details_(this) { 174 WebstorePrivateBeginInstallWithManifest3Function() : chrome_details_(this) {
172 } 175 }
173 176
174 WebstorePrivateBeginInstallWithManifest3Function:: 177 WebstorePrivateBeginInstallWithManifest3Function::
175 ~WebstorePrivateBeginInstallWithManifest3Function() { 178 ~WebstorePrivateBeginInstallWithManifest3Function() {
176 } 179 }
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 } 311 }
309 312
310 // Matches the AddRef in Run(). 313 // Matches the AddRef in Run().
311 Release(); 314 Release();
312 } 315 }
313 316
314 void WebstorePrivateBeginInstallWithManifest3Function::HandleInstallProceed() { 317 void WebstorePrivateBeginInstallWithManifest3Function::HandleInstallProceed() {
315 // This gets cleared in CrxInstaller::ConfirmInstall(). TODO(asargent) - in 318 // This gets cleared in CrxInstaller::ConfirmInstall(). TODO(asargent) - in
316 // the future we may also want to add time-based expiration, where a whitelist 319 // the future we may also want to add time-based expiration, where a whitelist
317 // entry is only valid for some number of minutes. 320 // entry is only valid for some number of minutes.
318 scoped_ptr<WebstoreInstaller::Approval> approval( 321 std::unique_ptr<WebstoreInstaller::Approval> approval(
319 WebstoreInstaller::Approval::CreateWithNoInstallPrompt( 322 WebstoreInstaller::Approval::CreateWithNoInstallPrompt(
320 chrome_details_.GetProfile(), details().id, 323 chrome_details_.GetProfile(), details().id,
321 std::move(parsed_manifest_), false)); 324 std::move(parsed_manifest_), false));
322 approval->use_app_installed_bubble = !!details().app_install_bubble; 325 approval->use_app_installed_bubble = !!details().app_install_bubble;
323 approval->enable_launcher = !!details().enable_launcher; 326 approval->enable_launcher = !!details().enable_launcher;
324 // If we are enabling the launcher, we should not show the app list in order 327 // If we are enabling the launcher, we should not show the app list in order
325 // to train the user to open it themselves at least once. 328 // to train the user to open it themselves at least once.
326 approval->skip_post_install_ui = !!details().enable_launcher; 329 approval->skip_post_install_ui = !!details().enable_launcher;
327 approval->dummy_extension = dummy_extension_.get(); 330 approval->dummy_extension = dummy_extension_.get();
328 approval->installing_icon = gfx::ImageSkia::CreateFrom1xBitmap(icon_); 331 approval->installing_icon = gfx::ImageSkia::CreateFrom1xBitmap(icon_);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 api::webstore_private::Result result, const std::string& error) { 368 api::webstore_private::Result result, const std::string& error) {
366 if (result != api::webstore_private::RESULT_SUCCESS) 369 if (result != api::webstore_private::RESULT_SUCCESS)
367 return ErrorWithArguments(CreateResults(result), error); 370 return ErrorWithArguments(CreateResults(result), error);
368 371
369 // The web store expects an empty string on success, so don't use 372 // The web store expects an empty string on success, so don't use
370 // RESULT_SUCCESS here. 373 // RESULT_SUCCESS here.
371 return ArgumentList( 374 return ArgumentList(
372 CreateResults(api::webstore_private::RESULT_EMPTY_STRING)); 375 CreateResults(api::webstore_private::RESULT_EMPTY_STRING));
373 } 376 }
374 377
375 scoped_ptr<base::ListValue> 378 std::unique_ptr<base::ListValue>
376 WebstorePrivateBeginInstallWithManifest3Function::CreateResults( 379 WebstorePrivateBeginInstallWithManifest3Function::CreateResults(
377 api::webstore_private::Result result) const { 380 api::webstore_private::Result result) const {
378 return BeginInstallWithManifest3::Results::Create(result); 381 return BeginInstallWithManifest3::Results::Create(result);
379 } 382 }
380 383
381 WebstorePrivateCompleteInstallFunction:: 384 WebstorePrivateCompleteInstallFunction::
382 WebstorePrivateCompleteInstallFunction() : chrome_details_(this) {} 385 WebstorePrivateCompleteInstallFunction() : chrome_details_(this) {}
383 386
384 WebstorePrivateCompleteInstallFunction:: 387 WebstorePrivateCompleteInstallFunction::
385 ~WebstorePrivateCompleteInstallFunction() {} 388 ~WebstorePrivateCompleteInstallFunction() {}
386 389
387 ExtensionFunction::ResponseAction 390 ExtensionFunction::ResponseAction
388 WebstorePrivateCompleteInstallFunction::Run() { 391 WebstorePrivateCompleteInstallFunction::Run() {
389 scoped_ptr<CompleteInstall::Params> params( 392 std::unique_ptr<CompleteInstall::Params> params(
390 CompleteInstall::Params::Create(*args_)); 393 CompleteInstall::Params::Create(*args_));
391 EXTENSION_FUNCTION_VALIDATE(params); 394 EXTENSION_FUNCTION_VALIDATE(params);
392 if (chrome_details_.GetProfile()->IsGuestSession() || 395 if (chrome_details_.GetProfile()->IsGuestSession() ||
393 chrome_details_.GetProfile()->IsOffTheRecord()) { 396 chrome_details_.GetProfile()->IsOffTheRecord()) {
394 return RespondNow(Error(kIncognitoError)); 397 return RespondNow(Error(kIncognitoError));
395 } 398 }
396 399
397 if (!crx_file::id_util::IdIsValid(params->expected_id)) 400 if (!crx_file::id_util::IdIsValid(params->expected_id))
398 return RespondNow(Error(kInvalidIdError)); 401 return RespondNow(Error(kInvalidIdError));
399 402
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
614 GetWebstoreLogin(chrome_details_.GetProfile())))); 617 GetWebstoreLogin(chrome_details_.GetProfile()))));
615 } 618 }
616 619
617 WebstorePrivateSetStoreLoginFunction:: 620 WebstorePrivateSetStoreLoginFunction::
618 WebstorePrivateSetStoreLoginFunction() : chrome_details_(this) {} 621 WebstorePrivateSetStoreLoginFunction() : chrome_details_(this) {}
619 622
620 WebstorePrivateSetStoreLoginFunction:: 623 WebstorePrivateSetStoreLoginFunction::
621 ~WebstorePrivateSetStoreLoginFunction() {} 624 ~WebstorePrivateSetStoreLoginFunction() {}
622 625
623 ExtensionFunction::ResponseAction WebstorePrivateSetStoreLoginFunction::Run() { 626 ExtensionFunction::ResponseAction WebstorePrivateSetStoreLoginFunction::Run() {
624 scoped_ptr<SetStoreLogin::Params> params( 627 std::unique_ptr<SetStoreLogin::Params> params(
625 SetStoreLogin::Params::Create(*args_)); 628 SetStoreLogin::Params::Create(*args_));
626 EXTENSION_FUNCTION_VALIDATE(params); 629 EXTENSION_FUNCTION_VALIDATE(params);
627 SetWebstoreLogin(chrome_details_.GetProfile(), params->login); 630 SetWebstoreLogin(chrome_details_.GetProfile(), params->login);
628 return RespondNow(NoArguments()); 631 return RespondNow(NoArguments());
629 } 632 }
630 633
631 WebstorePrivateGetWebGLStatusFunction::WebstorePrivateGetWebGLStatusFunction() 634 WebstorePrivateGetWebGLStatusFunction::WebstorePrivateGetWebGLStatusFunction()
632 : feature_checker_(new GPUFeatureChecker( 635 : feature_checker_(new GPUFeatureChecker(
633 gpu::GPU_FEATURE_TYPE_WEBGL, 636 gpu::GPU_FEATURE_TYPE_WEBGL,
634 base::Bind(&WebstorePrivateGetWebGLStatusFunction::OnFeatureCheck, 637 base::Bind(&WebstorePrivateGetWebGLStatusFunction::OnFeatureCheck,
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
693 WebstorePrivateGetEphemeralAppsEnabledFunction:: 696 WebstorePrivateGetEphemeralAppsEnabledFunction::
694 ~WebstorePrivateGetEphemeralAppsEnabledFunction() {} 697 ~WebstorePrivateGetEphemeralAppsEnabledFunction() {}
695 698
696 ExtensionFunction::ResponseAction 699 ExtensionFunction::ResponseAction
697 WebstorePrivateGetEphemeralAppsEnabledFunction::Run() { 700 WebstorePrivateGetEphemeralAppsEnabledFunction::Run() {
698 return RespondNow(ArgumentList(GetEphemeralAppsEnabled::Results::Create( 701 return RespondNow(ArgumentList(GetEphemeralAppsEnabled::Results::Create(
699 false))); 702 false)));
700 } 703 }
701 704
702 } // namespace extensions 705 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698