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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
127 void RecordCreationFlags(const Extension* extension) { | 127 void RecordCreationFlags(const Extension* extension) { |
128 for (int i = 0; i < Extension::kInitFromValueFlagBits; ++i) { | 128 for (int i = 0; i < Extension::kInitFromValueFlagBits; ++i) { |
129 int flag = 1 << i; | 129 int flag = 1 << i; |
130 if (extension->creation_flags() & flag) { | 130 if (extension->creation_flags() & flag) { |
131 UMA_HISTOGRAM_ENUMERATION( | 131 UMA_HISTOGRAM_ENUMERATION( |
132 "Extensions.LoadCreationFlags", i, Extension::kInitFromValueFlagBits); | 132 "Extensions.LoadCreationFlags", i, Extension::kInitFromValueFlagBits); |
133 } | 133 } |
134 } | 134 } |
135 } | 135 } |
136 | 136 |
137 // Records the disable reasons for a single extension grouped by | |
138 // Extension::DisableReason. | |
139 void RecordDisableReasons(int reasons) { | |
140 // |reasons| is a bitmask with values from Extension::DisabledReason | |
141 // which are increasing powers of 2. | |
142 if (reasons == Extension::DISABLE_NONE) { | |
143 UMA_HISTOGRAM_ENUMERATION("Extensions.DisableReason", | |
144 Extension::DISABLE_NONE, | |
145 Extension::DISABLE_REASON_LAST); | |
Ilya Sherman
2014/07/24 21:55:51
Please define a small wrapper function around this
asargent_no_longer_on_chrome
2014/07/25 00:09:16
Done.
| |
146 return; | |
147 } | |
148 for (int reason = 1; reason < Extension::DISABLE_REASON_LAST; reason <<= 1) { | |
149 if (reasons & reason) | |
150 UMA_HISTOGRAM_ENUMERATION( | |
151 "Extensions.DisableReason", reason, Extension::DISABLE_REASON_LAST); | |
Ilya Sherman
2014/07/24 21:55:51
UMA_HISTOGRAM_ENUMERATION allocates a vector to ba
asargent_no_longer_on_chrome
2014/07/25 00:09:16
Done.
| |
152 } | |
153 } | |
154 | |
137 } // namespace | 155 } // namespace |
138 | 156 |
139 InstalledLoader::InstalledLoader(ExtensionService* extension_service) | 157 InstalledLoader::InstalledLoader(ExtensionService* extension_service) |
140 : extension_service_(extension_service), | 158 : extension_service_(extension_service), |
141 extension_registry_(ExtensionRegistry::Get(extension_service->profile())), | 159 extension_registry_(ExtensionRegistry::Get(extension_service->profile())), |
142 extension_prefs_(ExtensionPrefs::Get(extension_service->profile())) {} | 160 extension_prefs_(ExtensionPrefs::Get(extension_service->profile())) {} |
143 | 161 |
144 InstalledLoader::~InstalledLoader() { | 162 InstalledLoader::~InstalledLoader() { |
145 } | 163 } |
146 | 164 |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
466 | 484 |
467 const ExtensionSet& disabled_extensions = | 485 const ExtensionSet& disabled_extensions = |
468 extension_registry_->disabled_extensions(); | 486 extension_registry_->disabled_extensions(); |
469 | 487 |
470 for (ExtensionSet::const_iterator ex = disabled_extensions.begin(); | 488 for (ExtensionSet::const_iterator ex = disabled_extensions.begin(); |
471 ex != disabled_extensions.end(); | 489 ex != disabled_extensions.end(); |
472 ++ex) { | 490 ++ex) { |
473 if (extension_prefs_->DidExtensionEscalatePermissions((*ex)->id())) { | 491 if (extension_prefs_->DidExtensionEscalatePermissions((*ex)->id())) { |
474 ++disabled_for_permissions_count; | 492 ++disabled_for_permissions_count; |
475 } | 493 } |
494 RecordDisableReasons(extension_prefs_->GetDisableReasons((*ex)->id())); | |
476 if (Manifest::IsExternalLocation((*ex)->location())) { | 495 if (Manifest::IsExternalLocation((*ex)->location())) { |
477 // See loop above for ENABLED. | 496 // See loop above for ENABLED. |
478 if (ManifestURL::UpdatesFromGallery(*ex)) { | 497 if (ManifestURL::UpdatesFromGallery(*ex)) { |
479 UMA_HISTOGRAM_ENUMERATION("Extensions.ExternalItemState", | 498 UMA_HISTOGRAM_ENUMERATION("Extensions.ExternalItemState", |
480 EXTERNAL_ITEM_WEBSTORE_DISABLED, | 499 EXTERNAL_ITEM_WEBSTORE_DISABLED, |
481 EXTERNAL_ITEM_MAX_ITEMS); | 500 EXTERNAL_ITEM_MAX_ITEMS); |
482 } else { | 501 } else { |
483 UMA_HISTOGRAM_ENUMERATION("Extensions.ExternalItemState", | 502 UMA_HISTOGRAM_ENUMERATION("Extensions.ExternalItemState", |
484 EXTERNAL_ITEM_NONWEBSTORE_DISABLED, | 503 EXTERNAL_ITEM_NONWEBSTORE_DISABLED, |
485 EXTERNAL_ITEM_MAX_ITEMS); | 504 EXTERNAL_ITEM_MAX_ITEMS); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
535 incognito_allowed_count); | 554 incognito_allowed_count); |
536 UMA_HISTOGRAM_COUNTS_100("Extensions.IncognitoNotAllowed", | 555 UMA_HISTOGRAM_COUNTS_100("Extensions.IncognitoNotAllowed", |
537 incognito_not_allowed_count); | 556 incognito_not_allowed_count); |
538 } | 557 } |
539 if (file_access_allowed_count + file_access_not_allowed_count > 0) { | 558 if (file_access_allowed_count + file_access_not_allowed_count > 0) { |
540 UMA_HISTOGRAM_COUNTS_100("Extensions.FileAccessAllowed", | 559 UMA_HISTOGRAM_COUNTS_100("Extensions.FileAccessAllowed", |
541 file_access_allowed_count); | 560 file_access_allowed_count); |
542 UMA_HISTOGRAM_COUNTS_100("Extensions.FileAccessNotAllowed", | 561 UMA_HISTOGRAM_COUNTS_100("Extensions.FileAccessNotAllowed", |
543 file_access_not_allowed_count); | 562 file_access_not_allowed_count); |
544 } | 563 } |
564 UMA_HISTOGRAM_COUNTS_100("Extensions.CorruptExtensionTotalDisables", | |
565 extension_prefs_->GetCorruptedDisableCount()); | |
545 } | 566 } |
546 | 567 |
547 int InstalledLoader::GetCreationFlags(const ExtensionInfo* info) { | 568 int InstalledLoader::GetCreationFlags(const ExtensionInfo* info) { |
548 int flags = extension_prefs_->GetCreationFlags(info->extension_id); | 569 int flags = extension_prefs_->GetCreationFlags(info->extension_id); |
549 if (!Manifest::IsUnpackedLocation(info->extension_location)) | 570 if (!Manifest::IsUnpackedLocation(info->extension_location)) |
550 flags |= Extension::REQUIRE_KEY; | 571 flags |= Extension::REQUIRE_KEY; |
551 if (extension_prefs_->AllowFileAccess(info->extension_id)) | 572 if (extension_prefs_->AllowFileAccess(info->extension_id)) |
552 flags |= Extension::ALLOW_FILE_ACCESS; | 573 flags |= Extension::ALLOW_FILE_ACCESS; |
553 return flags; | 574 return flags; |
554 } | 575 } |
555 | 576 |
556 } // namespace extensions | 577 } // namespace extensions |
OLD | NEW |