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

Side by Side Diff: chrome/browser/permissions/permission_uma_util.cc

Issue 2887613003: Only collect Permission Action Reporting data in official builds (Closed)
Patch Set: Make it fail even without DCHECKS Created 3 years, 7 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/permissions/permission_uma_util.h" 5 #include "chrome/browser/permissions/permission_uma_util.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/metrics/histogram_macros.h" 10 #include "base/metrics/histogram_macros.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 PERMISSION_BUBBLE_TYPE_UMA(gesture_metric_name, permission_bubble_type); \ 53 PERMISSION_BUBBLE_TYPE_UMA(gesture_metric_name, permission_bubble_type); \
54 } else if (gesture_type == PermissionRequestGestureType::NO_GESTURE) { \ 54 } else if (gesture_type == PermissionRequestGestureType::NO_GESTURE) { \
55 PERMISSION_BUBBLE_TYPE_UMA(no_gesture_metric_name, \ 55 PERMISSION_BUBBLE_TYPE_UMA(no_gesture_metric_name, \
56 permission_bubble_type); \ 56 permission_bubble_type); \
57 } 57 }
58 58
59 using content::PermissionType; 59 using content::PermissionType;
60 60
61 namespace { 61 namespace {
62 62
63 static bool gIsFakeOfficialBuildForTest = false;
64
63 const std::string GetRapporMetric(ContentSettingsType permission, 65 const std::string GetRapporMetric(ContentSettingsType permission,
64 PermissionAction action) { 66 PermissionAction action) {
65 std::string action_str; 67 std::string action_str;
66 switch (action) { 68 switch (action) {
67 case PermissionAction::GRANTED: 69 case PermissionAction::GRANTED:
68 action_str = "Granted"; 70 action_str = "Granted";
69 break; 71 break;
70 case PermissionAction::DENIED: 72 case PermissionAction::DENIED:
71 action_str = "Denied"; 73 action_str = "Denied";
72 break; 74 break;
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 break; 572 break;
571 // The user is not prompted for these permissions, thus there is no deny 573 // The user is not prompted for these permissions, thus there is no deny
572 // recorded for them. 574 // recorded for them.
573 default: 575 default:
574 NOTREACHED() << "PERMISSION " 576 NOTREACHED() << "PERMISSION "
575 << PermissionUtil::GetPermissionString(permission) 577 << PermissionUtil::GetPermissionString(permission)
576 << " not accounted for"; 578 << " not accounted for";
577 } 579 }
578 } 580 }
579 581
582 void PermissionUmaUtil::FakeOfficialBuildForTest() {
583 gIsFakeOfficialBuildForTest = true;
vakh (use Gerrit instead) 2017/05/25 01:59:17 Perhaps add a CHECK(false) here for official build
benwells 2017/05/25 02:03:37 The CHECK below is just for an experiment, not to
584 }
585
580 bool PermissionUmaUtil::IsOptedIntoPermissionActionReporting(Profile* profile) { 586 bool PermissionUmaUtil::IsOptedIntoPermissionActionReporting(Profile* profile) {
581 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 587 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
582 switches::kDisablePermissionActionReporting)) { 588 switches::kDisablePermissionActionReporting)) {
583 return false; 589 return false;
584 } 590 }
585 591
592 bool official_build = gIsFakeOfficialBuildForTest;
593 #if defined(OFFICIAL_BUILD) && defined(GOOGLE_CHROME_BUILD)
594 official_build = true;
595 CHECK(false);
vakh (use Gerrit instead) 2017/05/25 01:59:17 I must be reading this incorrectly but it looks li
benwells 2017/05/25 02:03:37 Sorry, this is just an experiment I'm doing to see
596 #endif
597
598 if (!official_build)
599 return false;
600
586 DCHECK(profile); 601 DCHECK(profile);
587 if (profile->GetProfileType() == Profile::INCOGNITO_PROFILE) 602 if (profile->GetProfileType() == Profile::INCOGNITO_PROFILE)
588 return false; 603 return false;
589 if (!profile->GetPrefs()->GetBoolean(prefs::kSafeBrowsingEnabled)) 604 if (!profile->GetPrefs()->GetBoolean(prefs::kSafeBrowsingEnabled))
590 return false; 605 return false;
591 606
592 browser_sync::ProfileSyncService* profile_sync_service = 607 browser_sync::ProfileSyncService* profile_sync_service =
593 ProfileSyncServiceFactory::GetForProfile(profile); 608 ProfileSyncServiceFactory::GetForProfile(profile);
594 609
595 // Do not report if profile can't get a profile sync service or sync cannot 610 // Do not report if profile can't get a profile sync service or sync cannot
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
693 708
694 const std::string rappor_metric = GetRapporMetric(permission, action); 709 const std::string rappor_metric = GetRapporMetric(permission, action);
695 rappor::RapporServiceImpl* rappor_service = 710 rappor::RapporServiceImpl* rappor_service =
696 g_browser_process->rappor_service(); 711 g_browser_process->rappor_service();
697 if (!rappor_metric.empty() && rappor_service) { 712 if (!rappor_metric.empty() && rappor_service) {
698 rappor_service->RecordSampleString( 713 rappor_service->RecordSampleString(
699 rappor_metric, rappor::LOW_FREQUENCY_ETLD_PLUS_ONE_RAPPOR_TYPE, 714 rappor_metric, rappor::LOW_FREQUENCY_ETLD_PLUS_ONE_RAPPOR_TYPE,
700 rappor::GetDomainAndRegistrySampleFromGURL(requesting_origin)); 715 rappor::GetDomainAndRegistrySampleFromGURL(requesting_origin));
701 } 716 }
702 } 717 }
OLDNEW
« no previous file with comments | « chrome/browser/permissions/permission_uma_util.h ('k') | chrome/browser/permissions/permission_uma_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698