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/metrics/sparse_histogram.h" |
10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 extension_service_->profile())->management_policy(); | 195 extension_service_->profile())->management_policy(); |
196 if (extension.get()) { | 196 if (extension.get()) { |
197 Extension::DisableReason disable_reason = Extension::DISABLE_NONE; | 197 Extension::DisableReason disable_reason = Extension::DISABLE_NONE; |
198 bool force_disabled = false; | 198 bool force_disabled = false; |
199 if (!policy->UserMayLoad(extension.get(), NULL)) { | 199 if (!policy->UserMayLoad(extension.get(), NULL)) { |
200 // The error message from UserMayInstall() often contains the extension ID | 200 // The error message from UserMayInstall() often contains the extension ID |
201 // and is therefore not well suited to this UI. | 201 // and is therefore not well suited to this UI. |
202 error = errors::kDisabledByPolicy; | 202 error = errors::kDisabledByPolicy; |
203 extension = NULL; | 203 extension = NULL; |
204 } else if (!extension_prefs_->IsExtensionDisabled(extension->id()) && | 204 } else if (!extension_prefs_->IsExtensionDisabled(extension->id()) && |
205 policy->MustRemainDisabled(extension, &disable_reason, NULL)) { | 205 policy->MustRemainDisabled( |
| 206 extension.get(), &disable_reason, NULL)) { |
206 extension_prefs_->SetExtensionState(extension->id(), Extension::DISABLED); | 207 extension_prefs_->SetExtensionState(extension->id(), Extension::DISABLED); |
207 extension_prefs_->AddDisableReason(extension->id(), disable_reason); | 208 extension_prefs_->AddDisableReason(extension->id(), disable_reason); |
208 force_disabled = true; | 209 force_disabled = true; |
209 } | 210 } |
210 UMA_HISTOGRAM_BOOLEAN("ExtensionInstalledLoader.ForceDisabled", | 211 UMA_HISTOGRAM_BOOLEAN("ExtensionInstalledLoader.ForceDisabled", |
211 force_disabled); | 212 force_disabled); |
212 } | 213 } |
213 | 214 |
214 if (!extension.get()) { | 215 if (!extension.get()) { |
215 ExtensionErrorReporter::GetInstance()->ReportLoadError( | 216 ExtensionErrorReporter::GetInstance()->ReportLoadError( |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 int incognito_not_allowed_count = 0; | 324 int incognito_not_allowed_count = 0; |
324 int file_access_allowed_count = 0; | 325 int file_access_allowed_count = 0; |
325 int file_access_not_allowed_count = 0; | 326 int file_access_not_allowed_count = 0; |
326 | 327 |
327 const ExtensionSet& extensions = extension_registry_->enabled_extensions(); | 328 const ExtensionSet& extensions = extension_registry_->enabled_extensions(); |
328 ExtensionActionManager* extension_action_manager = | 329 ExtensionActionManager* extension_action_manager = |
329 ExtensionActionManager::Get(profile); | 330 ExtensionActionManager::Get(profile); |
330 for (ExtensionSet::const_iterator iter = extensions.begin(); | 331 for (ExtensionSet::const_iterator iter = extensions.begin(); |
331 iter != extensions.end(); | 332 iter != extensions.end(); |
332 ++iter) { | 333 ++iter) { |
333 const Extension* extension = *iter; | 334 const Extension* extension = iter->get(); |
334 Manifest::Location location = extension->location(); | 335 Manifest::Location location = extension->location(); |
335 Manifest::Type type = extension->GetType(); | 336 Manifest::Type type = extension->GetType(); |
336 | 337 |
337 // For the first few metrics, include all extensions and apps (component, | 338 // For the first few metrics, include all extensions and apps (component, |
338 // unpacked, etc). It's good to know these locations, and it doesn't | 339 // unpacked, etc). It's good to know these locations, and it doesn't |
339 // muck up any of the stats. Later, though, we want to omit component and | 340 // muck up any of the stats. Later, though, we want to omit component and |
340 // unpacked, as they are less interesting. | 341 // unpacked, as they are less interesting. |
341 if (extension->is_app()) | 342 if (extension->is_app()) |
342 UMA_HISTOGRAM_ENUMERATION( | 343 UMA_HISTOGRAM_ENUMERATION( |
343 "Extensions.AppLocation", location, Manifest::NUM_LOCATIONS); | 344 "Extensions.AppLocation", location, Manifest::NUM_LOCATIONS); |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
491 | 492 |
492 for (ExtensionSet::const_iterator ex = disabled_extensions.begin(); | 493 for (ExtensionSet::const_iterator ex = disabled_extensions.begin(); |
493 ex != disabled_extensions.end(); | 494 ex != disabled_extensions.end(); |
494 ++ex) { | 495 ++ex) { |
495 if (extension_prefs_->DidExtensionEscalatePermissions((*ex)->id())) { | 496 if (extension_prefs_->DidExtensionEscalatePermissions((*ex)->id())) { |
496 ++disabled_for_permissions_count; | 497 ++disabled_for_permissions_count; |
497 } | 498 } |
498 RecordDisableReasons(extension_prefs_->GetDisableReasons((*ex)->id())); | 499 RecordDisableReasons(extension_prefs_->GetDisableReasons((*ex)->id())); |
499 if (Manifest::IsExternalLocation((*ex)->location())) { | 500 if (Manifest::IsExternalLocation((*ex)->location())) { |
500 // See loop above for ENABLED. | 501 // See loop above for ENABLED. |
501 if (ManifestURL::UpdatesFromGallery(*ex)) { | 502 if (ManifestURL::UpdatesFromGallery(ex->get())) { |
502 UMA_HISTOGRAM_ENUMERATION("Extensions.ExternalItemState", | 503 UMA_HISTOGRAM_ENUMERATION("Extensions.ExternalItemState", |
503 EXTERNAL_ITEM_WEBSTORE_DISABLED, | 504 EXTERNAL_ITEM_WEBSTORE_DISABLED, |
504 EXTERNAL_ITEM_MAX_ITEMS); | 505 EXTERNAL_ITEM_MAX_ITEMS); |
505 } else { | 506 } else { |
506 UMA_HISTOGRAM_ENUMERATION("Extensions.ExternalItemState", | 507 UMA_HISTOGRAM_ENUMERATION("Extensions.ExternalItemState", |
507 EXTERNAL_ITEM_NONWEBSTORE_DISABLED, | 508 EXTERNAL_ITEM_NONWEBSTORE_DISABLED, |
508 EXTERNAL_ITEM_MAX_ITEMS); | 509 EXTERNAL_ITEM_MAX_ITEMS); |
509 } | 510 } |
510 } | 511 } |
511 } | 512 } |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
574 int InstalledLoader::GetCreationFlags(const ExtensionInfo* info) { | 575 int InstalledLoader::GetCreationFlags(const ExtensionInfo* info) { |
575 int flags = extension_prefs_->GetCreationFlags(info->extension_id); | 576 int flags = extension_prefs_->GetCreationFlags(info->extension_id); |
576 if (!Manifest::IsUnpackedLocation(info->extension_location)) | 577 if (!Manifest::IsUnpackedLocation(info->extension_location)) |
577 flags |= Extension::REQUIRE_KEY; | 578 flags |= Extension::REQUIRE_KEY; |
578 if (extension_prefs_->AllowFileAccess(info->extension_id)) | 579 if (extension_prefs_->AllowFileAccess(info->extension_id)) |
579 flags |= Extension::ALLOW_FILE_ACCESS; | 580 flags |= Extension::ALLOW_FILE_ACCESS; |
580 return flags; | 581 return flags; |
581 } | 582 } |
582 | 583 |
583 } // namespace extensions | 584 } // namespace extensions |
OLD | NEW |