Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 216 ExtensionInfo* info = extensions_info->at(i).get(); | 216 ExtensionInfo* info = extensions_info->at(i).get(); |
| 217 | 217 |
| 218 // Skip extensions that were loaded from the command-line because we don't | 218 // Skip extensions that were loaded from the command-line because we don't |
| 219 // want those to persist across browser restart. | 219 // want those to persist across browser restart. |
| 220 if (info->extension_location == Manifest::COMMAND_LINE) | 220 if (info->extension_location == Manifest::COMMAND_LINE) |
| 221 continue; | 221 continue; |
| 222 | 222 |
| 223 ManifestReloadReason reload_reason = ShouldReloadExtensionManifest(*info); | 223 ManifestReloadReason reload_reason = ShouldReloadExtensionManifest(*info); |
| 224 ++reload_reason_counts[reload_reason]; | 224 ++reload_reason_counts[reload_reason]; |
| 225 UMA_HISTOGRAM_ENUMERATION("Extensions.ManifestReloadEnumValue", | 225 UMA_HISTOGRAM_ENUMERATION("Extensions.ManifestReloadEnumValue", |
| 226 reload_reason, 100); | 226 reload_reason, 100); |
|
jar (doing other things)
2014/05/20 17:43:34
This should use a precise top value + 1, rather th
not at google - send to devlin
2014/05/21 19:46:43
Done.
| |
| 227 | 227 |
| 228 if (reload_reason != NOT_NEEDED) { | 228 if (reload_reason != NOT_NEEDED) { |
| 229 // Reloading an extension reads files from disk. We do this on the | 229 // Reloading an extension reads files from disk. We do this on the |
| 230 // UI thread because reloads should be very rare, and the complexity | 230 // UI thread because reloads should be very rare, and the complexity |
| 231 // added by delaying the time when the extensions service knows about | 231 // added by delaying the time when the extensions service knows about |
| 232 // all extensions is significant. See crbug.com/37548 for details. | 232 // all extensions is significant. See crbug.com/37548 for details. |
| 233 // |allow_io| disables tests that file operations run on the file | 233 // |allow_io| disables tests that file operations run on the file |
| 234 // thread. | 234 // thread. |
| 235 base::ThreadRestrictions::ScopedAllowIO allow_io; | 235 base::ThreadRestrictions::ScopedAllowIO allow_io; |
| 236 | 236 |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 309 ++iter) { | 309 ++iter) { |
| 310 const Extension* extension = *iter; | 310 const Extension* extension = *iter; |
| 311 Manifest::Location location = extension->location(); | 311 Manifest::Location location = extension->location(); |
| 312 Manifest::Type type = extension->GetType(); | 312 Manifest::Type type = extension->GetType(); |
| 313 | 313 |
| 314 // For the first few metrics, include all extensions and apps (component, | 314 // For the first few metrics, include all extensions and apps (component, |
| 315 // unpacked, etc). It's good to know these locations, and it doesn't | 315 // unpacked, etc). It's good to know these locations, and it doesn't |
| 316 // muck up any of the stats. Later, though, we want to omit component and | 316 // muck up any of the stats. Later, though, we want to omit component and |
| 317 // unpacked, as they are less interesting. | 317 // unpacked, as they are less interesting. |
| 318 if (extension->is_app()) | 318 if (extension->is_app()) |
| 319 UMA_HISTOGRAM_ENUMERATION("Extensions.AppLocation", location, 100); | 319 UMA_HISTOGRAM_ENUMERATION("Extensions.AppLocation", location, 100); |
|
jar (doing other things)
2014/05/20 17:43:34
All of these histograms should have the more preci
not at google - send to devlin
2014/05/21 19:46:43
Done.
| |
| 320 else if (extension->is_extension()) | 320 else if (extension->is_extension()) |
| 321 UMA_HISTOGRAM_ENUMERATION("Extensions.ExtensionLocation", location, 100); | 321 UMA_HISTOGRAM_ENUMERATION("Extensions.ExtensionLocation", location, 100); |
| 322 | 322 |
| 323 if (!ManifestURL::UpdatesFromGallery(extension)) { | 323 if (!ManifestURL::UpdatesFromGallery(extension)) { |
| 324 UMA_HISTOGRAM_ENUMERATION( | 324 UMA_HISTOGRAM_ENUMERATION( |
| 325 "Extensions.NonWebstoreLocation", location, 100); | 325 "Extensions.NonWebstoreLocation", location, 100); |
| 326 | 326 |
| 327 // Check for inconsistencies if the extension was supposedly installed | 327 // Check for inconsistencies if the extension was supposedly installed |
| 328 // from the webstore. | 328 // from the webstore. |
| 329 enum { | 329 enum { |
| 330 BAD_UPDATE_URL = 0, | 330 BAD_UPDATE_URL = 0, |
| 331 // This value was a mistake. Turns out sideloaded extensions can | 331 // This value was a mistake. Turns out sideloaded extensions can |
| 332 // have the from_webstore bit if they update from the webstore. | 332 // have the from_webstore bit if they update from the webstore. |
| 333 DEPRECATED_IS_EXTERNAL = 1, | 333 DEPRECATED_IS_EXTERNAL = 1, |
| 334 }; | 334 }; |
| 335 if (extension->from_webstore()) { | 335 if (extension->from_webstore()) { |
| 336 UMA_HISTOGRAM_ENUMERATION( | 336 UMA_HISTOGRAM_ENUMERATION( |
| 337 "Extensions.FromWebstoreInconsistency", BAD_UPDATE_URL, 2); | 337 "Extensions.FromWebstoreInconsistency", BAD_UPDATE_URL, 2); |
|
jar (doing other things)
2014/05/20 17:43:34
This uses a histogram as a counter, as I can't fin
not at google - send to devlin
2014/05/21 19:46:43
yeah I have no idea what this histogram is suppose
| |
| 338 } | 338 } |
| 339 } | 339 } |
| 340 | 340 |
| 341 if (Manifest::IsExternalLocation(location)) { | 341 if (Manifest::IsExternalLocation(location)) { |
| 342 // See loop below for DISABLED. | 342 // See loop below for DISABLED. |
| 343 if (ManifestURL::UpdatesFromGallery(extension)) { | 343 if (ManifestURL::UpdatesFromGallery(extension)) { |
| 344 UMA_HISTOGRAM_ENUMERATION("Extensions.ExternalItemState", | 344 UMA_HISTOGRAM_ENUMERATION("Extensions.ExternalItemState", |
| 345 EXTERNAL_ITEM_WEBSTORE_ENABLED, | 345 EXTERNAL_ITEM_WEBSTORE_ENABLED, |
| 346 EXTERNAL_ITEM_MAX_ITEMS); | 346 EXTERNAL_ITEM_MAX_ITEMS); |
| 347 } else { | 347 } else { |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 363 URLOverrides::GetChromeURLOverrides(extension).count("newtab")) { | 363 URLOverrides::GetChromeURLOverrides(extension).count("newtab")) { |
| 364 ++non_webstore_ntp_override_count; | 364 ++non_webstore_ntp_override_count; |
| 365 } | 365 } |
| 366 | 366 |
| 367 // Don't count unpacked extensions anymore, either. | 367 // Don't count unpacked extensions anymore, either. |
| 368 if (Manifest::IsUnpackedLocation(location)) | 368 if (Manifest::IsUnpackedLocation(location)) |
| 369 continue; | 369 continue; |
| 370 | 370 |
| 371 UMA_HISTOGRAM_ENUMERATION("Extensions.ManifestVersion", | 371 UMA_HISTOGRAM_ENUMERATION("Extensions.ManifestVersion", |
| 372 extension->manifest_version(), | 372 extension->manifest_version(), |
| 373 10); | 373 10); |
|
jar (doing other things)
2014/05/20 17:43:34
Why did you use 10 here? Better would be a limit,
not at google - send to devlin
2014/05/21 19:46:43
This is basically going to be either 1 or 2 at the
jar (doing other things)
2014/05/22 02:19:07
Most histograms are implemented (under the covers)
| |
| 374 | 374 |
| 375 // We might have wanted to count legacy packaged apps here, too, since they | 375 // We might have wanted to count legacy packaged apps here, too, since they |
| 376 // are effectively extensions. Unfortunately, it's too late, as we don't | 376 // are effectively extensions. Unfortunately, it's too late, as we don't |
| 377 // want to mess up the existing stats. | 377 // want to mess up the existing stats. |
| 378 if (type == Manifest::TYPE_EXTENSION) { | 378 if (type == Manifest::TYPE_EXTENSION) { |
| 379 UMA_HISTOGRAM_ENUMERATION("Extensions.BackgroundPageType", | 379 UMA_HISTOGRAM_ENUMERATION("Extensions.BackgroundPageType", |
| 380 GetBackgroundPageType(extension), | 380 GetBackgroundPageType(extension), |
| 381 10); | 381 10); |
| 382 } | 382 } |
| 383 | 383 |
| 384 // Using an enumeration shows us the total installed ratio across all users. | 384 // Using an enumeration shows us the total installed ratio across all users. |
| 385 // Using the totals per user at each startup tells us the distribution of | 385 // Using the totals per user at each startup tells us the distribution of |
| 386 // usage for each user (e.g. 40% of users have at least one app installed). | 386 // usage for each user (e.g. 40% of users have at least one app installed). |
| 387 UMA_HISTOGRAM_ENUMERATION("Extensions.LoadType", type, 100); | 387 UMA_HISTOGRAM_ENUMERATION("Extensions.LoadType", type, 100); |
|
jar (doing other things)
2014/05/20 17:43:34
Here again, rather than 100, I think the numeber i
not at google - send to devlin
2014/05/21 19:46:43
Done.
| |
| 388 switch (type) { | 388 switch (type) { |
| 389 case Manifest::TYPE_THEME: | 389 case Manifest::TYPE_THEME: |
| 390 ++theme_count; | 390 ++theme_count; |
| 391 break; | 391 break; |
| 392 case Manifest::TYPE_USER_SCRIPT: | 392 case Manifest::TYPE_USER_SCRIPT: |
| 393 ++user_script_count; | 393 ++user_script_count; |
| 394 break; | 394 break; |
| 395 case Manifest::TYPE_HOSTED_APP: | 395 case Manifest::TYPE_HOSTED_APP: |
| 396 ++hosted_app_count; | 396 ++hosted_app_count; |
| 397 if (Manifest::IsExternalLocation(location)) { | 397 if (Manifest::IsExternalLocation(location)) { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 436 | 436 |
| 437 if (ManagedModeInfo::IsContentPack(extension)) | 437 if (ManagedModeInfo::IsContentPack(extension)) |
| 438 ++content_pack_count; | 438 ++content_pack_count; |
| 439 | 439 |
| 440 RecordCreationFlags(extension); | 440 RecordCreationFlags(extension); |
| 441 | 441 |
| 442 ExtensionService::RecordPermissionMessagesHistogram( | 442 ExtensionService::RecordPermissionMessagesHistogram( |
| 443 extension, "Extensions.Permissions_Load"); | 443 extension, "Extensions.Permissions_Load"); |
| 444 | 444 |
| 445 // For incognito and file access, skip anything that doesn't appear in | 445 // For incognito and file access, skip anything that doesn't appear in |
| 446 // settings. | 446 // settings. Also, policy-installed (and unpacked of course, checked above) |
| 447 if (extension->ShouldDisplayInExtensionSettings()) { | 447 // extensions are boring. |
| 448 if (extension->ShouldDisplayInExtensionSettings() && | |
| 449 !Manifest::IsPolicyLocation(extension->location())) { | |
| 448 if (extension->can_be_incognito_enabled()) { | 450 if (extension->can_be_incognito_enabled()) { |
| 449 if (util::IsIncognitoEnabled(extension->id(), profile)) | 451 if (util::IsIncognitoEnabled(extension->id(), profile)) |
| 450 ++incognito; | 452 ++incognito; |
| 451 else | 453 else |
| 452 ++not_incognito; | 454 ++not_incognito; |
| 453 } | 455 } |
| 454 if (extension->wants_file_access()) { | 456 if (extension->wants_file_access()) { |
| 455 if (util::AllowFileAccess(extension->id(), profile)) | 457 if (util::AllowFileAccess(extension->id(), profile)) |
| 456 ++file_access; | 458 ++file_access; |
| 457 else | 459 else |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 520 UMA_HISTOGRAM_COUNTS_100("Extensions.LoadUserScript", user_script_count); | 522 UMA_HISTOGRAM_COUNTS_100("Extensions.LoadUserScript", user_script_count); |
| 521 UMA_HISTOGRAM_COUNTS_100("Extensions.LoadTheme", theme_count); | 523 UMA_HISTOGRAM_COUNTS_100("Extensions.LoadTheme", theme_count); |
| 522 UMA_HISTOGRAM_COUNTS_100("Extensions.LoadPageAction", page_action_count); | 524 UMA_HISTOGRAM_COUNTS_100("Extensions.LoadPageAction", page_action_count); |
| 523 UMA_HISTOGRAM_COUNTS_100("Extensions.LoadBrowserAction", | 525 UMA_HISTOGRAM_COUNTS_100("Extensions.LoadBrowserAction", |
| 524 browser_action_count); | 526 browser_action_count); |
| 525 UMA_HISTOGRAM_COUNTS_100("Extensions.LoadContentPack", content_pack_count); | 527 UMA_HISTOGRAM_COUNTS_100("Extensions.LoadContentPack", content_pack_count); |
| 526 UMA_HISTOGRAM_COUNTS_100("Extensions.DisabledForPermissions", | 528 UMA_HISTOGRAM_COUNTS_100("Extensions.DisabledForPermissions", |
| 527 disabled_for_permissions_count); | 529 disabled_for_permissions_count); |
| 528 UMA_HISTOGRAM_COUNTS_100("Extensions.NonWebStoreNewTabPageOverrides", | 530 UMA_HISTOGRAM_COUNTS_100("Extensions.NonWebStoreNewTabPageOverrides", |
| 529 non_webstore_ntp_override_count); | 531 non_webstore_ntp_override_count); |
| 530 UMA_HISTOGRAM_COUNTS_100("Extensions.IncognitoAllowed", incognito); | 532 if (incognito + not_incognito > 0) { |
|
jar (doing other things)
2014/05/20 17:43:34
nit: the above is seemingly meant to be clever, bu
not at google - send to devlin
2014/05/20 17:53:10
We only just added this metric (a few days ago), s
not at google - send to devlin
2014/05/20 18:06:20
I can change it but I think the existing condition
jar (doing other things)
2014/05/21 00:27:20
If you're really enamoured with using the sum, you
not at google - send to devlin
2014/05/21 01:38:48
That change SGTM. I'll come back to this CL tomorr
| |
| 531 UMA_HISTOGRAM_COUNTS_100("Extensions.IncognitoNotAllowed", not_incognito); | 533 UMA_HISTOGRAM_COUNTS_100("Extensions.IncognitoAllowed", incognito); |
| 532 UMA_HISTOGRAM_COUNTS_100("Extensions.FileAccessAllowed", file_access); | 534 UMA_HISTOGRAM_COUNTS_100("Extensions.IncognitoNotAllowed", not_incognito); |
| 533 UMA_HISTOGRAM_COUNTS_100("Extensions.FileAccessNotAllowed", not_file_access); | 535 } |
| 536 if (file_access + not_file_access > 0) { | |
| 537 UMA_HISTOGRAM_COUNTS_100("Extensions.FileAccessAllowed", file_access); | |
| 538 UMA_HISTOGRAM_COUNTS_100("Extensions.FileAccessNotAllowed", | |
| 539 not_file_access); | |
| 540 } | |
| 534 } | 541 } |
| 535 | 542 |
| 536 int InstalledLoader::GetCreationFlags(const ExtensionInfo* info) { | 543 int InstalledLoader::GetCreationFlags(const ExtensionInfo* info) { |
| 537 int flags = extension_prefs_->GetCreationFlags(info->extension_id); | 544 int flags = extension_prefs_->GetCreationFlags(info->extension_id); |
| 538 if (!Manifest::IsUnpackedLocation(info->extension_location)) | 545 if (!Manifest::IsUnpackedLocation(info->extension_location)) |
| 539 flags |= Extension::REQUIRE_KEY; | 546 flags |= Extension::REQUIRE_KEY; |
| 540 if (extension_prefs_->AllowFileAccess(info->extension_id)) | 547 if (extension_prefs_->AllowFileAccess(info->extension_id)) |
| 541 flags |= Extension::ALLOW_FILE_ACCESS; | 548 flags |= Extension::ALLOW_FILE_ACCESS; |
| 542 return flags; | 549 return flags; |
| 543 } | 550 } |
| 544 | 551 |
| 545 } // namespace extensions | 552 } // namespace extensions |
| OLD | NEW |