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

Side by Side Diff: chrome/browser/safe_browsing/permission_reporter.h

Issue 2075523002: Add SourceUI field to permission report (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge Created 4 years, 5 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 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 #ifndef CHROME_BROWSER_SAFE_BROWSING_PERMISSION_REPORTER_H_ 5 #ifndef CHROME_BROWSER_SAFE_BROWSING_PERMISSION_REPORTER_H_
6 #define CHROME_BROWSER_SAFE_BROWSING_PERMISSION_REPORTER_H_ 6 #define CHROME_BROWSER_SAFE_BROWSING_PERMISSION_REPORTER_H_
7 7
8 #include <queue> 8 #include <queue>
9 #include <string> 9 #include <string>
10 #include <unordered_map> 10 #include <unordered_map>
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 ~PermissionReporter(); 48 ~PermissionReporter();
49 49
50 // Sends a serialized permission report to the report collection server. 50 // Sends a serialized permission report to the report collection server.
51 // The permission report includes |origin| as the origin of 51 // The permission report includes |origin| as the origin of
52 // the site requesting permission, |permission| as the type of permission 52 // the site requesting permission, |permission| as the type of permission
53 // requested, and |action| as the action taken. The report will be serialized 53 // requested, and |action| as the action taken. The report will be serialized
54 // using protobuf defined in 54 // using protobuf defined in
55 // //src/chrome/common/safe_browsing/permission_report.proto 55 // //src/chrome/common/safe_browsing/permission_report.proto
56 void SendReport(const GURL& origin, 56 void SendReport(const GURL& origin,
57 content::PermissionType permission, 57 content::PermissionType permission,
58 PermissionAction action); 58 PermissionAction action,
59 PermissionSourceUI source_ui);
59 60
60 private: 61 private:
61 friend class PermissionReporterTest; 62 friend class PermissionReporterTest;
62 63
63 // Used by tests. This constructor allows tests to have access to the 64 // Used by tests. This constructor allows tests to have access to the
64 // ReportSender and use a test Clock. 65 // ReportSender and use a test Clock.
65 PermissionReporter(std::unique_ptr<net::ReportSender> report_sender, 66 PermissionReporter(std::unique_ptr<net::ReportSender> report_sender,
66 std::unique_ptr<base::Clock> clock); 67 std::unique_ptr<base::Clock> clock);
67 68
68 // Builds and serializes a permission report with |origin| as the origin of 69 // Builds and serializes a permission report with |origin| as the origin of
69 // the site requesting permission, |permission| as the type of permission 70 // the site requesting permission, |permission| as the type of permission
70 // requested, and |action| as the action taken. The serialized report is 71 // requested, and |action| as the action taken. The serialized report is
71 // written into |output|. Returns true if the serialization was successful and 72 // written into |output|. Returns true if the serialization was successful and
72 // false otherwise. 73 // false otherwise.
73 static bool BuildReport(const GURL& origin, 74 static bool BuildReport(const GURL& origin,
74 content::PermissionType permission, 75 content::PermissionType permission,
75 PermissionAction action, 76 PermissionAction action,
77 PermissionSourceUI source_ui,
76 std::string* output); 78 std::string* output);
77 79
78 // Returns false if the number of reports sent in the last one minute per 80 // Returns false if the number of reports sent in the last one minute per
79 // origin per permission is under a threshold, otherwise true. 81 // origin per permission is under a threshold, otherwise true.
80 bool IsReportThresholdExceeded(content::PermissionType permission, 82 bool IsReportThresholdExceeded(content::PermissionType permission,
81 const GURL& origin); 83 const GURL& origin);
82 84
83 std::unique_ptr<net::ReportSender> permission_report_sender_; 85 std::unique_ptr<net::ReportSender> permission_report_sender_;
84 86
85 // TODO(stefanocs): This might introduce a memory issue since older entries 87 // TODO(stefanocs): This might introduce a memory issue since older entries
86 // are not removed until a new report with the corresponding key is added. We 88 // are not removed until a new report with the corresponding key is added. We
87 // should address this issue if that becomes a problem in the future. 89 // should address this issue if that becomes a problem in the future.
88 std::unordered_map<PermissionAndOrigin, 90 std::unordered_map<PermissionAndOrigin,
89 std::queue<base::Time>, 91 std::queue<base::Time>,
90 PermissionAndOriginHash> 92 PermissionAndOriginHash>
91 report_logs_; 93 report_logs_;
92 94
93 std::unique_ptr<base::Clock> clock_; 95 std::unique_ptr<base::Clock> clock_;
94 96
95 DISALLOW_COPY_AND_ASSIGN(PermissionReporter); 97 DISALLOW_COPY_AND_ASSIGN(PermissionReporter);
96 }; 98 };
97 99
98 } // namespace safe_browsing 100 } // namespace safe_browsing
99 101
100 #endif // CHROME_BROWSER_SAFE_BROWSING_PERMISSION_REPORTER_H_ 102 #endif // CHROME_BROWSER_SAFE_BROWSING_PERMISSION_REPORTER_H_
OLDNEW
« no previous file with comments | « chrome/browser/permissions/permission_util.cc ('k') | chrome/browser/safe_browsing/permission_reporter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698