| 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/metrics/sparse_histogram.h" |
| 9 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 11 #include "base/threading/thread_restrictions.h" | 12 #include "base/threading/thread_restrictions.h" |
| 12 #include "base/values.h" | 13 #include "base/values.h" |
| 13 #include "chrome/browser/browser_process.h" | 14 #include "chrome/browser/browser_process.h" |
| 14 #include "chrome/browser/extensions/extension_action_manager.h" | 15 #include "chrome/browser/extensions/extension_action_manager.h" |
| 15 #include "chrome/browser/extensions/extension_error_reporter.h" | 16 #include "chrome/browser/extensions/extension_error_reporter.h" |
| 16 #include "chrome/browser/extensions/extension_service.h" | 17 #include "chrome/browser/extensions/extension_service.h" |
| 17 #include "chrome/browser/extensions/extension_util.h" | 18 #include "chrome/browser/extensions/extension_util.h" |
| 18 #include "chrome/browser/profiles/profile_manager.h" | 19 #include "chrome/browser/profiles/profile_manager.h" |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 void RecordCreationFlags(const Extension* extension) { | 128 void RecordCreationFlags(const Extension* extension) { |
| 128 for (int i = 0; i < Extension::kInitFromValueFlagBits; ++i) { | 129 for (int i = 0; i < Extension::kInitFromValueFlagBits; ++i) { |
| 129 int flag = 1 << i; | 130 int flag = 1 << i; |
| 130 if (extension->creation_flags() & flag) { | 131 if (extension->creation_flags() & flag) { |
| 131 UMA_HISTOGRAM_ENUMERATION( | 132 UMA_HISTOGRAM_ENUMERATION( |
| 132 "Extensions.LoadCreationFlags", i, Extension::kInitFromValueFlagBits); | 133 "Extensions.LoadCreationFlags", i, Extension::kInitFromValueFlagBits); |
| 133 } | 134 } |
| 134 } | 135 } |
| 135 } | 136 } |
| 136 | 137 |
| 138 // Helper to record a single disable reason histogram value (see |
| 139 // RecordDisableReasons below). |
| 140 void RecordDisbleReasonHistogram(int reason) { |
| 141 UMA_HISTOGRAM_SPARSE_SLOWLY("Extensions.DisableReason", reason); |
| 142 } |
| 143 |
| 144 // Records the disable reasons for a single extension grouped by |
| 145 // Extension::DisableReason. |
| 146 void RecordDisableReasons(int reasons) { |
| 147 // |reasons| is a bitmask with values from Extension::DisabledReason |
| 148 // which are increasing powers of 2. |
| 149 if (reasons == Extension::DISABLE_NONE) { |
| 150 RecordDisbleReasonHistogram(Extension::DISABLE_NONE); |
| 151 return; |
| 152 } |
| 153 for (int reason = 1; reason < Extension::DISABLE_REASON_LAST; reason <<= 1) { |
| 154 if (reasons & reason) |
| 155 RecordDisbleReasonHistogram(reason); |
| 156 } |
| 157 } |
| 158 |
| 137 } // namespace | 159 } // namespace |
| 138 | 160 |
| 139 InstalledLoader::InstalledLoader(ExtensionService* extension_service) | 161 InstalledLoader::InstalledLoader(ExtensionService* extension_service) |
| 140 : extension_service_(extension_service), | 162 : extension_service_(extension_service), |
| 141 extension_registry_(ExtensionRegistry::Get(extension_service->profile())), | 163 extension_registry_(ExtensionRegistry::Get(extension_service->profile())), |
| 142 extension_prefs_(ExtensionPrefs::Get(extension_service->profile())) {} | 164 extension_prefs_(ExtensionPrefs::Get(extension_service->profile())) {} |
| 143 | 165 |
| 144 InstalledLoader::~InstalledLoader() { | 166 InstalledLoader::~InstalledLoader() { |
| 145 } | 167 } |
| 146 | 168 |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 466 | 488 |
| 467 const ExtensionSet& disabled_extensions = | 489 const ExtensionSet& disabled_extensions = |
| 468 extension_registry_->disabled_extensions(); | 490 extension_registry_->disabled_extensions(); |
| 469 | 491 |
| 470 for (ExtensionSet::const_iterator ex = disabled_extensions.begin(); | 492 for (ExtensionSet::const_iterator ex = disabled_extensions.begin(); |
| 471 ex != disabled_extensions.end(); | 493 ex != disabled_extensions.end(); |
| 472 ++ex) { | 494 ++ex) { |
| 473 if (extension_prefs_->DidExtensionEscalatePermissions((*ex)->id())) { | 495 if (extension_prefs_->DidExtensionEscalatePermissions((*ex)->id())) { |
| 474 ++disabled_for_permissions_count; | 496 ++disabled_for_permissions_count; |
| 475 } | 497 } |
| 498 RecordDisableReasons(extension_prefs_->GetDisableReasons((*ex)->id())); |
| 476 if (Manifest::IsExternalLocation((*ex)->location())) { | 499 if (Manifest::IsExternalLocation((*ex)->location())) { |
| 477 // See loop above for ENABLED. | 500 // See loop above for ENABLED. |
| 478 if (ManifestURL::UpdatesFromGallery(*ex)) { | 501 if (ManifestURL::UpdatesFromGallery(*ex)) { |
| 479 UMA_HISTOGRAM_ENUMERATION("Extensions.ExternalItemState", | 502 UMA_HISTOGRAM_ENUMERATION("Extensions.ExternalItemState", |
| 480 EXTERNAL_ITEM_WEBSTORE_DISABLED, | 503 EXTERNAL_ITEM_WEBSTORE_DISABLED, |
| 481 EXTERNAL_ITEM_MAX_ITEMS); | 504 EXTERNAL_ITEM_MAX_ITEMS); |
| 482 } else { | 505 } else { |
| 483 UMA_HISTOGRAM_ENUMERATION("Extensions.ExternalItemState", | 506 UMA_HISTOGRAM_ENUMERATION("Extensions.ExternalItemState", |
| 484 EXTERNAL_ITEM_NONWEBSTORE_DISABLED, | 507 EXTERNAL_ITEM_NONWEBSTORE_DISABLED, |
| 485 EXTERNAL_ITEM_MAX_ITEMS); | 508 EXTERNAL_ITEM_MAX_ITEMS); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 535 incognito_allowed_count); | 558 incognito_allowed_count); |
| 536 UMA_HISTOGRAM_COUNTS_100("Extensions.IncognitoNotAllowed", | 559 UMA_HISTOGRAM_COUNTS_100("Extensions.IncognitoNotAllowed", |
| 537 incognito_not_allowed_count); | 560 incognito_not_allowed_count); |
| 538 } | 561 } |
| 539 if (file_access_allowed_count + file_access_not_allowed_count > 0) { | 562 if (file_access_allowed_count + file_access_not_allowed_count > 0) { |
| 540 UMA_HISTOGRAM_COUNTS_100("Extensions.FileAccessAllowed", | 563 UMA_HISTOGRAM_COUNTS_100("Extensions.FileAccessAllowed", |
| 541 file_access_allowed_count); | 564 file_access_allowed_count); |
| 542 UMA_HISTOGRAM_COUNTS_100("Extensions.FileAccessNotAllowed", | 565 UMA_HISTOGRAM_COUNTS_100("Extensions.FileAccessNotAllowed", |
| 543 file_access_not_allowed_count); | 566 file_access_not_allowed_count); |
| 544 } | 567 } |
| 568 UMA_HISTOGRAM_COUNTS_100("Extensions.CorruptExtensionTotalDisables", |
| 569 extension_prefs_->GetCorruptedDisableCount()); |
| 545 } | 570 } |
| 546 | 571 |
| 547 int InstalledLoader::GetCreationFlags(const ExtensionInfo* info) { | 572 int InstalledLoader::GetCreationFlags(const ExtensionInfo* info) { |
| 548 int flags = extension_prefs_->GetCreationFlags(info->extension_id); | 573 int flags = extension_prefs_->GetCreationFlags(info->extension_id); |
| 549 if (!Manifest::IsUnpackedLocation(info->extension_location)) | 574 if (!Manifest::IsUnpackedLocation(info->extension_location)) |
| 550 flags |= Extension::REQUIRE_KEY; | 575 flags |= Extension::REQUIRE_KEY; |
| 551 if (extension_prefs_->AllowFileAccess(info->extension_id)) | 576 if (extension_prefs_->AllowFileAccess(info->extension_id)) |
| 552 flags |= Extension::ALLOW_FILE_ACCESS; | 577 flags |= Extension::ALLOW_FILE_ACCESS; |
| 553 return flags; | 578 return flags; |
| 554 } | 579 } |
| 555 | 580 |
| 556 } // namespace extensions | 581 } // namespace extensions |
| OLD | NEW |