ExtensionSyncService: listen for relevant changes instead of being explicitly called...
[chromium-blink-merge.git] / chrome / browser / extensions / installed_loader.cc
blob9d562c44f0559078e12a74cd3c9683864bd62ed5
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
3 // found in the LICENSE file.
5 #include "chrome/browser/extensions/installed_loader.h"
7 #include "base/files/file_path.h"
8 #include "base/metrics/histogram_macros.h"
9 #include "base/metrics/sparse_histogram.h"
10 #include "base/strings/stringprintf.h"
11 #include "base/strings/utf_string_conversions.h"
12 #include "base/threading/thread_restrictions.h"
13 #include "base/trace_event/trace_event.h"
14 #include "base/values.h"
15 #include "chrome/browser/browser_process.h"
16 #include "chrome/browser/extensions/extension_action_manager.h"
17 #include "chrome/browser/extensions/extension_error_reporter.h"
18 #include "chrome/browser/extensions/extension_service.h"
19 #include "chrome/browser/extensions/extension_util.h"
20 #include "chrome/browser/profiles/profile_manager.h"
21 #include "chrome/common/chrome_switches.h"
22 #include "chrome/common/extensions/chrome_manifest_url_handlers.h"
23 #include "components/crx_file/id_util.h"
24 #include "content/public/browser/browser_thread.h"
25 #include "content/public/browser/notification_service.h"
26 #include "content/public/browser/user_metrics.h"
27 #include "extensions/browser/event_router.h"
28 #include "extensions/browser/extension_prefs.h"
29 #include "extensions/browser/extension_registry.h"
30 #include "extensions/browser/extension_system.h"
31 #include "extensions/browser/management_policy.h"
32 #include "extensions/common/extension.h"
33 #include "extensions/common/extension_l10n_util.h"
34 #include "extensions/common/extension_set.h"
35 #include "extensions/common/extension_urls.h"
36 #include "extensions/common/file_util.h"
37 #include "extensions/common/manifest.h"
38 #include "extensions/common/manifest_constants.h"
39 #include "extensions/common/manifest_handlers/background_info.h"
40 #include "extensions/common/manifest_url_handlers.h"
42 using base::UserMetricsAction;
43 using content::BrowserThread;
45 namespace extensions {
47 namespace errors = manifest_errors;
49 namespace {
51 // The following enumeration is used in histograms matching
52 // Extensions.ManifestReload*.
53 enum ManifestReloadReason {
54 NOT_NEEDED = 0, // Reload not needed.
55 UNPACKED_DIR, // Unpacked directory.
56 NEEDS_RELOCALIZATION, // The locale has changed since we read this extension.
57 CORRUPT_PREFERENCES, // The manifest in the preferences is corrupt.
59 // New enum values must go above here.
60 NUM_MANIFEST_RELOAD_REASONS
63 // Used in histogram Extension.BackgroundPageType.
64 enum BackgroundPageType {
65 NO_BACKGROUND_PAGE = 0,
66 BACKGROUND_PAGE_PERSISTENT,
67 EVENT_PAGE,
69 // New enum values must go above here.
70 NUM_BACKGROUND_PAGE_TYPES
73 // Used in histogram Extensions.ExternalItemState.
74 enum ExternalItemState {
75 DEPRECATED_EXTERNAL_ITEM_DISABLED = 0,
76 DEPRECATED_EXTERNAL_ITEM_ENABLED,
77 EXTERNAL_ITEM_WEBSTORE_DISABLED,
78 EXTERNAL_ITEM_WEBSTORE_ENABLED,
79 EXTERNAL_ITEM_NONWEBSTORE_DISABLED,
80 EXTERNAL_ITEM_NONWEBSTORE_ENABLED,
81 EXTERNAL_ITEM_WEBSTORE_UNINSTALLED,
82 EXTERNAL_ITEM_NONWEBSTORE_UNINSTALLED,
84 // New enum values must go above here.
85 EXTERNAL_ITEM_MAX_ITEMS
88 bool IsManifestCorrupt(const base::DictionaryValue* manifest) {
89 if (!manifest)
90 return false;
92 // Because of bug #272524 sometimes manifests got mangled in the preferences
93 // file, one particularly bad case resulting in having both a background page
94 // and background scripts values. In those situations we want to reload the
95 // manifest from the extension to fix this.
96 const base::Value* background_page;
97 const base::Value* background_scripts;
98 return manifest->Get(manifest_keys::kBackgroundPage, &background_page) &&
99 manifest->Get(manifest_keys::kBackgroundScripts, &background_scripts);
102 ManifestReloadReason ShouldReloadExtensionManifest(const ExtensionInfo& info) {
103 // Always reload manifests of unpacked extensions, because they can change
104 // on disk independent of the manifest in our prefs.
105 if (Manifest::IsUnpackedLocation(info.extension_location))
106 return UNPACKED_DIR;
108 // Reload the manifest if it needs to be relocalized.
109 if (extension_l10n_util::ShouldRelocalizeManifest(
110 info.extension_manifest.get()))
111 return NEEDS_RELOCALIZATION;
113 // Reload if the copy of the manifest in the preferences is corrupt.
114 if (IsManifestCorrupt(info.extension_manifest.get()))
115 return CORRUPT_PREFERENCES;
117 return NOT_NEEDED;
120 BackgroundPageType GetBackgroundPageType(const Extension* extension) {
121 if (!BackgroundInfo::HasBackgroundPage(extension))
122 return NO_BACKGROUND_PAGE;
123 if (BackgroundInfo::HasPersistentBackgroundPage(extension))
124 return BACKGROUND_PAGE_PERSISTENT;
125 return EVENT_PAGE;
128 // Records the creation flags of an extension grouped by
129 // Extension::InitFromValueFlags.
130 void RecordCreationFlags(const Extension* extension) {
131 for (int i = 0; i < Extension::kInitFromValueFlagBits; ++i) {
132 int flag = 1 << i;
133 if (extension->creation_flags() & flag) {
134 UMA_HISTOGRAM_ENUMERATION(
135 "Extensions.LoadCreationFlags", i, Extension::kInitFromValueFlagBits);
140 // Helper to record a single disable reason histogram value (see
141 // RecordDisableReasons below).
142 void RecordDisbleReasonHistogram(int reason) {
143 UMA_HISTOGRAM_SPARSE_SLOWLY("Extensions.DisableReason", reason);
146 // Records the disable reasons for a single extension grouped by
147 // Extension::DisableReason.
148 void RecordDisableReasons(int reasons) {
149 // |reasons| is a bitmask with values from Extension::DisabledReason
150 // which are increasing powers of 2.
151 if (reasons == Extension::DISABLE_NONE) {
152 RecordDisbleReasonHistogram(Extension::DISABLE_NONE);
153 return;
155 for (int reason = 1; reason < Extension::DISABLE_REASON_LAST; reason <<= 1) {
156 if (reasons & reason)
157 RecordDisbleReasonHistogram(reason);
161 } // namespace
163 InstalledLoader::InstalledLoader(ExtensionService* extension_service)
164 : extension_service_(extension_service),
165 extension_registry_(ExtensionRegistry::Get(extension_service->profile())),
166 extension_prefs_(ExtensionPrefs::Get(extension_service->profile())) {}
168 InstalledLoader::~InstalledLoader() {
171 void InstalledLoader::Load(const ExtensionInfo& info, bool write_to_prefs) {
172 // TODO(asargent): add a test to confirm that we can't load extensions if
173 // their ID in preferences does not match the extension's actual ID.
174 if (invalid_extensions_.find(info.extension_path) !=
175 invalid_extensions_.end())
176 return;
178 std::string error;
179 scoped_refptr<const Extension> extension(NULL);
180 if (info.extension_manifest) {
181 extension = Extension::Create(
182 info.extension_path,
183 info.extension_location,
184 *info.extension_manifest,
185 GetCreationFlags(&info),
186 &error);
187 } else {
188 error = errors::kManifestUnreadable;
191 // Once installed, non-unpacked extensions cannot change their IDs (e.g., by
192 // updating the 'key' field in their manifest).
193 // TODO(jstritar): migrate preferences when unpacked extensions change IDs.
194 if (extension.get() && !Manifest::IsUnpackedLocation(extension->location()) &&
195 info.extension_id != extension->id()) {
196 error = errors::kCannotChangeExtensionID;
197 extension = NULL;
200 // Check policy on every load in case an extension was blacklisted while
201 // Chrome was not running.
202 const ManagementPolicy* policy = extensions::ExtensionSystem::Get(
203 extension_service_->profile())->management_policy();
204 if (extension.get()) {
205 Extension::DisableReason disable_reason = Extension::DISABLE_NONE;
206 bool force_disabled = false;
207 if (!policy->UserMayLoad(extension.get(), NULL)) {
208 // The error message from UserMayInstall() often contains the extension ID
209 // and is therefore not well suited to this UI.
210 error = errors::kDisabledByPolicy;
211 extension = NULL;
212 } else if (!extension_prefs_->IsExtensionDisabled(extension->id()) &&
213 policy->MustRemainDisabled(
214 extension.get(), &disable_reason, NULL)) {
215 extension_prefs_->SetExtensionDisabled(extension->id(), disable_reason);
216 force_disabled = true;
218 UMA_HISTOGRAM_BOOLEAN("ExtensionInstalledLoader.ForceDisabled",
219 force_disabled);
222 if (!extension.get()) {
223 ExtensionErrorReporter::GetInstance()->ReportLoadError(
224 info.extension_path,
225 error,
226 extension_service_->profile(),
227 false); // Be quiet.
228 return;
231 if (write_to_prefs)
232 extension_prefs_->UpdateManifest(extension.get());
234 extension_service_->AddExtension(extension.get());
237 void InstalledLoader::LoadAllExtensions() {
238 DCHECK_CURRENTLY_ON(BrowserThread::UI);
239 TRACE_EVENT0("browser,startup", "InstalledLoader::LoadAllExtensions");
240 SCOPED_UMA_HISTOGRAM_TIMER("Extensions.LoadAllTime2");
241 base::TimeTicks start_time = base::TimeTicks::Now();
243 Profile* profile = extension_service_->profile();
244 scoped_ptr<ExtensionPrefs::ExtensionsInfo> extensions_info(
245 extension_prefs_->GetInstalledExtensionsInfo());
247 std::vector<int> reload_reason_counts(NUM_MANIFEST_RELOAD_REASONS, 0);
248 bool should_write_prefs = false;
250 for (size_t i = 0; i < extensions_info->size(); ++i) {
251 ExtensionInfo* info = extensions_info->at(i).get();
253 // Skip extensions that were loaded from the command-line because we don't
254 // want those to persist across browser restart.
255 if (info->extension_location == Manifest::COMMAND_LINE)
256 continue;
258 ManifestReloadReason reload_reason = ShouldReloadExtensionManifest(*info);
259 ++reload_reason_counts[reload_reason];
261 if (reload_reason != NOT_NEEDED) {
262 // Reloading an extension reads files from disk. We do this on the
263 // UI thread because reloads should be very rare, and the complexity
264 // added by delaying the time when the extensions service knows about
265 // all extensions is significant. See crbug.com/37548 for details.
266 // |allow_io| disables tests that file operations run on the file
267 // thread.
268 base::ThreadRestrictions::ScopedAllowIO allow_io;
270 std::string error;
271 scoped_refptr<const Extension> extension(
272 file_util::LoadExtension(info->extension_path,
273 info->extension_location,
274 GetCreationFlags(info),
275 &error));
277 if (!extension.get() || extension->id() != info->extension_id) {
278 invalid_extensions_.insert(info->extension_path);
279 ExtensionErrorReporter::GetInstance()->ReportLoadError(
280 info->extension_path,
281 error,
282 profile,
283 false); // Be quiet.
284 continue;
287 extensions_info->at(i)->extension_manifest.reset(
288 static_cast<base::DictionaryValue*>(
289 extension->manifest()->value()->DeepCopy()));
290 should_write_prefs = true;
294 for (size_t i = 0; i < extensions_info->size(); ++i) {
295 if (extensions_info->at(i)->extension_location != Manifest::COMMAND_LINE)
296 Load(*extensions_info->at(i), should_write_prefs);
299 extension_service_->OnLoadedInstalledExtensions();
301 // The histograms Extensions.ManifestReload* allow us to validate
302 // the assumption that reloading manifest is a rare event.
303 UMA_HISTOGRAM_COUNTS_100("Extensions.ManifestReloadNotNeeded",
304 reload_reason_counts[NOT_NEEDED]);
305 UMA_HISTOGRAM_COUNTS_100("Extensions.ManifestReloadUnpackedDir",
306 reload_reason_counts[UNPACKED_DIR]);
307 UMA_HISTOGRAM_COUNTS_100("Extensions.ManifestReloadNeedsRelocalization",
308 reload_reason_counts[NEEDS_RELOCALIZATION]);
310 UMA_HISTOGRAM_COUNTS_100("Extensions.LoadAll",
311 extension_registry_->enabled_extensions().size());
312 UMA_HISTOGRAM_COUNTS_100("Extensions.Disabled",
313 extension_registry_->disabled_extensions().size());
315 // TODO(rkaplow): Obsolete this when verified similar to LoadAllTime2.
316 UMA_HISTOGRAM_TIMES("Extensions.LoadAllTime",
317 base::TimeTicks::Now() - start_time);
318 RecordExtensionsMetrics();
321 void InstalledLoader::RecordExtensionsMetrics() {
322 Profile* profile = extension_service_->profile();
324 int app_user_count = 0;
325 int app_external_count = 0;
326 int hosted_app_count = 0;
327 int legacy_packaged_app_count = 0;
328 int platform_app_count = 0;
329 int user_script_count = 0;
330 int extension_user_count = 0;
331 int extension_external_count = 0;
332 int theme_count = 0;
333 int page_action_count = 0;
334 int browser_action_count = 0;
335 int disabled_for_permissions_count = 0;
336 int non_webstore_ntp_override_count = 0;
337 int incognito_allowed_count = 0;
338 int incognito_not_allowed_count = 0;
339 int file_access_allowed_count = 0;
340 int file_access_not_allowed_count = 0;
341 int eventless_event_pages_count = 0;
343 const ExtensionSet& extensions = extension_registry_->enabled_extensions();
344 ExtensionActionManager* extension_action_manager =
345 ExtensionActionManager::Get(profile);
346 for (ExtensionSet::const_iterator iter = extensions.begin();
347 iter != extensions.end();
348 ++iter) {
349 const Extension* extension = iter->get();
350 Manifest::Location location = extension->location();
351 Manifest::Type type = extension->GetType();
353 // For the first few metrics, include all extensions and apps (component,
354 // unpacked, etc). It's good to know these locations, and it doesn't
355 // muck up any of the stats. Later, though, we want to omit component and
356 // unpacked, as they are less interesting.
357 if (extension->is_app())
358 UMA_HISTOGRAM_ENUMERATION(
359 "Extensions.AppLocation", location, Manifest::NUM_LOCATIONS);
360 else if (extension->is_extension())
361 UMA_HISTOGRAM_ENUMERATION(
362 "Extensions.ExtensionLocation", location, Manifest::NUM_LOCATIONS);
364 if (!ManifestURL::UpdatesFromGallery(extension)) {
365 UMA_HISTOGRAM_ENUMERATION(
366 "Extensions.NonWebstoreLocation", location, Manifest::NUM_LOCATIONS);
368 // Check for inconsistencies if the extension was supposedly installed
369 // from the webstore.
370 enum {
371 BAD_UPDATE_URL = 0,
372 // This value was a mistake. Turns out sideloaded extensions can
373 // have the from_webstore bit if they update from the webstore.
374 DEPRECATED_IS_EXTERNAL = 1,
376 if (extension->from_webstore()) {
377 UMA_HISTOGRAM_ENUMERATION(
378 "Extensions.FromWebstoreInconsistency", BAD_UPDATE_URL, 2);
382 if (Manifest::IsExternalLocation(location)) {
383 // See loop below for DISABLED.
384 if (ManifestURL::UpdatesFromGallery(extension)) {
385 UMA_HISTOGRAM_ENUMERATION("Extensions.ExternalItemState",
386 EXTERNAL_ITEM_WEBSTORE_ENABLED,
387 EXTERNAL_ITEM_MAX_ITEMS);
388 } else {
389 UMA_HISTOGRAM_ENUMERATION("Extensions.ExternalItemState",
390 EXTERNAL_ITEM_NONWEBSTORE_ENABLED,
391 EXTERNAL_ITEM_MAX_ITEMS);
395 // From now on, don't count component extensions, since they are only
396 // extensions as an implementation detail. Continue to count unpacked
397 // extensions for a few metrics.
398 if (Manifest::IsComponentLocation(location))
399 continue;
401 // Histogram for non-webstore extensions overriding new tab page should
402 // include unpacked extensions.
403 if (!extension->from_webstore() &&
404 URLOverrides::GetChromeURLOverrides(extension).count("newtab")) {
405 ++non_webstore_ntp_override_count;
408 // Don't count unpacked extensions anymore, either.
409 if (Manifest::IsUnpackedLocation(location))
410 continue;
412 UMA_HISTOGRAM_ENUMERATION("Extensions.ManifestVersion",
413 extension->manifest_version(),
414 10); // TODO(kalman): Why 10 manifest versions?
416 // We might have wanted to count legacy packaged apps here, too, since they
417 // are effectively extensions. Unfortunately, it's too late, as we don't
418 // want to mess up the existing stats.
419 if (type == Manifest::TYPE_EXTENSION) {
420 UMA_HISTOGRAM_ENUMERATION("Extensions.BackgroundPageType",
421 GetBackgroundPageType(extension),
422 NUM_BACKGROUND_PAGE_TYPES);
424 if (GetBackgroundPageType(extension) == EVENT_PAGE) {
425 size_t num_registered_events =
426 EventRouter::Get(extension_service_->profile())
427 ->GetRegisteredEvents(extension->id())
428 .size();
429 // Count extension event pages with no registered events. Either the
430 // event page is badly designed, or there may be a bug where the event
431 // page failed to start after an update (crbug.com/469361).
432 if (num_registered_events == 0u) {
433 ++eventless_event_pages_count;
434 VLOG(1) << "Event page without registered event listeners: "
435 << extension->id() << " " << extension->name();
437 // Count the number of event listeners the Enhanced Bookmarks Manager
438 // has for crbug.com/469361, but only if it's using an event page (not
439 // necessarily the case). This should always be > 0, because that's how
440 // the bookmarks extension works, but Chrome may have a bug - it has in
441 // the past. In fact, this metric may generally be useful for tracking
442 // the frequency of event page bugs.
443 std::string hashed_id =
444 crx_file::id_util::HashedIdInHex(extension->id());
445 if (hashed_id == "D5736E4B5CF695CB93A2FB57E4FDC6E5AFAB6FE2") {
446 UMA_HISTOGRAM_CUSTOM_COUNTS(
447 "Extensions.EnhancedBookmarksManagerNumEventListeners",
448 num_registered_events, 1, 10, 10);
453 // Using an enumeration shows us the total installed ratio across all users.
454 // Using the totals per user at each startup tells us the distribution of
455 // usage for each user (e.g. 40% of users have at least one app installed).
456 UMA_HISTOGRAM_ENUMERATION(
457 "Extensions.LoadType", type, Manifest::NUM_LOAD_TYPES);
458 switch (type) {
459 case Manifest::TYPE_THEME:
460 ++theme_count;
461 break;
462 case Manifest::TYPE_USER_SCRIPT:
463 ++user_script_count;
464 break;
465 case Manifest::TYPE_HOSTED_APP:
466 ++hosted_app_count;
467 if (Manifest::IsExternalLocation(location)) {
468 ++app_external_count;
469 } else {
470 ++app_user_count;
472 break;
473 case Manifest::TYPE_LEGACY_PACKAGED_APP:
474 ++legacy_packaged_app_count;
475 if (Manifest::IsExternalLocation(location)) {
476 ++app_external_count;
477 } else {
478 ++app_user_count;
480 break;
481 case Manifest::TYPE_PLATFORM_APP:
482 ++platform_app_count;
483 if (Manifest::IsExternalLocation(location)) {
484 ++app_external_count;
485 } else {
486 ++app_user_count;
488 break;
489 case Manifest::TYPE_EXTENSION:
490 default:
491 if (Manifest::IsExternalLocation(location)) {
492 ++extension_external_count;
493 } else {
494 ++extension_user_count;
496 break;
499 if (extension_action_manager->GetPageAction(*extension))
500 ++page_action_count;
502 if (extension_action_manager->GetBrowserAction(*extension))
503 ++browser_action_count;
505 RecordCreationFlags(extension);
507 ExtensionService::RecordPermissionMessagesHistogram(extension, "Load");
509 // For incognito and file access, skip anything that doesn't appear in
510 // settings. Also, policy-installed (and unpacked of course, checked above)
511 // extensions are boring.
512 if (extension->ShouldDisplayInExtensionSettings() &&
513 !Manifest::IsPolicyLocation(extension->location())) {
514 if (extension->can_be_incognito_enabled()) {
515 if (util::IsIncognitoEnabled(extension->id(), profile))
516 ++incognito_allowed_count;
517 else
518 ++incognito_not_allowed_count;
520 if (extension->wants_file_access()) {
521 if (util::AllowFileAccess(extension->id(), profile))
522 ++file_access_allowed_count;
523 else
524 ++file_access_not_allowed_count;
529 const ExtensionSet& disabled_extensions =
530 extension_registry_->disabled_extensions();
532 for (ExtensionSet::const_iterator ex = disabled_extensions.begin();
533 ex != disabled_extensions.end();
534 ++ex) {
535 if (extension_prefs_->DidExtensionEscalatePermissions((*ex)->id())) {
536 ++disabled_for_permissions_count;
538 RecordDisableReasons(extension_prefs_->GetDisableReasons((*ex)->id()));
539 if (Manifest::IsExternalLocation((*ex)->location())) {
540 // See loop above for ENABLED.
541 if (ManifestURL::UpdatesFromGallery(ex->get())) {
542 UMA_HISTOGRAM_ENUMERATION("Extensions.ExternalItemState",
543 EXTERNAL_ITEM_WEBSTORE_DISABLED,
544 EXTERNAL_ITEM_MAX_ITEMS);
545 } else {
546 UMA_HISTOGRAM_ENUMERATION("Extensions.ExternalItemState",
547 EXTERNAL_ITEM_NONWEBSTORE_DISABLED,
548 EXTERNAL_ITEM_MAX_ITEMS);
553 scoped_ptr<ExtensionPrefs::ExtensionsInfo> uninstalled_extensions_info(
554 extension_prefs_->GetUninstalledExtensionsInfo());
555 for (size_t i = 0; i < uninstalled_extensions_info->size(); ++i) {
556 ExtensionInfo* info = uninstalled_extensions_info->at(i).get();
557 if (Manifest::IsExternalLocation(info->extension_location)) {
558 std::string update_url;
559 if (info->extension_manifest->GetString("update_url", &update_url) &&
560 extension_urls::IsWebstoreUpdateUrl(GURL(update_url))) {
561 UMA_HISTOGRAM_ENUMERATION("Extensions.ExternalItemState",
562 EXTERNAL_ITEM_WEBSTORE_UNINSTALLED,
563 EXTERNAL_ITEM_MAX_ITEMS);
564 } else {
565 UMA_HISTOGRAM_ENUMERATION("Extensions.ExternalItemState",
566 EXTERNAL_ITEM_NONWEBSTORE_UNINSTALLED,
567 EXTERNAL_ITEM_MAX_ITEMS);
572 UMA_HISTOGRAM_COUNTS_100("Extensions.LoadApp",
573 app_user_count + app_external_count);
574 UMA_HISTOGRAM_COUNTS_100("Extensions.LoadAppUser", app_user_count);
575 UMA_HISTOGRAM_COUNTS_100("Extensions.LoadAppExternal", app_external_count);
576 UMA_HISTOGRAM_COUNTS_100("Extensions.LoadHostedApp", hosted_app_count);
577 UMA_HISTOGRAM_COUNTS_100("Extensions.LoadPackagedApp",
578 legacy_packaged_app_count);
579 UMA_HISTOGRAM_COUNTS_100("Extensions.LoadPlatformApp", platform_app_count);
580 UMA_HISTOGRAM_COUNTS_100("Extensions.LoadExtension",
581 extension_user_count + extension_external_count);
582 UMA_HISTOGRAM_COUNTS_100("Extensions.LoadExtensionUser",
583 extension_user_count);
584 UMA_HISTOGRAM_COUNTS_100("Extensions.LoadExtensionExternal",
585 extension_external_count);
586 UMA_HISTOGRAM_COUNTS_100("Extensions.LoadUserScript", user_script_count);
587 UMA_HISTOGRAM_COUNTS_100("Extensions.LoadTheme", theme_count);
588 // Histogram name different for legacy reasons.
589 UMA_HISTOGRAM_COUNTS_100("PageActionController.ExtensionsWithPageActions",
590 page_action_count);
591 UMA_HISTOGRAM_COUNTS_100("Extensions.LoadBrowserAction",
592 browser_action_count);
593 UMA_HISTOGRAM_COUNTS_100("Extensions.DisabledForPermissions",
594 disabled_for_permissions_count);
595 UMA_HISTOGRAM_COUNTS_100("Extensions.NonWebStoreNewTabPageOverrides",
596 non_webstore_ntp_override_count);
597 if (incognito_allowed_count + incognito_not_allowed_count > 0) {
598 UMA_HISTOGRAM_COUNTS_100("Extensions.IncognitoAllowed",
599 incognito_allowed_count);
600 UMA_HISTOGRAM_COUNTS_100("Extensions.IncognitoNotAllowed",
601 incognito_not_allowed_count);
603 if (file_access_allowed_count + file_access_not_allowed_count > 0) {
604 UMA_HISTOGRAM_COUNTS_100("Extensions.FileAccessAllowed",
605 file_access_allowed_count);
606 UMA_HISTOGRAM_COUNTS_100("Extensions.FileAccessNotAllowed",
607 file_access_not_allowed_count);
609 UMA_HISTOGRAM_COUNTS_100("Extensions.CorruptExtensionTotalDisables",
610 extension_prefs_->GetCorruptedDisableCount());
611 UMA_HISTOGRAM_COUNTS_100("Extensions.EventlessEventPages",
612 eventless_event_pages_count);
615 int InstalledLoader::GetCreationFlags(const ExtensionInfo* info) {
616 int flags = extension_prefs_->GetCreationFlags(info->extension_id);
617 if (!Manifest::IsUnpackedLocation(info->extension_location))
618 flags |= Extension::REQUIRE_KEY;
619 if (extension_prefs_->AllowFileAccess(info->extension_id))
620 flags |= Extension::ALLOW_FILE_ACCESS;
621 return flags;
624 } // namespace extensions