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

Side by Side Diff: chrome/browser/extensions/api/webstore_private/webstore_private_api.cc

Issue 2310683002: Remove most ScopedVector usage from c/b/extensions. (Closed)
Patch Set: remove scoped_vector includes Created 4 years, 3 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"
11 #include "base/lazy_instance.h" 11 #include "base/lazy_instance.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/scoped_vector.h"
14 #include "base/metrics/histogram_macros.h" 13 #include "base/metrics/histogram_macros.h"
15 #include "base/strings/stringprintf.h" 14 #include "base/strings/stringprintf.h"
16 #include "base/strings/utf_string_conversions.h" 15 #include "base/strings/utf_string_conversions.h"
17 #include "base/threading/thread_task_runner_handle.h" 16 #include "base/threading/thread_task_runner_handle.h"
18 #include "base/values.h" 17 #include "base/values.h"
19 #include "base/version.h" 18 #include "base/version.h"
20 #include "chrome/browser/bitmap_fetcher/bitmap_fetcher.h" 19 #include "chrome/browser/bitmap_fetcher/bitmap_fetcher.h"
21 #include "chrome/browser/extensions/crx_installer.h" 20 #include "chrome/browser/extensions/crx_installer.h"
22 #include "chrome/browser/extensions/extension_install_ui_util.h" 21 #include "chrome/browser/extensions/extension_install_ui_util.h"
23 #include "chrome/browser/extensions/extension_service.h" 22 #include "chrome/browser/extensions/extension_service.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 public: 65 public:
67 PendingApprovals(); 66 PendingApprovals();
68 ~PendingApprovals(); 67 ~PendingApprovals();
69 68
70 void PushApproval(std::unique_ptr<WebstoreInstaller::Approval> approval); 69 void PushApproval(std::unique_ptr<WebstoreInstaller::Approval> approval);
71 std::unique_ptr<WebstoreInstaller::Approval> PopApproval( 70 std::unique_ptr<WebstoreInstaller::Approval> PopApproval(
72 Profile* profile, 71 Profile* profile,
73 const std::string& id); 72 const std::string& id);
74 73
75 private: 74 private:
76 typedef ScopedVector<WebstoreInstaller::Approval> ApprovalList; 75 using ApprovalList =
76 std::vector<std::unique_ptr<WebstoreInstaller::Approval>>;
77 77
78 ApprovalList approvals_; 78 ApprovalList approvals_;
79 79
80 DISALLOW_COPY_AND_ASSIGN(PendingApprovals); 80 DISALLOW_COPY_AND_ASSIGN(PendingApprovals);
81 }; 81 };
82 82
83 PendingApprovals::PendingApprovals() {} 83 PendingApprovals::PendingApprovals() {}
84 PendingApprovals::~PendingApprovals() {} 84 PendingApprovals::~PendingApprovals() {}
85 85
86 void PendingApprovals::PushApproval( 86 void PendingApprovals::PushApproval(
87 std::unique_ptr<WebstoreInstaller::Approval> approval) { 87 std::unique_ptr<WebstoreInstaller::Approval> approval) {
88 approvals_.push_back(approval.release()); 88 approvals_.push_back(std::move(approval));
89 } 89 }
90 90
91 std::unique_ptr<WebstoreInstaller::Approval> PendingApprovals::PopApproval( 91 std::unique_ptr<WebstoreInstaller::Approval> PendingApprovals::PopApproval(
92 Profile* profile, 92 Profile* profile,
93 const std::string& id) { 93 const std::string& id) {
94 for (size_t i = 0; i < approvals_.size(); ++i) { 94 for (ApprovalList::iterator iter = approvals_.begin();
95 WebstoreInstaller::Approval* approval = approvals_[i]; 95 iter != approvals_.end(); ++iter) {
96 if (approval->extension_id == id && 96 if (iter->get()->extension_id == id &&
97 profile->IsSameProfile(approval->profile)) { 97 profile->IsSameProfile(iter->get()->profile)) {
98 approvals_.weak_erase(approvals_.begin() + i); 98 std::unique_ptr<WebstoreInstaller::Approval> approval = std::move(*iter);
99 return std::unique_ptr<WebstoreInstaller::Approval>(approval); 99 approvals_.erase(iter);
100 return approval;
100 } 101 }
101 } 102 }
102 return std::unique_ptr<WebstoreInstaller::Approval>(); 103 return std::unique_ptr<WebstoreInstaller::Approval>();
103 } 104 }
104 105
105 api::webstore_private::Result WebstoreInstallHelperResultToApiResult( 106 api::webstore_private::Result WebstoreInstallHelperResultToApiResult(
106 WebstoreInstallHelper::Delegate::InstallHelperResultCode result) { 107 WebstoreInstallHelper::Delegate::InstallHelperResultCode result) {
107 switch (result) { 108 switch (result) {
108 case WebstoreInstallHelper::Delegate::UNKNOWN_ERROR: 109 case WebstoreInstallHelper::Delegate::UNKNOWN_ERROR:
109 return api::webstore_private::RESULT_UNKNOWN_ERROR; 110 return api::webstore_private::RESULT_UNKNOWN_ERROR;
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after
629 630
630 return RespondNow(BuildResponse(is_pending_approval)); 631 return RespondNow(BuildResponse(is_pending_approval));
631 } 632 }
632 633
633 ExtensionFunction::ResponseValue 634 ExtensionFunction::ResponseValue
634 WebstorePrivateIsPendingCustodianApprovalFunction::BuildResponse(bool result) { 635 WebstorePrivateIsPendingCustodianApprovalFunction::BuildResponse(bool result) {
635 return OneArgument(base::MakeUnique<base::FundamentalValue>(result)); 636 return OneArgument(base::MakeUnique<base::FundamentalValue>(result));
636 } 637 }
637 638
638 } // namespace extensions 639 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/tab_capture/tab_capture_registry.cc ('k') | chrome/browser/extensions/extension_management.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698