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

Side by Side Diff: chrome/browser/extensions/crx_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: 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 #include "chrome/browser/extensions/crx_installer.h" 5 #include "chrome/browser/extensions/crx_installer.h"
6 6
7 #include <map> 7 #include <map>
8 #include <set> 8 #include <set>
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/files/file_util.h" 12 #include "base/files/file_util.h"
13 #include "base/files/scoped_temp_dir.h" 13 #include "base/files/scoped_temp_dir.h"
14 #include "base/lazy_instance.h" 14 #include "base/lazy_instance.h"
15 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "base/memory/ptr_util.h"
16 #include "base/metrics/histogram.h" 17 #include "base/metrics/histogram.h"
17 #include "base/sequenced_task_runner.h" 18 #include "base/sequenced_task_runner.h"
18 #include "base/strings/string_util.h" 19 #include "base/strings/string_util.h"
19 #include "base/strings/stringprintf.h" 20 #include "base/strings/stringprintf.h"
20 #include "base/strings/utf_string_conversions.h" 21 #include "base/strings/utf_string_conversions.h"
21 #include "base/threading/sequenced_worker_pool.h" 22 #include "base/threading/sequenced_worker_pool.h"
22 #include "base/threading/thread_restrictions.h" 23 #include "base/threading/thread_restrictions.h"
23 #include "base/time/time.h" 24 #include "base/time/time.h"
24 #include "base/version.h" 25 #include "base/version.h"
25 #include "build/build_config.h" 26 #include "build/build_config.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 OffStoreInstallDisallowed, 83 OffStoreInstallDisallowed,
83 NumOffStoreInstallDecision 84 NumOffStoreInstallDecision
84 }; 85 };
85 86
86 } // namespace 87 } // namespace
87 88
88 // static 89 // static
89 scoped_refptr<CrxInstaller> CrxInstaller::CreateSilent( 90 scoped_refptr<CrxInstaller> CrxInstaller::CreateSilent(
90 ExtensionService* frontend) { 91 ExtensionService* frontend) {
91 return new CrxInstaller(frontend->AsWeakPtr(), 92 return new CrxInstaller(frontend->AsWeakPtr(),
92 scoped_ptr<ExtensionInstallPrompt>(), 93 std::unique_ptr<ExtensionInstallPrompt>(), NULL);
93 NULL);
94 } 94 }
95 95
96 // static 96 // static
97 scoped_refptr<CrxInstaller> CrxInstaller::Create( 97 scoped_refptr<CrxInstaller> CrxInstaller::Create(
98 ExtensionService* frontend, 98 ExtensionService* frontend,
99 scoped_ptr<ExtensionInstallPrompt> client) { 99 std::unique_ptr<ExtensionInstallPrompt> client) {
100 return new CrxInstaller(frontend->AsWeakPtr(), std::move(client), NULL); 100 return new CrxInstaller(frontend->AsWeakPtr(), std::move(client), NULL);
101 } 101 }
102 102
103 // static 103 // static
104 scoped_refptr<CrxInstaller> CrxInstaller::Create( 104 scoped_refptr<CrxInstaller> CrxInstaller::Create(
105 ExtensionService* service, 105 ExtensionService* service,
106 scoped_ptr<ExtensionInstallPrompt> client, 106 std::unique_ptr<ExtensionInstallPrompt> client,
107 const WebstoreInstaller::Approval* approval) { 107 const WebstoreInstaller::Approval* approval) {
108 return new CrxInstaller(service->AsWeakPtr(), std::move(client), approval); 108 return new CrxInstaller(service->AsWeakPtr(), std::move(client), approval);
109 } 109 }
110 110
111 CrxInstaller::CrxInstaller(base::WeakPtr<ExtensionService> service_weak, 111 CrxInstaller::CrxInstaller(base::WeakPtr<ExtensionService> service_weak,
112 scoped_ptr<ExtensionInstallPrompt> client, 112 std::unique_ptr<ExtensionInstallPrompt> client,
113 const WebstoreInstaller::Approval* approval) 113 const WebstoreInstaller::Approval* approval)
114 : install_directory_(service_weak->install_directory()), 114 : install_directory_(service_weak->install_directory()),
115 install_source_(Manifest::INTERNAL), 115 install_source_(Manifest::INTERNAL),
116 approved_(false), 116 approved_(false),
117 hash_check_failed_(false), 117 hash_check_failed_(false),
118 expected_manifest_check_level_( 118 expected_manifest_check_level_(
119 WebstoreInstaller::MANIFEST_CHECK_LEVEL_STRICT), 119 WebstoreInstaller::MANIFEST_CHECK_LEVEL_STRICT),
120 fail_install_if_unexpected_version_(false), 120 fail_install_if_unexpected_version_(false),
121 extensions_enabled_(service_weak->extensions_enabled()), 121 extensions_enabled_(service_weak->extensions_enabled()),
122 delete_source_(false), 122 delete_source_(false),
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 extension_misc::NUM_INSTALL_CAUSES); 441 extension_misc::NUM_INSTALL_CAUSES);
442 442
443 install_checker_.set_extension(extension); 443 install_checker_.set_extension(extension);
444 temp_dir_ = temp_dir; 444 temp_dir_ = temp_dir;
445 if (!install_icon.empty()) 445 if (!install_icon.empty())
446 install_icon_.reset(new SkBitmap(install_icon)); 446 install_icon_.reset(new SkBitmap(install_icon));
447 447
448 if (original_manifest) 448 if (original_manifest)
449 original_manifest_.reset(new Manifest( 449 original_manifest_.reset(new Manifest(
450 Manifest::INVALID_LOCATION, 450 Manifest::INVALID_LOCATION,
451 scoped_ptr<base::DictionaryValue>(original_manifest->DeepCopy()))); 451 std::unique_ptr<base::DictionaryValue>(original_manifest->DeepCopy())));
452 452
453 // We don't have to delete the unpack dir explicity since it is a child of 453 // We don't have to delete the unpack dir explicity since it is a child of
454 // the temp dir. 454 // the temp dir.
455 unpacked_extension_root_ = extension_dir; 455 unpacked_extension_root_ = extension_dir;
456 456
457 CrxInstallError error = AllowInstall(extension); 457 CrxInstallError error = AllowInstall(extension);
458 if (error.type() != CrxInstallError::ERROR_NONE) { 458 if (error.type() != CrxInstallError::ERROR_NONE) {
459 ReportFailureFromFileThread(error); 459 ReportFailureFromFileThread(error);
460 return; 460 return;
461 } 461 }
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after
911 if (!prefs->DidExtensionEscalatePermissions(extension()->id())) 911 if (!prefs->DidExtensionEscalatePermissions(extension()->id()))
912 return; 912 return;
913 913
914 if (client_) { 914 if (client_) {
915 AddRef(); // Balanced in OnInstallPromptDone(). 915 AddRef(); // Balanced in OnInstallPromptDone().
916 ExtensionInstallPrompt::PromptType type = 916 ExtensionInstallPrompt::PromptType type =
917 ExtensionInstallPrompt::GetReEnablePromptTypeForExtension( 917 ExtensionInstallPrompt::GetReEnablePromptTypeForExtension(
918 service->profile(), extension()); 918 service->profile(), extension());
919 client_->ShowDialog( 919 client_->ShowDialog(
920 base::Bind(&CrxInstaller::OnInstallPromptDone, this), extension(), 920 base::Bind(&CrxInstaller::OnInstallPromptDone, this), extension(),
921 nullptr, make_scoped_ptr(new ExtensionInstallPrompt::Prompt(type)), 921 nullptr, base::WrapUnique(new ExtensionInstallPrompt::Prompt(type)),
922 ExtensionInstallPrompt::GetDefaultShowDialogCallback()); 922 ExtensionInstallPrompt::GetDefaultShowDialogCallback());
923 } 923 }
924 } 924 }
925 925
926 } // namespace extensions 926 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/crx_installer.h ('k') | chrome/browser/extensions/crx_installer_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698