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 diable reasons for a single extension grouped by | |
Ken Rockot(use gerrit already)
2014/07/24 03:56:02
nit: disable
asargent_no_longer_on_chrome
2014/07/24 17:08:12
Done.
| |
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 int shift = 0; | |
143 for (int reason = (1 << shift); reason < Extension::DISABLE_REASON_LAST; | |
144 reason = (1 << ++shift)) { | |
Ken Rockot(use gerrit already)
2014/07/24 03:56:02
What about:
for (int reason = 1; reason < ...; re
asargent_no_longer_on_chrome
2014/07/24 17:08:12
Done.
| |
145 if ((reason == 0 && reasons == 0) || reasons & reason) | |
Ken Rockot(use gerrit already)
2014/07/24 03:56:02
OK now I'm confused; I don't think reason can ever
asargent_no_longer_on_chrome
2014/07/24 17:08:12
And this is why we have code review! I did some re
| |
146 UMA_HISTOGRAM_ENUMERATION( | |
147 "Extensions.DisableReason", reason, Extension::DISABLE_REASON_LAST); | |
148 if (reasons == 0) | |
149 break; | |
150 } | |
151 } | |
152 | |
137 } // namespace | 153 } // namespace |
138 | 154 |
139 InstalledLoader::InstalledLoader(ExtensionService* extension_service) | 155 InstalledLoader::InstalledLoader(ExtensionService* extension_service) |
140 : extension_service_(extension_service), | 156 : extension_service_(extension_service), |
141 extension_registry_(ExtensionRegistry::Get(extension_service->profile())), | 157 extension_registry_(ExtensionRegistry::Get(extension_service->profile())), |
142 extension_prefs_(ExtensionPrefs::Get(extension_service->profile())) {} | 158 extension_prefs_(ExtensionPrefs::Get(extension_service->profile())) {} |
143 | 159 |
144 InstalledLoader::~InstalledLoader() { | 160 InstalledLoader::~InstalledLoader() { |
145 } | 161 } |
146 | 162 |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
466 | 482 |
467 const ExtensionSet& disabled_extensions = | 483 const ExtensionSet& disabled_extensions = |
468 extension_registry_->disabled_extensions(); | 484 extension_registry_->disabled_extensions(); |
469 | 485 |
470 for (ExtensionSet::const_iterator ex = disabled_extensions.begin(); | 486 for (ExtensionSet::const_iterator ex = disabled_extensions.begin(); |
471 ex != disabled_extensions.end(); | 487 ex != disabled_extensions.end(); |
472 ++ex) { | 488 ++ex) { |
473 if (extension_prefs_->DidExtensionEscalatePermissions((*ex)->id())) { | 489 if (extension_prefs_->DidExtensionEscalatePermissions((*ex)->id())) { |
474 ++disabled_for_permissions_count; | 490 ++disabled_for_permissions_count; |
475 } | 491 } |
492 RecordDisableReasons(extension_prefs_->GetDisableReasons((*ex)->id())); | |
476 if (Manifest::IsExternalLocation((*ex)->location())) { | 493 if (Manifest::IsExternalLocation((*ex)->location())) { |
477 // See loop above for ENABLED. | 494 // See loop above for ENABLED. |
478 if (ManifestURL::UpdatesFromGallery(*ex)) { | 495 if (ManifestURL::UpdatesFromGallery(*ex)) { |
479 UMA_HISTOGRAM_ENUMERATION("Extensions.ExternalItemState", | 496 UMA_HISTOGRAM_ENUMERATION("Extensions.ExternalItemState", |
480 EXTERNAL_ITEM_WEBSTORE_DISABLED, | 497 EXTERNAL_ITEM_WEBSTORE_DISABLED, |
481 EXTERNAL_ITEM_MAX_ITEMS); | 498 EXTERNAL_ITEM_MAX_ITEMS); |
482 } else { | 499 } else { |
483 UMA_HISTOGRAM_ENUMERATION("Extensions.ExternalItemState", | 500 UMA_HISTOGRAM_ENUMERATION("Extensions.ExternalItemState", |
484 EXTERNAL_ITEM_NONWEBSTORE_DISABLED, | 501 EXTERNAL_ITEM_NONWEBSTORE_DISABLED, |
485 EXTERNAL_ITEM_MAX_ITEMS); | 502 EXTERNAL_ITEM_MAX_ITEMS); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
535 incognito_allowed_count); | 552 incognito_allowed_count); |
536 UMA_HISTOGRAM_COUNTS_100("Extensions.IncognitoNotAllowed", | 553 UMA_HISTOGRAM_COUNTS_100("Extensions.IncognitoNotAllowed", |
537 incognito_not_allowed_count); | 554 incognito_not_allowed_count); |
538 } | 555 } |
539 if (file_access_allowed_count + file_access_not_allowed_count > 0) { | 556 if (file_access_allowed_count + file_access_not_allowed_count > 0) { |
540 UMA_HISTOGRAM_COUNTS_100("Extensions.FileAccessAllowed", | 557 UMA_HISTOGRAM_COUNTS_100("Extensions.FileAccessAllowed", |
541 file_access_allowed_count); | 558 file_access_allowed_count); |
542 UMA_HISTOGRAM_COUNTS_100("Extensions.FileAccessNotAllowed", | 559 UMA_HISTOGRAM_COUNTS_100("Extensions.FileAccessNotAllowed", |
543 file_access_not_allowed_count); | 560 file_access_not_allowed_count); |
544 } | 561 } |
562 UMA_HISTOGRAM_COUNTS_100("Extensions.CorruptExtensionTotalDisables", | |
563 extension_prefs_->GetCorruptedDisableCount()); | |
545 } | 564 } |
546 | 565 |
547 int InstalledLoader::GetCreationFlags(const ExtensionInfo* info) { | 566 int InstalledLoader::GetCreationFlags(const ExtensionInfo* info) { |
548 int flags = extension_prefs_->GetCreationFlags(info->extension_id); | 567 int flags = extension_prefs_->GetCreationFlags(info->extension_id); |
549 if (!Manifest::IsUnpackedLocation(info->extension_location)) | 568 if (!Manifest::IsUnpackedLocation(info->extension_location)) |
550 flags |= Extension::REQUIRE_KEY; | 569 flags |= Extension::REQUIRE_KEY; |
551 if (extension_prefs_->AllowFileAccess(info->extension_id)) | 570 if (extension_prefs_->AllowFileAccess(info->extension_id)) |
552 flags |= Extension::ALLOW_FILE_ACCESS; | 571 flags |= Extension::ALLOW_FILE_ACCESS; |
553 return flags; | 572 return flags; |
554 } | 573 } |
555 | 574 |
556 } // namespace extensions | 575 } // namespace extensions |
OLD | NEW |