Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(224)

Side by Side Diff: chrome/browser/extensions/installed_loader.cc

Issue 240613004: Add UMA logging of extension creation flags. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | extensions/common/extension.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 } 107 }
108 108
109 BackgroundPageType GetBackgroundPageType(const Extension* extension) { 109 BackgroundPageType GetBackgroundPageType(const Extension* extension) {
110 if (!BackgroundInfo::HasBackgroundPage(extension)) 110 if (!BackgroundInfo::HasBackgroundPage(extension))
111 return NO_BACKGROUND_PAGE; 111 return NO_BACKGROUND_PAGE;
112 if (BackgroundInfo::HasPersistentBackgroundPage(extension)) 112 if (BackgroundInfo::HasPersistentBackgroundPage(extension))
113 return BACKGROUND_PAGE_PERSISTENT; 113 return BACKGROUND_PAGE_PERSISTENT;
114 return EVENT_PAGE; 114 return EVENT_PAGE;
115 } 115 }
116 116
117 // Records the creation flags of an extension grouped by
118 // Extension::InitFromValueFlags.
119 void RecordCreationFlags(const Extension* extension) {
120 int highest_flag_bit = 0;
121 for (int i = 1; i < Extension::LAST_INIT_FROM_VALUE_FLAGS; i <<= 1)
benwells 2014/04/22 06:41:44 Nit: add a comment explaining what you're doing he
calamity 2014/04/22 06:56:28 Done.
122 ++highest_flag_bit;
123
124 int flag = 1;
125 for (int i = 1; i <= highest_flag_bit; ++i) {
126 if (extension->creation_flags() & flag) {
127 UMA_HISTOGRAM_ENUMERATION(
128 "Extensions.LoadCreationFlags", i, highest_flag_bit + 1);
129 }
130 flag <<= 1;
131 }
132 }
133
117 } // namespace 134 } // namespace
118 135
119 InstalledLoader::InstalledLoader(ExtensionService* extension_service) 136 InstalledLoader::InstalledLoader(ExtensionService* extension_service)
120 : extension_service_(extension_service), 137 : extension_service_(extension_service),
121 extension_registry_(ExtensionRegistry::Get(extension_service->profile())), 138 extension_registry_(ExtensionRegistry::Get(extension_service->profile())),
122 extension_prefs_(ExtensionPrefs::Get(extension_service->profile())) {} 139 extension_prefs_(ExtensionPrefs::Get(extension_service->profile())) {}
123 140
124 InstalledLoader::~InstalledLoader() { 141 InstalledLoader::~InstalledLoader() {
125 } 142 }
126 143
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 ExtensionActionManager* extension_action_manager = 413 ExtensionActionManager* extension_action_manager =
397 ExtensionActionManager::Get(extension_service_->profile()); 414 ExtensionActionManager::Get(extension_service_->profile());
398 if (extension_action_manager->GetPageAction(*ex->get())) 415 if (extension_action_manager->GetPageAction(*ex->get()))
399 ++page_action_count; 416 ++page_action_count;
400 if (extension_action_manager->GetBrowserAction(*ex->get())) 417 if (extension_action_manager->GetBrowserAction(*ex->get()))
401 ++browser_action_count; 418 ++browser_action_count;
402 419
403 if (extensions::ManagedModeInfo::IsContentPack(ex->get())) 420 if (extensions::ManagedModeInfo::IsContentPack(ex->get()))
404 ++content_pack_count; 421 ++content_pack_count;
405 422
423 RecordCreationFlags(*ex);
424
406 extension_service_->RecordPermissionMessagesHistogram( 425 extension_service_->RecordPermissionMessagesHistogram(
407 ex->get(), "Extensions.Permissions_Load"); 426 ex->get(), "Extensions.Permissions_Load");
408 } 427 }
409 428
410 const ExtensionSet& disabled_extensions = 429 const ExtensionSet& disabled_extensions =
411 extension_registry_->disabled_extensions(); 430 extension_registry_->disabled_extensions();
412 for (ex = disabled_extensions.begin(); ex != disabled_extensions.end(); 431 for (ex = disabled_extensions.begin(); ex != disabled_extensions.end();
413 ++ex) { 432 ++ex) {
414 if (extension_prefs_->DidExtensionEscalatePermissions((*ex)->id())) { 433 if (extension_prefs_->DidExtensionEscalatePermissions((*ex)->id())) {
415 ++disabled_for_permissions_count; 434 ++disabled_for_permissions_count;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 int InstalledLoader::GetCreationFlags(const ExtensionInfo* info) { 496 int InstalledLoader::GetCreationFlags(const ExtensionInfo* info) {
478 int flags = extension_prefs_->GetCreationFlags(info->extension_id); 497 int flags = extension_prefs_->GetCreationFlags(info->extension_id);
479 if (!Manifest::IsUnpackedLocation(info->extension_location)) 498 if (!Manifest::IsUnpackedLocation(info->extension_location))
480 flags |= Extension::REQUIRE_KEY; 499 flags |= Extension::REQUIRE_KEY;
481 if (extension_prefs_->AllowFileAccess(info->extension_id)) 500 if (extension_prefs_->AllowFileAccess(info->extension_id))
482 flags |= Extension::ALLOW_FILE_ACCESS; 501 flags |= Extension::ALLOW_FILE_ACCESS;
483 return flags; 502 return flags;
484 } 503 }
485 504
486 } // namespace extensions 505 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | extensions/common/extension.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698