Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "base/memory/ptr_util.h" | 5 #include "base/memory/ptr_util.h" |
| 6 #include "chrome/browser/safe_browsing/permission_reporter.h" | 6 #include "chrome/browser/safe_browsing/permission_reporter.h" |
| 7 #include "chrome/common/safe_browsing/permission_report.pb.h" | 7 #include "chrome/common/safe_browsing/permission_report.pb.h" |
| 8 #include "components/variations/active_field_trials.h" | |
| 8 #include "content/public/browser/permission_type.h" | 9 #include "content/public/browser/permission_type.h" |
| 9 #include "net/url_request/report_sender.h" | 10 #include "net/url_request/report_sender.h" |
| 10 | 11 |
| 11 using content::PermissionType; | 12 using content::PermissionType; |
| 12 | 13 |
| 13 namespace safe_browsing { | 14 namespace safe_browsing { |
| 14 | 15 |
| 15 namespace { | 16 namespace { |
| 16 // URL to upload permission action reports. | 17 // URL to upload permission action reports. |
| 17 const char kPermissionActionReportingUploadUrl[] = | 18 const char kPermissionActionReportingUploadUrl[] = |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 96 | 97 |
| 97 // static | 98 // static |
| 98 bool PermissionReporter::BuildReport(const GURL& origin, | 99 bool PermissionReporter::BuildReport(const GURL& origin, |
| 99 PermissionType permission, | 100 PermissionType permission, |
| 100 PermissionAction action, | 101 PermissionAction action, |
| 101 std::string* output) { | 102 std::string* output) { |
| 102 PermissionReport report; | 103 PermissionReport report; |
| 103 report.set_origin(origin.spec()); | 104 report.set_origin(origin.spec()); |
| 104 report.set_permission(PermissionTypeForReport(permission)); | 105 report.set_permission(PermissionTypeForReport(permission)); |
| 105 report.set_action(PermissionActionForReport(action)); | 106 report.set_action(PermissionActionForReport(action)); |
| 106 // TODO(stefanocs): Collect field trials and platform type from global | 107 |
| 107 // variables to the permission report. | 108 // Collect platform data. |
| 109 #if defined(OS_ANDROID) | |
| 110 report.set_platform_type(PermissionReport::ANDROID_PLATFORM); | |
| 111 #elif defined(OS_MACOSX) || defined(OS_WIN) || defined(OS_CHROMEOS) || \ | |
| 112 defined(OS_LINUX) | |
| 113 report.set_platform_type(PermissionReport::DESKTOP_PLATFORM); | |
| 114 #else | |
| 115 #error Unsupported platform. | |
| 116 #endif | |
| 117 | |
| 118 // Collect field trials data. | |
|
kcarattini
2016/06/24 03:42:35
trials -> trial
stefanocs
2016/06/24 05:23:04
Done.
| |
| 119 std::vector<variations::ActiveGroupId> active_groups_ids; | |
|
kcarattini
2016/06/24 03:42:35
active_groups_ids -> active_group_ids
stefanocs
2016/06/24 05:23:04
Done.
| |
| 120 variations::GetFieldTrialActiveGroupIds(&active_groups_ids); | |
| 121 for (auto active_group_id : active_groups_ids) { | |
| 122 PermissionReport::FieldTrial* field_trial = report.add_field_trials(); | |
| 123 field_trial->set_name_id(active_group_id.name); | |
| 124 field_trial->set_group_id(active_group_id.group); | |
| 125 } | |
| 108 return report.SerializeToString(output); | 126 return report.SerializeToString(output); |
| 109 } | 127 } |
| 110 | 128 |
| 111 } // namespace safe_browsing | 129 } // namespace safe_browsing |
| OLD | NEW |