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 "chrome/browser/safe_browsing/permission_reporter.h" | 5 #include "chrome/browser/safe_browsing/permission_reporter.h" |
| 6 #include "chrome/common/safe_browsing/permission_report.pb.h" | 6 #include "chrome/common/safe_browsing/permission_report.pb.h" |
| 7 #include "components/variations/active_field_trials.h" | |
| 7 #include "content/public/browser/permission_type.h" | 8 #include "content/public/browser/permission_type.h" |
| 8 #include "net/url_request/report_sender.h" | 9 #include "net/url_request/report_sender.h" |
| 9 | 10 |
| 10 using content::PermissionType; | 11 using content::PermissionType; |
| 11 | 12 |
| 12 namespace safe_browsing { | 13 namespace safe_browsing { |
| 13 | 14 |
| 14 namespace { | 15 namespace { |
| 15 // URL to upload permission action reports. | 16 // URL to upload permission action reports. |
| 16 const char kPermissionActionReportingUploadUrl[] = | 17 const char kPermissionActionReportingUploadUrl[] = |
| (...skipping 79 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(PermissionTypeToPermissionReportPermission(permission)); | 105 report.set_permission(PermissionTypeToPermissionReportPermission(permission)); |
| 105 report.set_action(PermissionActionToPermissionReportAction(action)); | 106 report.set_action(PermissionActionToPermissionReportAction(action)); |
| 106 // TODO(stefanocs): Collect other data for the report from global variables. | 107 // Collect platform data. |
| 108 #if defined(OS_ANDROID) | |
| 109 report.set_platform_type(PermissionReport::ANDROID_PLATFORM); | |
| 110 #elif defined(OS_MACOSX) || defined(OS_WIN) || defined(OS_CHROMEOS) || \ | |
| 111 defined(OS_LINUX) | |
| 112 report.set_platform_type(PermissionReport::DESKTOP_PLATFORM); | |
| 113 #else | |
| 114 report.set_platform_type(PermissionReport::PLATFORM_TYPE_UNSPECIFIED); | |
|
raymes
2016/06/20 01:32:11
Perhaps add a #error here instead of setting UNSPE
stefanocs
2016/06/21 07:01:01
Done.
| |
| 115 #endif | |
| 116 // Collect field trials data. | |
| 117 std::vector<variations::ActiveGroupId> active_groups_ids; | |
| 118 variations::GetFieldTrialActiveGroupIds(&active_groups_ids); | |
|
raymes
2016/06/20 01:32:11
I think Kendra mentioned we may only want to add f
kcarattini
2016/06/20 20:58:17
Hmm, I don't want to bloat the reports with unnece
| |
| 119 for (auto active_group_id : active_groups_ids) { | |
| 120 PermissionReport::FieldTrial* field_trial = report.add_field_trials(); | |
| 121 field_trial->set_name_id(active_group_id.name); | |
| 122 field_trial->set_group_id(active_group_id.group); | |
| 123 } | |
| 107 return report.SerializeToString(output); | 124 return report.SerializeToString(output); |
| 108 } | 125 } |
| 109 | 126 |
| 110 } // namespace safe_browsing | 127 } // namespace safe_browsing |
| OLD | NEW |