| OLD | NEW |
| 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" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 class GURL; | 28 class GURL; |
| 29 class HostContentSettingsMap; | 29 class HostContentSettingsMap; |
| 30 | 30 |
| 31 namespace safe_browsing { | 31 namespace safe_browsing { |
| 32 | 32 |
| 33 class SafeBrowsingDatabaseManager; | 33 class SafeBrowsingDatabaseManager; |
| 34 class PasswordProtectionRequest; | 34 class PasswordProtectionRequest; |
| 35 | 35 |
| 36 extern const base::Feature kPasswordFieldOnFocusPinging; | 36 extern const base::Feature kPasswordFieldOnFocusPinging; |
| 37 extern const base::Feature kProtectedPasswordEntryPinging; | 37 extern const base::Feature kProtectedPasswordEntryPinging; |
| 38 extern const char kPasswordOnFocusRequestOutcomeHistogramName[]; |
| 39 extern const char kPasswordEntryRequestOutcomeHistogramName[]; |
| 38 | 40 |
| 39 // Manage password protection pings and verdicts. There is one instance of this | 41 // Manage password protection pings and verdicts. There is one instance of this |
| 40 // class per profile. Therefore, every PasswordProtectionService instance is | 42 // class per profile. Therefore, every PasswordProtectionService instance is |
| 41 // associated with a unique HistoryService instance and a unique | 43 // associated with a unique HistoryService instance and a unique |
| 42 // HostContentSettingsMap instance. | 44 // HostContentSettingsMap instance. |
| 43 class PasswordProtectionService : public history::HistoryServiceObserver { | 45 class PasswordProtectionService : public history::HistoryServiceObserver { |
| 44 public: | 46 public: |
| 47 // The outcome of the request. These values are used for UMA. |
| 48 // DO NOT CHANGE THE ORDERING OF THESE VALUES. |
| 49 enum RequestOutcome { |
| 50 UNKNOWN = 0, |
| 51 SUCCEEDED = 1, |
| 52 CANCELED = 2, |
| 53 TIMEDOUT = 3, |
| 54 MATCHED_WHITELIST = 4, |
| 55 RESPONSE_ALREADY_CACHED = 5, |
| 56 DEPRECATED_NO_EXTENDED_REPORTING = 6, |
| 57 DISABLED_DUE_TO_INCOGNITO = 7, |
| 58 REQUEST_MALFORMED = 8, |
| 59 FETCH_FAILED = 9, |
| 60 RESPONSE_MALFORMED = 10, |
| 61 SERVICE_DESTROYED = 11, |
| 62 DISABLED_DUE_TO_FEATURE_DISABLED = 12, |
| 63 DISABLED_DUE_TO_USER_POPULATION = 13, |
| 64 MAX_OUTCOME |
| 65 }; |
| 45 PasswordProtectionService( | 66 PasswordProtectionService( |
| 46 const scoped_refptr<SafeBrowsingDatabaseManager>& database_manager, | 67 const scoped_refptr<SafeBrowsingDatabaseManager>& database_manager, |
| 47 scoped_refptr<net::URLRequestContextGetter> request_context_getter, | 68 scoped_refptr<net::URLRequestContextGetter> request_context_getter, |
| 48 history::HistoryService* history_service, | 69 history::HistoryService* history_service, |
| 49 HostContentSettingsMap* host_content_settings_map); | 70 HostContentSettingsMap* host_content_settings_map); |
| 50 | 71 |
| 51 ~PasswordProtectionService() override; | 72 ~PasswordProtectionService() override; |
| 52 | 73 |
| 53 base::WeakPtr<PasswordProtectionService> GetWeakPtr() { | 74 base::WeakPtr<PasswordProtectionService> GetWeakPtr() { |
| 54 return weak_factory_.GetWeakPtr(); | 75 return weak_factory_.GetWeakPtr(); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 75 void CleanUpExpiredVerdicts(); | 96 void CleanUpExpiredVerdicts(); |
| 76 | 97 |
| 77 // Creates an instance of PasswordProtectionRequest and call Start() on that | 98 // Creates an instance of PasswordProtectionRequest and call Start() on that |
| 78 // instance. This function also insert this request object in |requests_| for | 99 // instance. This function also insert this request object in |requests_| for |
| 79 // record keeping. | 100 // record keeping. |
| 80 void StartRequest(const GURL& main_frame_url, | 101 void StartRequest(const GURL& main_frame_url, |
| 81 const GURL& password_form_action, | 102 const GURL& password_form_action, |
| 82 const GURL& password_form_frame_url, | 103 const GURL& password_form_frame_url, |
| 83 LoginReputationClientRequest::TriggerType type); | 104 LoginReputationClientRequest::TriggerType type); |
| 84 | 105 |
| 85 virtual void MaybeStartLowReputationRequest( | 106 virtual void MaybeStartPasswordFieldOnFocusRequest( |
| 86 const GURL& main_frame_url, | 107 const GURL& main_frame_url, |
| 87 const GURL& password_form_action, | 108 const GURL& password_form_action, |
| 88 const GURL& password_form_frame_url); | 109 const GURL& password_form_frame_url); |
| 89 | 110 |
| 90 scoped_refptr<SafeBrowsingDatabaseManager> database_manager(); | 111 scoped_refptr<SafeBrowsingDatabaseManager> database_manager(); |
| 91 | 112 |
| 92 protected: | 113 protected: |
| 93 friend class PasswordProtectionRequest; | 114 friend class PasswordProtectionRequest; |
| 94 | 115 |
| 95 // Called by a PasswordProtectionRequest instance when it finishes to remove | 116 // Called by a PasswordProtectionRequest instance when it finishes to remove |
| (...skipping 28 matching lines...) Expand all Loading... |
| 124 LoginReputationClientRequest::Frame* frame) = 0; | 145 LoginReputationClientRequest::Frame* frame) = 0; |
| 125 | 146 |
| 126 void FillUserPopulation( | 147 void FillUserPopulation( |
| 127 const LoginReputationClientRequest::TriggerType& request_type, | 148 const LoginReputationClientRequest::TriggerType& request_type, |
| 128 LoginReputationClientRequest* request_proto); | 149 LoginReputationClientRequest* request_proto); |
| 129 | 150 |
| 130 virtual bool IsExtendedReporting() = 0; | 151 virtual bool IsExtendedReporting() = 0; |
| 131 | 152 |
| 132 virtual bool IsIncognito() = 0; | 153 virtual bool IsIncognito() = 0; |
| 133 | 154 |
| 134 virtual bool IsPingingEnabled(const base::Feature& feature) = 0; | 155 virtual bool IsPingingEnabled(const base::Feature& feature, |
| 156 RequestOutcome* reason) = 0; |
| 135 | 157 |
| 136 virtual bool IsHistorySyncEnabled() = 0; | 158 virtual bool IsHistorySyncEnabled() = 0; |
| 137 | 159 |
| 138 void CheckCsdWhitelistOnIOThread(const GURL& url, bool* check_result); | 160 void CheckCsdWhitelistOnIOThread(const GURL& url, bool* check_result); |
| 139 | 161 |
| 140 // Increases "PasswordManager.PasswordReuse.MainFrameMatchCsdWhitelist" UMA | 162 // Increases "PasswordManager.PasswordReuse.MainFrameMatchCsdWhitelist" UMA |
| 141 // metric based on input. | 163 // metric based on input. |
| 142 void OnMatchCsdWhiteListResult(const bool* match_whitelist); | 164 void OnMatchCsdWhiteListResult(const bool* match_whitelist); |
| 143 | 165 |
| 144 HostContentSettingsMap* content_settings() const { return content_settings_; } | 166 HostContentSettingsMap* content_settings() const { return content_settings_; } |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 static void GeneratePathVariantsWithoutQuery(const GURL& url, | 207 static void GeneratePathVariantsWithoutQuery(const GURL& url, |
| 186 std::vector<std::string>* paths); | 208 std::vector<std::string>* paths); |
| 187 | 209 |
| 188 static std::string GetCacheExpressionPath( | 210 static std::string GetCacheExpressionPath( |
| 189 const std::string& cache_expression); | 211 const std::string& cache_expression); |
| 190 | 212 |
| 191 static std::unique_ptr<base::DictionaryValue> CreateDictionaryFromVerdict( | 213 static std::unique_ptr<base::DictionaryValue> CreateDictionaryFromVerdict( |
| 192 const LoginReputationClientResponse* verdict, | 214 const LoginReputationClientResponse* verdict, |
| 193 const base::Time& receive_time); | 215 const base::Time& receive_time); |
| 194 | 216 |
| 217 static void RecordPingingDisabledReason(const base::Feature& feature, |
| 218 RequestOutcome reason); |
| 195 // Number of verdict stored for this profile. | 219 // Number of verdict stored for this profile. |
| 196 int stored_verdict_count_; | 220 int stored_verdict_count_; |
| 197 | 221 |
| 198 scoped_refptr<SafeBrowsingDatabaseManager> database_manager_; | 222 scoped_refptr<SafeBrowsingDatabaseManager> database_manager_; |
| 199 | 223 |
| 200 // The context we use to issue network requests. This request_context_getter | 224 // The context we use to issue network requests. This request_context_getter |
| 201 // is obtained from SafeBrowsingService so that we can use the Safe Browsing | 225 // is obtained from SafeBrowsingService so that we can use the Safe Browsing |
| 202 // cookie store. | 226 // cookie store. |
| 203 scoped_refptr<net::URLRequestContextGetter> request_context_getter_; | 227 scoped_refptr<net::URLRequestContextGetter> request_context_getter_; |
| 204 | 228 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 215 // we need CancelableTaskTracker to cancel tasks posted to IO thread. | 239 // we need CancelableTaskTracker to cancel tasks posted to IO thread. |
| 216 base::CancelableTaskTracker tracker_; | 240 base::CancelableTaskTracker tracker_; |
| 217 | 241 |
| 218 base::WeakPtrFactory<PasswordProtectionService> weak_factory_; | 242 base::WeakPtrFactory<PasswordProtectionService> weak_factory_; |
| 219 DISALLOW_COPY_AND_ASSIGN(PasswordProtectionService); | 243 DISALLOW_COPY_AND_ASSIGN(PasswordProtectionService); |
| 220 }; | 244 }; |
| 221 | 245 |
| 222 } // namespace safe_browsing | 246 } // namespace safe_browsing |
| 223 | 247 |
| 224 #endif // COMPONENTS_SAFE_BROWSING_PASSWORD_PROTECTION_PASSWORD_PROTECTION_SERV
ICE_H_ | 248 #endif // COMPONENTS_SAFE_BROWSING_PASSWORD_PROTECTION_PASSWORD_PROTECTION_SERV
ICE_H_ |
| OLD | NEW |