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

Side by Side Diff: components/safe_browsing/password_protection/password_protection_service.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_SERVICE _H_ 5 #ifndef COMPONENTS_SAFE_BROWSING_PASSWORD_PROTECTION_PASSWORD_PROTECTION_SERVICE _H_
6 #define COMPONENTS_SAFE_BROWSING_PASSWORD_PROTECTION_PASSWORD_PROTECTION_SERVICE _H_ 6 #define COMPONENTS_SAFE_BROWSING_PASSWORD_PROTECTION_PASSWORD_PROTECTION_SERVICE _H_
7 7
8 #include <set> 8 #include <set>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/feature_list.h" 11 #include "base/feature_list.h"
12 #include "base/gtest_prod_util.h" 12 #include "base/gtest_prod_util.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
15 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
16 #include "base/scoped_observer.h" 16 #include "base/scoped_observer.h"
17 #include "base/task/cancelable_task_tracker.h" 17 #include "base/task/cancelable_task_tracker.h"
18 #include "base/values.h" 18 #include "base/values.h"
19 #include "components/history/core/browser/history_service_observer.h" 19 #include "components/history/core/browser/history_service_observer.h"
20 #include "components/safe_browsing/csd.pb.h" 20 #include "components/safe_browsing/csd.pb.h"
21 #include "net/url_request/url_request_context_getter.h" 21 #include "net/url_request/url_request_context_getter.h"
22 #include "third_party/protobuf/src/google/protobuf/repeated_field.h" 22 #include "third_party/protobuf/src/google/protobuf/repeated_field.h"
23 23
24 namespace content {
25 class WebContents;
26 }
27
24 namespace history { 28 namespace history {
25 class HistoryService; 29 class HistoryService;
26 } 30 }
27 31
28 class GURL; 32 class GURL;
29 class HostContentSettingsMap; 33 class HostContentSettingsMap;
30 34
31 namespace safe_browsing { 35 namespace safe_browsing {
32 36
33 class SafeBrowsingDatabaseManager; 37 class SafeBrowsingDatabaseManager;
(...skipping 20 matching lines...) Expand all
54 MATCHED_WHITELIST = 4, 58 MATCHED_WHITELIST = 4,
55 RESPONSE_ALREADY_CACHED = 5, 59 RESPONSE_ALREADY_CACHED = 5,
56 DEPRECATED_NO_EXTENDED_REPORTING = 6, 60 DEPRECATED_NO_EXTENDED_REPORTING = 6,
57 DISABLED_DUE_TO_INCOGNITO = 7, 61 DISABLED_DUE_TO_INCOGNITO = 7,
58 REQUEST_MALFORMED = 8, 62 REQUEST_MALFORMED = 8,
59 FETCH_FAILED = 9, 63 FETCH_FAILED = 9,
60 RESPONSE_MALFORMED = 10, 64 RESPONSE_MALFORMED = 10,
61 SERVICE_DESTROYED = 11, 65 SERVICE_DESTROYED = 11,
62 DISABLED_DUE_TO_FEATURE_DISABLED = 12, 66 DISABLED_DUE_TO_FEATURE_DISABLED = 12,
63 DISABLED_DUE_TO_USER_POPULATION = 13, 67 DISABLED_DUE_TO_USER_POPULATION = 13,
68 URL_NOT_VALID_FOR_REPUTATION_COMPUTING = 14,
64 MAX_OUTCOME 69 MAX_OUTCOME
65 }; 70 };
66 PasswordProtectionService( 71 PasswordProtectionService(
67 const scoped_refptr<SafeBrowsingDatabaseManager>& database_manager, 72 const scoped_refptr<SafeBrowsingDatabaseManager>& database_manager,
68 scoped_refptr<net::URLRequestContextGetter> request_context_getter, 73 scoped_refptr<net::URLRequestContextGetter> request_context_getter,
69 history::HistoryService* history_service, 74 history::HistoryService* history_service,
70 HostContentSettingsMap* host_content_settings_map); 75 HostContentSettingsMap* host_content_settings_map);
71 76
72 ~PasswordProtectionService() override; 77 ~PasswordProtectionService() override;
73 78
(...skipping 13 matching lines...) Expand all
87 void CacheVerdict(const GURL& url, 92 void CacheVerdict(const GURL& url,
88 LoginReputationClientResponse* verdict, 93 LoginReputationClientResponse* verdict,
89 const base::Time& receive_time); 94 const base::Time& receive_time);
90 95
91 // Removes all the expired verdicts from cache. 96 // Removes all the expired verdicts from cache.
92 void CleanUpExpiredVerdicts(); 97 void CleanUpExpiredVerdicts();
93 98
94 // Creates an instance of PasswordProtectionRequest and call Start() on that 99 // Creates an instance of PasswordProtectionRequest and call Start() on that
95 // instance. This function also insert this request object in |requests_| for 100 // instance. This function also insert this request object in |requests_| for
96 // record keeping. 101 // record keeping.
97 void StartRequest(const GURL& main_frame_url, 102 void StartRequest(content::WebContents* web_contents,
103 const GURL& main_frame_url,
98 const GURL& password_form_action, 104 const GURL& password_form_action,
99 const GURL& password_form_frame_url, 105 const GURL& password_form_frame_url,
100 const std::string& saved_domain, 106 const std::string& saved_domain,
101 LoginReputationClientRequest::TriggerType type); 107 LoginReputationClientRequest::TriggerType type);
102 108
103 virtual void MaybeStartPasswordFieldOnFocusRequest( 109 virtual void MaybeStartPasswordFieldOnFocusRequest(
110 content::WebContents* web_contents,
104 const GURL& main_frame_url, 111 const GURL& main_frame_url,
105 const GURL& password_form_action, 112 const GURL& password_form_action,
106 const GURL& password_form_frame_url); 113 const GURL& password_form_frame_url);
107 114
108 virtual void MaybeStartProtectedPasswordEntryRequest( 115 virtual void MaybeStartProtectedPasswordEntryRequest(
116 content::WebContents* web_contents,
109 const GURL& main_frame_url, 117 const GURL& main_frame_url,
110 const std::string& saved_domain); 118 const std::string& saved_domain);
111 119
112 scoped_refptr<SafeBrowsingDatabaseManager> database_manager(); 120 scoped_refptr<SafeBrowsingDatabaseManager> database_manager();
113 121
122 // Safe Browsing backend cannot get a reliable reputation of a URL if
123 // (1) URL is not valid
124 // (2) URL doesn't have http or https scheme
125 // (3) It maps to a local host.
126 // (4) Its hostname is an IP Address in an IANA-reserved range.
127 // (5) Its hostname is a not-yet-assigned by ICANN gTLD.
128 // (6) Its hostname is a dotless domain.
129 static bool CanGetReputationOfURL(const GURL& url);
130
114 protected: 131 protected:
115 friend class PasswordProtectionRequest; 132 friend class PasswordProtectionRequest;
116 133
134 // Chrome can send password protection ping if it is allowed by Finch config
135 // and if Safe Browsing can compute reputation of |main_frame_url| (e.g.
136 // Safe Browsing is not able to compute reputation of a private IP or
137 // a local host.)
138 bool CanSendPing(const base::Feature& feature, const GURL& main_frame_url);
139
117 // Called by a PasswordProtectionRequest instance when it finishes to remove 140 // Called by a PasswordProtectionRequest instance when it finishes to remove
118 // itself from |requests_|. 141 // itself from |requests_|.
119 virtual void RequestFinished( 142 virtual void RequestFinished(
120 PasswordProtectionRequest* request, 143 PasswordProtectionRequest* request,
121 std::unique_ptr<LoginReputationClientResponse> response); 144 std::unique_ptr<LoginReputationClientResponse> response);
122 145
123 // Cancels all requests in |requests_|, empties it, and releases references to 146 // Cancels all requests in |requests_|, empties it, and releases references to
124 // the requests. 147 // the requests.
125 void CancelPendingRequests(); 148 void CancelPendingRequests();
126 149
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 static void GeneratePathVariantsWithoutQuery(const GURL& url, 227 static void GeneratePathVariantsWithoutQuery(const GURL& url,
205 std::vector<std::string>* paths); 228 std::vector<std::string>* paths);
206 229
207 static std::string GetCacheExpressionPath( 230 static std::string GetCacheExpressionPath(
208 const std::string& cache_expression); 231 const std::string& cache_expression);
209 232
210 static std::unique_ptr<base::DictionaryValue> CreateDictionaryFromVerdict( 233 static std::unique_ptr<base::DictionaryValue> CreateDictionaryFromVerdict(
211 const LoginReputationClientResponse* verdict, 234 const LoginReputationClientResponse* verdict,
212 const base::Time& receive_time); 235 const base::Time& receive_time);
213 236
214 static void RecordPingingDisabledReason(const base::Feature& feature, 237 static void RecordNoPingingReason(const base::Feature& feature,
215 RequestOutcome reason); 238 RequestOutcome reason);
216 // Number of verdict stored for this profile. 239 // Number of verdict stored for this profile.
217 int stored_verdict_count_; 240 int stored_verdict_count_;
218 241
219 scoped_refptr<SafeBrowsingDatabaseManager> database_manager_; 242 scoped_refptr<SafeBrowsingDatabaseManager> database_manager_;
220 243
221 // The context we use to issue network requests. This request_context_getter 244 // The context we use to issue network requests. This request_context_getter
222 // is obtained from SafeBrowsingService so that we can use the Safe Browsing 245 // is obtained from SafeBrowsingService so that we can use the Safe Browsing
223 // cookie store. 246 // cookie store.
224 scoped_refptr<net::URLRequestContextGetter> request_context_getter_; 247 scoped_refptr<net::URLRequestContextGetter> request_context_getter_;
225 248
(...skipping 10 matching lines...) Expand all
236 // we need CancelableTaskTracker to cancel tasks posted to IO thread. 259 // we need CancelableTaskTracker to cancel tasks posted to IO thread.
237 base::CancelableTaskTracker tracker_; 260 base::CancelableTaskTracker tracker_;
238 261
239 base::WeakPtrFactory<PasswordProtectionService> weak_factory_; 262 base::WeakPtrFactory<PasswordProtectionService> weak_factory_;
240 DISALLOW_COPY_AND_ASSIGN(PasswordProtectionService); 263 DISALLOW_COPY_AND_ASSIGN(PasswordProtectionService);
241 }; 264 };
242 265
243 } // namespace safe_browsing 266 } // namespace safe_browsing
244 267
245 #endif // COMPONENTS_SAFE_BROWSING_PASSWORD_PROTECTION_PASSWORD_PROTECTION_SERV ICE_H_ 268 #endif // COMPONENTS_SAFE_BROWSING_PASSWORD_PROTECTION_PASSWORD_PROTECTION_SERV ICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698