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

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: add comment 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 // Since each flag is a separate bit in an int, this loop is needed to find
121 // the number of flags.
122 int highest_flag_bit = 0;
123 for (int i = 1; i < Extension::LAST_INIT_FROM_VALUE_FLAGS; i <<= 1)
124 ++highest_flag_bit;
jar (doing other things) 2014/04/29 16:25:56 I didn't read this section of the code carefully..
calamity 2014/05/12 03:39:10 Done.
125
126 int flag = 1;
127 for (int i = 1; i <= highest_flag_bit; ++i) {
jar (doing other things) 2014/04/29 16:25:56 Since higest_flag_bit == 9, this loop will only re
128 if (extension->creation_flags() & flag) {
jar (doing other things) 2014/04/29 16:25:56 Since you're only looking at 9 choices for |flag|,
129 UMA_HISTOGRAM_ENUMERATION(
130 "Extensions.LoadCreationFlags", i, highest_flag_bit + 1);
jar (doing other things) 2014/04/29 01:32:25 Other than |i| (which is the sample), the other ar
131 }
132 flag <<= 1;
133 }
134 }
135
117 } // namespace 136 } // namespace
118 137
119 InstalledLoader::InstalledLoader(ExtensionService* extension_service) 138 InstalledLoader::InstalledLoader(ExtensionService* extension_service)
120 : extension_service_(extension_service), 139 : extension_service_(extension_service),
121 extension_registry_(ExtensionRegistry::Get(extension_service->profile())), 140 extension_registry_(ExtensionRegistry::Get(extension_service->profile())),
122 extension_prefs_(ExtensionPrefs::Get(extension_service->profile())) {} 141 extension_prefs_(ExtensionPrefs::Get(extension_service->profile())) {}
123 142
124 InstalledLoader::~InstalledLoader() { 143 InstalledLoader::~InstalledLoader() {
125 } 144 }
126 145
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 ExtensionActionManager* extension_action_manager = 415 ExtensionActionManager* extension_action_manager =
397 ExtensionActionManager::Get(extension_service_->profile()); 416 ExtensionActionManager::Get(extension_service_->profile());
398 if (extension_action_manager->GetPageAction(*ex->get())) 417 if (extension_action_manager->GetPageAction(*ex->get()))
399 ++page_action_count; 418 ++page_action_count;
400 if (extension_action_manager->GetBrowserAction(*ex->get())) 419 if (extension_action_manager->GetBrowserAction(*ex->get()))
401 ++browser_action_count; 420 ++browser_action_count;
402 421
403 if (extensions::ManagedModeInfo::IsContentPack(ex->get())) 422 if (extensions::ManagedModeInfo::IsContentPack(ex->get()))
404 ++content_pack_count; 423 ++content_pack_count;
405 424
425 RecordCreationFlags(*ex);
426
406 extension_service_->RecordPermissionMessagesHistogram( 427 extension_service_->RecordPermissionMessagesHistogram(
407 ex->get(), "Extensions.Permissions_Load"); 428 ex->get(), "Extensions.Permissions_Load");
408 } 429 }
409 430
410 const ExtensionSet& disabled_extensions = 431 const ExtensionSet& disabled_extensions =
411 extension_registry_->disabled_extensions(); 432 extension_registry_->disabled_extensions();
412 for (ex = disabled_extensions.begin(); ex != disabled_extensions.end(); 433 for (ex = disabled_extensions.begin(); ex != disabled_extensions.end();
413 ++ex) { 434 ++ex) {
414 if (extension_prefs_->DidExtensionEscalatePermissions((*ex)->id())) { 435 if (extension_prefs_->DidExtensionEscalatePermissions((*ex)->id())) {
415 ++disabled_for_permissions_count; 436 ++disabled_for_permissions_count;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 int InstalledLoader::GetCreationFlags(const ExtensionInfo* info) { 498 int InstalledLoader::GetCreationFlags(const ExtensionInfo* info) {
478 int flags = extension_prefs_->GetCreationFlags(info->extension_id); 499 int flags = extension_prefs_->GetCreationFlags(info->extension_id);
479 if (!Manifest::IsUnpackedLocation(info->extension_location)) 500 if (!Manifest::IsUnpackedLocation(info->extension_location))
480 flags |= Extension::REQUIRE_KEY; 501 flags |= Extension::REQUIRE_KEY;
481 if (extension_prefs_->AllowFileAccess(info->extension_id)) 502 if (extension_prefs_->AllowFileAccess(info->extension_id))
482 flags |= Extension::ALLOW_FILE_ACCESS; 503 flags |= Extension::ALLOW_FILE_ACCESS;
483 return flags; 504 return flags;
484 } 505 }
485 506
486 } // namespace extensions 507 } // 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