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

Side by Side Diff: chrome/browser/extensions/installed_loader.cc

Issue 14973007: Auto-install/uninstall shared module dependencies for extensions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased Created 7 years, 6 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/installed_loader.h" 5 #include "chrome/browser/extensions/installed_loader.h"
6 6
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 void InstalledLoader::LoadAllExtensions() { 157 void InstalledLoader::LoadAllExtensions() {
158 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 158 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
159 159
160 base::TimeTicks start_time = base::TimeTicks::Now(); 160 base::TimeTicks start_time = base::TimeTicks::Now();
161 161
162 scoped_ptr<ExtensionPrefs::ExtensionsInfo> extensions_info( 162 scoped_ptr<ExtensionPrefs::ExtensionsInfo> extensions_info(
163 extension_prefs_->GetInstalledExtensionsInfo()); 163 extension_prefs_->GetInstalledExtensionsInfo());
164 164
165 std::vector<int> reload_reason_counts(NUM_MANIFEST_RELOAD_REASONS, 0); 165 std::vector<int> reload_reason_counts(NUM_MANIFEST_RELOAD_REASONS, 0);
166 bool should_write_prefs = false; 166 bool should_write_prefs = false;
167 int update_count = 0;
168 167
169 for (size_t i = 0; i < extensions_info->size(); ++i) { 168 for (size_t i = 0; i < extensions_info->size(); ++i) {
170 ExtensionInfo* info = extensions_info->at(i).get(); 169 ExtensionInfo* info = extensions_info->at(i).get();
171 170
172 // Skip extensions that were loaded from the command-line because we don't 171 // Skip extensions that were loaded from the command-line because we don't
173 // want those to persist across browser restart. 172 // want those to persist across browser restart.
174 if (info->extension_location == Manifest::COMMAND_LINE) 173 if (info->extension_location == Manifest::COMMAND_LINE)
175 continue; 174 continue;
176 175
177 scoped_ptr<ExtensionInfo> pending_update(
178 extension_prefs_->GetDelayedInstallInfo(info->extension_id));
179 if (pending_update) {
180 if (!extension_prefs_->FinishDelayedInstallInfo(info->extension_id))
181 NOTREACHED();
182
183 Version old_version;
184 if (info->extension_manifest) {
185 std::string version_str;
186 if (info->extension_manifest->GetString(
187 extension_manifest_keys::kVersion, &version_str)) {
188 old_version = Version(version_str);
189 }
190 }
191 base::MessageLoop::current()->PostTask(FROM_HERE,
192 base::Bind(&DispatchOnInstalledEvent, extension_service_->profile(),
193 info->extension_id, old_version, false));
194
195 info = extension_prefs_->GetInstalledExtensionInfo(
196 info->extension_id).release();
197 extensions_info->at(i).reset(info);
198
199 update_count++;
200 }
201
202 ManifestReloadReason reload_reason = ShouldReloadExtensionManifest(*info); 176 ManifestReloadReason reload_reason = ShouldReloadExtensionManifest(*info);
203 ++reload_reason_counts[reload_reason]; 177 ++reload_reason_counts[reload_reason];
204 UMA_HISTOGRAM_ENUMERATION("Extensions.ManifestReloadEnumValue", 178 UMA_HISTOGRAM_ENUMERATION("Extensions.ManifestReloadEnumValue",
205 reload_reason, 100); 179 reload_reason, 100);
206 180
207 if (reload_reason != NOT_NEEDED) { 181 if (reload_reason != NOT_NEEDED) {
208 // Reloading an extension reads files from disk. We do this on the 182 // Reloading an extension reads files from disk. We do this on the
209 // UI thread because reloads should be very rare, and the complexity 183 // UI thread because reloads should be very rare, and the complexity
210 // added by delaying the time when the extensions service knows about 184 // added by delaying the time when the extensions service knows about
211 // all extensions is significant. See crbug.com/37548 for details. 185 // all extensions is significant. See crbug.com/37548 for details.
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 reload_reason_counts[NOT_NEEDED]); 222 reload_reason_counts[NOT_NEEDED]);
249 UMA_HISTOGRAM_COUNTS_100("Extensions.ManifestReloadUnpackedDir", 223 UMA_HISTOGRAM_COUNTS_100("Extensions.ManifestReloadUnpackedDir",
250 reload_reason_counts[UNPACKED_DIR]); 224 reload_reason_counts[UNPACKED_DIR]);
251 UMA_HISTOGRAM_COUNTS_100("Extensions.ManifestReloadNeedsRelocalization", 225 UMA_HISTOGRAM_COUNTS_100("Extensions.ManifestReloadNeedsRelocalization",
252 reload_reason_counts[NEEDS_RELOCALIZATION]); 226 reload_reason_counts[NEEDS_RELOCALIZATION]);
253 227
254 UMA_HISTOGRAM_COUNTS_100("Extensions.LoadAll", 228 UMA_HISTOGRAM_COUNTS_100("Extensions.LoadAll",
255 extension_service_->extensions()->size()); 229 extension_service_->extensions()->size());
256 UMA_HISTOGRAM_COUNTS_100("Extensions.Disabled", 230 UMA_HISTOGRAM_COUNTS_100("Extensions.Disabled",
257 extension_service_->disabled_extensions()->size()); 231 extension_service_->disabled_extensions()->size());
258 UMA_HISTOGRAM_COUNTS_100("Extensions.UpdateOnLoad",
259 update_count);
260 232
261 UMA_HISTOGRAM_TIMES("Extensions.LoadAllTime", 233 UMA_HISTOGRAM_TIMES("Extensions.LoadAllTime",
262 base::TimeTicks::Now() - start_time); 234 base::TimeTicks::Now() - start_time);
263 235
264 int app_user_count = 0; 236 int app_user_count = 0;
265 int app_external_count = 0; 237 int app_external_count = 0;
266 int hosted_app_count = 0; 238 int hosted_app_count = 0;
267 int legacy_packaged_app_count = 0; 239 int legacy_packaged_app_count = 0;
268 int platform_app_count = 0; 240 int platform_app_count = 0;
269 int user_script_count = 0; 241 int user_script_count = 0;
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 int InstalledLoader::GetCreationFlags(const ExtensionInfo* info) { 377 int InstalledLoader::GetCreationFlags(const ExtensionInfo* info) {
406 int flags = extension_prefs_->GetCreationFlags(info->extension_id); 378 int flags = extension_prefs_->GetCreationFlags(info->extension_id);
407 if (!Manifest::IsUnpackedLocation(info->extension_location)) 379 if (!Manifest::IsUnpackedLocation(info->extension_location))
408 flags |= Extension::REQUIRE_KEY; 380 flags |= Extension::REQUIRE_KEY;
409 if (extension_prefs_->AllowFileAccess(info->extension_id)) 381 if (extension_prefs_->AllowFileAccess(info->extension_id))
410 flags |= Extension::ALLOW_FILE_ACCESS; 382 flags |= Extension::ALLOW_FILE_ACCESS;
411 return flags; 383 return flags;
412 } 384 }
413 385
414 } // namespace extensions 386 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_service_unittest.cc ('k') | chrome/browser/extensions/pending_extension_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698