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

Side by Side Diff: components/safe_browsing/password_protection/password_protection_request.h

Issue 2892093003: Don't trigger Phishguard pings if we cannot compute URL reputation. (Closed)
Patch Set: update comments 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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 COMPONENTS_SAFE_BROWSING_PASSWORD_PROTECTION_PASSWORD_PROTECTION_REQUEST _H_ 5 #ifndef COMPONENTS_SAFE_BROWSING_PASSWORD_PROTECTION_PASSWORD_PROTECTION_REQUEST _H_
6 #define COMPONENTS_SAFE_BROWSING_PASSWORD_PROTECTION_PASSWORD_PROTECTION_REQUEST _H_ 6 #define COMPONENTS_SAFE_BROWSING_PASSWORD_PROTECTION_PASSWORD_PROTECTION_REQUEST _H_
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/task/cancelable_task_tracker.h" 10 #include "base/task/cancelable_task_tracker.h"
(...skipping 22 matching lines...) Expand all
33 // (5) | UI | If verdict cached, quit request; else prepare request proto. 33 // (5) | UI | If verdict cached, quit request; else prepare request proto.
34 // (6) | UI | Start a timeout task, and send network request. 34 // (6) | UI | Start a timeout task, and send network request.
35 // (7) | UI | On receiving response, handle response and finish. 35 // (7) | UI | On receiving response, handle response and finish.
36 // | | On request timeout, cancel request. 36 // | | On request timeout, cancel request.
37 // | | On deletion of |password_protection_service_|, cancel request. 37 // | | On deletion of |password_protection_service_|, cancel request.
38 class PasswordProtectionRequest : public base::RefCountedThreadSafe< 38 class PasswordProtectionRequest : public base::RefCountedThreadSafe<
39 PasswordProtectionRequest, 39 PasswordProtectionRequest,
40 content::BrowserThread::DeleteOnUIThread>, 40 content::BrowserThread::DeleteOnUIThread>,
41 public net::URLFetcherDelegate { 41 public net::URLFetcherDelegate {
42 public: 42 public:
43 PasswordProtectionRequest(const GURL& main_frame_url, 43 PasswordProtectionRequest(content::WebContents* web_contents,
44 const GURL& main_frame_url,
44 const GURL& password_form_action, 45 const GURL& password_form_action,
45 const GURL& password_form_frame_url, 46 const GURL& password_form_frame_url,
46 const std::string& saved_domain, 47 const std::string& saved_domain,
47 LoginReputationClientRequest::TriggerType type, 48 LoginReputationClientRequest::TriggerType type,
48 PasswordProtectionService* pps, 49 PasswordProtectionService* pps,
49 int request_timeout_in_ms); 50 int request_timeout_in_ms);
50 51
51 base::WeakPtr<PasswordProtectionRequest> GetWeakPtr() { 52 base::WeakPtr<PasswordProtectionRequest> GetWeakPtr() {
52 return weakptr_factory_.GetWeakPtr(); 53 return weakptr_factory_.GetWeakPtr();
53 } 54 }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 // Initiates network request to Safe Browsing backend. 97 // Initiates network request to Safe Browsing backend.
97 void SendRequest(); 98 void SendRequest();
98 99
99 // Start a timer to cancel the request if it takes too long. 100 // Start a timer to cancel the request if it takes too long.
100 void StartTimeout(); 101 void StartTimeout();
101 102
102 // |this| will be destroyed after calling this function. 103 // |this| will be destroyed after calling this function.
103 void Finish(PasswordProtectionService::RequestOutcome outcome, 104 void Finish(PasswordProtectionService::RequestOutcome outcome,
104 std::unique_ptr<LoginReputationClientResponse> response); 105 std::unique_ptr<LoginReputationClientResponse> response);
105 106
107 // WebContents of the password protection event.
108 content::WebContents* web_contents_;
109
106 // Main frame URL of the login form. 110 // Main frame URL of the login form.
107 const GURL main_frame_url_; 111 const GURL main_frame_url_;
108 112
109 // The action URL of the password form. 113 // The action URL of the password form.
110 const GURL password_form_action_; 114 const GURL password_form_action_;
111 115
112 // Frame url of the detected password form. 116 // Frame url of the detected password form.
113 const GURL password_form_frame_url_; 117 const GURL password_form_frame_url_;
114 118
115 // Domain on which a password is saved and gets reused. 119 // Domain on which a password is saved and gets reused.
116 const std::string saved_domain_; 120 const std::string saved_domain_;
117 121
118 // If this request is for unfamiliar login page or for a password reuse event. 122 // If this request is for unfamiliar login page or for a password reuse event.
119 const LoginReputationClientRequest::TriggerType request_type_; 123 const LoginReputationClientRequest::TriggerType request_type_;
120 124
121 // When request is sent. 125 // When request is sent.
122 base::TimeTicks request_start_time_; 126 base::TimeTicks request_start_time_;
123 127
124 // URLFetcher instance for sending request and receiving response. 128 // URLFetcher instance for sending request and receiving response.
125 std::unique_ptr<net::URLFetcher> fetcher_; 129 std::unique_ptr<net::URLFetcher> fetcher_;
126 130
127 // The PasswordProtectionService instance owns |this|. 131 // The PasswordProtectionService instance owns |this|.
128 // Can only be accessed on UI thread. 132 // Can only be accessed on UI thread.
129 PasswordProtectionService* password_protection_service_; 133 PasswordProtectionService* password_protection_service_;
130 134
131 // Safe Browsing database manager used to look up CSD whitelist.
132 // Can only be accessed on IO thread.
133 scoped_refptr<SafeBrowsingDatabaseManager> database_manager_;
134
135 // If we haven't receive response after this period of time, we cancel this 135 // If we haven't receive response after this period of time, we cancel this
136 // request. 136 // request.
137 const int request_timeout_in_ms_; 137 const int request_timeout_in_ms_;
138 138
139 std::unique_ptr<LoginReputationClientRequest> request_proto_; 139 std::unique_ptr<LoginReputationClientRequest> request_proto_;
140 140
141 // Needed for canceling tasks posted to different threads. 141 // Needed for canceling tasks posted to different threads.
142 base::CancelableTaskTracker tracker_; 142 base::CancelableTaskTracker tracker_;
143 143
144 base::WeakPtrFactory<PasswordProtectionRequest> weakptr_factory_; 144 base::WeakPtrFactory<PasswordProtectionRequest> weakptr_factory_;
145 DISALLOW_COPY_AND_ASSIGN(PasswordProtectionRequest); 145 DISALLOW_COPY_AND_ASSIGN(PasswordProtectionRequest);
146 }; 146 };
147 147
148 } // namespace safe_browsing 148 } // namespace safe_browsing
149 149
150 #endif // COMPONENTS_SAFE_BROWSING_PASSWORD_PROTECTION_PASSWORD_PROTECTION_REQU EST_H_ 150 #endif // COMPONENTS_SAFE_BROWSING_PASSWORD_PROTECTION_PASSWORD_PROTECTION_REQU EST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698