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

Side by Side Diff: chrome/browser/extensions/webstore_standalone_installer.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/webstore_standalone_installer.h" 5 #include "chrome/browser/extensions/webstore_standalone_installer.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/memory/ptr_util.h"
9 #include "base/values.h" 10 #include "base/values.h"
10 #include "base/version.h" 11 #include "base/version.h"
11 #include "chrome/browser/extensions/crx_installer.h" 12 #include "chrome/browser/extensions/crx_installer.h"
12 #include "chrome/browser/extensions/extension_install_prompt.h" 13 #include "chrome/browser/extensions/extension_install_prompt.h"
13 #include "chrome/browser/extensions/extension_install_ui_util.h" 14 #include "chrome/browser/extensions/extension_install_ui_util.h"
14 #include "chrome/browser/extensions/extension_service.h" 15 #include "chrome/browser/extensions/extension_service.h"
15 #include "chrome/browser/extensions/install_tracker.h" 16 #include "chrome/browser/extensions/install_tracker.h"
16 #include "chrome/browser/extensions/webstore_data_fetcher.h" 17 #include "chrome/browser/extensions/webstore_data_fetcher.h"
17 #include "chrome/browser/profiles/profile.h" 18 #include "chrome/browser/profiles/profile.h"
18 #include "components/crx_file/id_util.h" 19 #include "components/crx_file/id_util.h"
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 164
164 void WebstoreStandaloneInstaller::InitInstallData( 165 void WebstoreStandaloneInstaller::InitInstallData(
165 ActiveInstallData* install_data) const { 166 ActiveInstallData* install_data) const {
166 // Default implementation sets no properties. 167 // Default implementation sets no properties.
167 } 168 }
168 169
169 void WebstoreStandaloneInstaller::OnManifestParsed() { 170 void WebstoreStandaloneInstaller::OnManifestParsed() {
170 ProceedWithInstallPrompt(); 171 ProceedWithInstallPrompt();
171 } 172 }
172 173
173 scoped_ptr<ExtensionInstallPrompt> 174 std::unique_ptr<ExtensionInstallPrompt>
174 WebstoreStandaloneInstaller::CreateInstallUI() { 175 WebstoreStandaloneInstaller::CreateInstallUI() {
175 return make_scoped_ptr(new ExtensionInstallPrompt(GetWebContents())); 176 return base::WrapUnique(new ExtensionInstallPrompt(GetWebContents()));
176 } 177 }
177 178
178 scoped_ptr<WebstoreInstaller::Approval> 179 std::unique_ptr<WebstoreInstaller::Approval>
179 WebstoreStandaloneInstaller::CreateApproval() const { 180 WebstoreStandaloneInstaller::CreateApproval() const {
180 scoped_ptr<WebstoreInstaller::Approval> approval( 181 std::unique_ptr<WebstoreInstaller::Approval> approval(
181 WebstoreInstaller::Approval::CreateWithNoInstallPrompt( 182 WebstoreInstaller::Approval::CreateWithNoInstallPrompt(
182 profile_, 183 profile_, id_,
183 id_, 184 std::unique_ptr<base::DictionaryValue>(manifest_.get()->DeepCopy()),
184 scoped_ptr<base::DictionaryValue>(manifest_.get()->DeepCopy()),
185 true)); 185 true));
186 approval->skip_post_install_ui = !ShouldShowPostInstallUI(); 186 approval->skip_post_install_ui = !ShouldShowPostInstallUI();
187 approval->use_app_installed_bubble = ShouldShowAppInstalledBubble(); 187 approval->use_app_installed_bubble = ShouldShowAppInstalledBubble();
188 approval->installing_icon = gfx::ImageSkia::CreateFrom1xBitmap(icon_); 188 approval->installing_icon = gfx::ImageSkia::CreateFrom1xBitmap(icon_);
189 return approval; 189 return approval;
190 } 190 }
191 191
192 void WebstoreStandaloneInstaller::OnInstallPromptDone( 192 void WebstoreStandaloneInstaller::OnInstallPromptDone(
193 ExtensionInstallPrompt::Result result) { 193 ExtensionInstallPrompt::Result result) {
194 if (result == ExtensionInstallPrompt::Result::USER_CANCELED) { 194 if (result == ExtensionInstallPrompt::Result::USER_CANCELED) {
195 CompleteInstall(webstore_install::USER_CANCELLED, kUserCancelledError); 195 CompleteInstall(webstore_install::USER_CANCELLED, kUserCancelledError);
196 return; 196 return;
197 } 197 }
198 198
199 if (result == ExtensionInstallPrompt::Result::ABORTED || 199 if (result == ExtensionInstallPrompt::Result::ABORTED ||
200 !CheckRequestorAlive()) { 200 !CheckRequestorAlive()) {
201 CompleteInstall(webstore_install::ABORTED, std::string()); 201 CompleteInstall(webstore_install::ABORTED, std::string());
202 return; 202 return;
203 } 203 }
204 204
205 DCHECK(result == ExtensionInstallPrompt::Result::ACCEPTED); 205 DCHECK(result == ExtensionInstallPrompt::Result::ACCEPTED);
206 206
207 scoped_ptr<WebstoreInstaller::Approval> approval = CreateApproval(); 207 std::unique_ptr<WebstoreInstaller::Approval> approval = CreateApproval();
208 208
209 ExtensionService* extension_service = 209 ExtensionService* extension_service =
210 ExtensionSystem::Get(profile_)->extension_service(); 210 ExtensionSystem::Get(profile_)->extension_service();
211 const Extension* installed_extension = 211 const Extension* installed_extension =
212 extension_service->GetExtensionById(id_, true /* include disabled */); 212 extension_service->GetExtensionById(id_, true /* include disabled */);
213 if (installed_extension) { 213 if (installed_extension) {
214 std::string install_message; 214 std::string install_message;
215 webstore_install::Result install_result = webstore_install::SUCCESS; 215 webstore_install::Result install_result = webstore_install::SUCCESS;
216 bool done = true; 216 bool done = true;
217 217
(...skipping 19 matching lines...) Expand all
237 installer->Start(); 237 installer->Start();
238 } 238 }
239 239
240 void WebstoreStandaloneInstaller::OnWebstoreRequestFailure() { 240 void WebstoreStandaloneInstaller::OnWebstoreRequestFailure() {
241 OnWebStoreDataFetcherDone(); 241 OnWebStoreDataFetcherDone();
242 CompleteInstall(webstore_install::WEBSTORE_REQUEST_ERROR, 242 CompleteInstall(webstore_install::WEBSTORE_REQUEST_ERROR,
243 kWebstoreRequestError); 243 kWebstoreRequestError);
244 } 244 }
245 245
246 void WebstoreStandaloneInstaller::OnWebstoreResponseParseSuccess( 246 void WebstoreStandaloneInstaller::OnWebstoreResponseParseSuccess(
247 scoped_ptr<base::DictionaryValue> webstore_data) { 247 std::unique_ptr<base::DictionaryValue> webstore_data) {
248 OnWebStoreDataFetcherDone(); 248 OnWebStoreDataFetcherDone();
249 249
250 if (!CheckRequestorAlive()) { 250 if (!CheckRequestorAlive()) {
251 CompleteInstall(webstore_install::ABORTED, std::string()); 251 CompleteInstall(webstore_install::ABORTED, std::string());
252 return; 252 return;
253 } 253 }
254 254
255 std::string error; 255 std::string error;
256 256
257 if (!CheckInlineInstallPermitted(*webstore_data, &error)) { 257 if (!CheckInlineInstallPermitted(*webstore_data, &error)) {
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 void WebstoreStandaloneInstaller::OnWebStoreDataFetcherDone() { 417 void WebstoreStandaloneInstaller::OnWebStoreDataFetcherDone() {
418 // An instance of this class is passed in as a delegate for the 418 // An instance of this class is passed in as a delegate for the
419 // WebstoreInstallHelper, ExtensionInstallPrompt and WebstoreInstaller, and 419 // WebstoreInstallHelper, ExtensionInstallPrompt and WebstoreInstaller, and
420 // therefore needs to remain alive until they are done. Clear the webstore 420 // therefore needs to remain alive until they are done. Clear the webstore
421 // data fetcher to avoid calling Release in AbortInstall while any of these 421 // data fetcher to avoid calling Release in AbortInstall while any of these
422 // operations are in progress. 422 // operations are in progress.
423 webstore_data_fetcher_.reset(); 423 webstore_data_fetcher_.reset();
424 } 424 }
425 425
426 } // namespace extensions 426 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698