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

Side by Side Diff: chrome/browser/safe_browsing/incident_reporting/extension_data_collection.cc

Issue 1870003002: Convert //chrome/browser/safe_browsing from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase and address comments 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/safe_browsing/incident_reporting/extension_data_collect ion.h" 5 #include "chrome/browser/safe_browsing/incident_reporting/extension_data_collect ion.h"
6 6
7 #include "base/json/json_string_value_serializer.h" 7 #include "base/json/json_string_value_serializer.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "base/version.h" 9 #include "base/version.h"
10 #include "chrome/browser/browser_process.h" 10 #include "chrome/browser/browser_process.h"
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 extension_info->set_from_webstore(extension.from_webstore()); 64 extension_info->set_from_webstore(extension.from_webstore());
65 extension_info->set_converted_from_user_script( 65 extension_info->set_converted_from_user_script(
66 extension.converted_from_user_script()); 66 extension.converted_from_user_script());
67 extension_info->set_may_be_untrusted(extension.may_be_untrusted()); 67 extension_info->set_may_be_untrusted(extension.may_be_untrusted());
68 extension_info->set_install_time_msec( 68 extension_info->set_install_time_msec(
69 extension_prefs.GetInstallTime(extension.id()).ToJavaTime()); 69 extension_prefs.GetInstallTime(extension.id()).ToJavaTime());
70 70
71 const base::DictionaryValue* signature = 71 const base::DictionaryValue* signature =
72 extension_prefs.GetInstallSignature(); 72 extension_prefs.GetInstallSignature();
73 if (signature) { 73 if (signature) {
74 scoped_ptr<extensions::InstallSignature> signature_from_prefs = 74 std::unique_ptr<extensions::InstallSignature> signature_from_prefs =
75 extensions::InstallSignature::FromValue(*signature); 75 extensions::InstallSignature::FromValue(*signature);
76 if (signature_from_prefs) { 76 if (signature_from_prefs) {
77 if (ContainsKey(signature_from_prefs->ids, extension_id)) { 77 if (ContainsKey(signature_from_prefs->ids, extension_id)) {
78 extension_info->set_has_signature_validation(true); 78 extension_info->set_has_signature_validation(true);
79 extension_info->set_signature_is_valid(true); 79 extension_info->set_signature_is_valid(true);
80 } else if (ContainsKey(signature_from_prefs->invalid_ids, extension_id)) { 80 } else if (ContainsKey(signature_from_prefs->invalid_ids, extension_id)) {
81 extension_info->set_has_signature_validation(true); 81 extension_info->set_has_signature_validation(true);
82 extension_info->set_signature_is_valid(false); 82 extension_info->set_signature_is_valid(false);
83 } 83 }
84 } 84 }
(...skipping 16 matching lines...) Expand all
101 scoped_refptr<const extensions::Extension> last_installed_extension; 101 scoped_refptr<const extensions::Extension> last_installed_extension;
102 Profile* profile_for_last_installed_extension = nullptr; 102 Profile* profile_for_last_installed_extension = nullptr;
103 base::Time last_install_time; 103 base::Time last_install_time;
104 104
105 for (Profile* profile : 105 for (Profile* profile :
106 g_browser_process->profile_manager()->GetLoadedProfiles()) { 106 g_browser_process->profile_manager()->GetLoadedProfiles()) {
107 // Skip profiles for which the incident reporting service is not enabled. 107 // Skip profiles for which the incident reporting service is not enabled.
108 if (!IncidentReportingService::IsEnabledForProfile(profile)) 108 if (!IncidentReportingService::IsEnabledForProfile(profile))
109 continue; 109 continue;
110 110
111 scoped_ptr<const extensions::ExtensionSet> extensions( 111 std::unique_ptr<const extensions::ExtensionSet> extensions(
112 extensions::ExtensionRegistryFactory::GetForBrowserContext(profile) 112 extensions::ExtensionRegistryFactory::GetForBrowserContext(profile)
113 ->GenerateInstalledExtensionsSet()); 113 ->GenerateInstalledExtensionsSet());
114 extensions::ExtensionPrefs* extension_prefs = 114 extensions::ExtensionPrefs* extension_prefs =
115 extensions::ExtensionPrefsFactory::GetForBrowserContext(profile); 115 extensions::ExtensionPrefsFactory::GetForBrowserContext(profile);
116 for (const auto& extension : *extensions) { 116 for (const auto& extension : *extensions) {
117 base::Time install_time = 117 base::Time install_time =
118 extension_prefs->GetInstallTime(extension->id()); 118 extension_prefs->GetInstallTime(extension->id());
119 if (install_time > last_install_time) { 119 if (install_time > last_install_time) {
120 last_install_time = install_time; 120 last_install_time = install_time;
121 last_installed_extension = extension; 121 last_installed_extension = extension;
122 profile_for_last_installed_extension = profile; 122 profile_for_last_installed_extension = profile;
123 } 123 }
124 } 124 }
125 } 125 }
126 126
127 if (last_installed_extension && profile_for_last_installed_extension) { 127 if (last_installed_extension && profile_for_last_installed_extension) {
128 PopulateExtensionInfo( 128 PopulateExtensionInfo(
129 *last_installed_extension, 129 *last_installed_extension,
130 *extensions::ExtensionPrefs::Get(profile_for_last_installed_extension), 130 *extensions::ExtensionPrefs::Get(profile_for_last_installed_extension),
131 *extensions::ExtensionRegistryFactory::GetForBrowserContext( 131 *extensions::ExtensionRegistryFactory::GetForBrowserContext(
132 profile_for_last_installed_extension), 132 profile_for_last_installed_extension),
133 data->mutable_last_installed_extension()); 133 data->mutable_last_installed_extension());
134 } 134 }
135 #endif 135 #endif
136 } 136 }
137 137
138 } // namespace safe_browsing 138 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698