Chromium Code Reviews| Index: components/safe_browsing/password_protection/password_protection_service.h |
| diff --git a/components/safe_browsing/password_protection/password_protection_service.h b/components/safe_browsing/password_protection/password_protection_service.h |
| index 4800ae9739fa5218cb7543626f299e8a033736a3..a2c977ba58924c866e0220c11230179c21c156ad 100644 |
| --- a/components/safe_browsing/password_protection/password_protection_service.h |
| +++ b/components/safe_browsing/password_protection/password_protection_service.h |
| @@ -49,6 +49,7 @@ extern const char kPasswordEntryRequestOutcomeHistogramName[]; |
| // HostContentSettingsMap instance. |
| class PasswordProtectionService : public history::HistoryServiceObserver { |
| public: |
| + using TriggerType = LoginReputationClientRequest::TriggerType; |
| // The outcome of the request. These values are used for UMA. |
| // DO NOT CHANGE THE ORDERING OF THESE VALUES. |
| enum RequestOutcome { |
| @@ -87,11 +88,13 @@ class PasswordProtectionService : public history::HistoryServiceObserver { |
| // any thread. |
| LoginReputationClientResponse::VerdictType GetCachedVerdict( |
| const GURL& url, |
| + TriggerType type, |
| LoginReputationClientResponse* out_response); |
| - // Stores |verdict| in |settings| based on |url|, |verdict| and |
| + // Stores |verdict| in |settings| based on its |type|, |url|, |verdict| and |
| // |receive_time|. |
| virtual void CacheVerdict(const GURL& url, |
| + TriggerType type, |
| LoginReputationClientResponse* verdict, |
| const base::Time& receive_time); |
| @@ -106,7 +109,7 @@ class PasswordProtectionService : public history::HistoryServiceObserver { |
| const GURL& password_form_action, |
| const GURL& password_form_frame_url, |
| const std::string& saved_domain, |
| - LoginReputationClientRequest::TriggerType type); |
| + TriggerType type); |
|
lpz
2017/06/08 15:18:33
nit: type -> trigger_type or verdict_type or reque
Jialiu Lin
2017/06/08 20:47:30
Done.
|
| virtual void MaybeStartPasswordFieldOnFocusRequest( |
| content::WebContents* web_contents, |
| @@ -150,9 +153,9 @@ class PasswordProtectionService : public history::HistoryServiceObserver { |
| // the requests. |
| void CancelPendingRequests(); |
| - // Gets the total number of verdict (no matter expired or not) we cached for |
| - // current active profile. |
| - virtual int GetStoredVerdictCount(); |
| + // Gets the total number of verdicts of the specified |type| (no matter |
|
lpz
2017/06/08 15:18:33
nit: i find the wording a bit awkward, consider:
Jialiu Lin
2017/06/08 20:47:30
Done.
|
| + // expired or not) we cached for current active profile. |
| + virtual int GetStoredVerdictCount(TriggerType type); |
| scoped_refptr<net::URLRequestContextGetter> request_context_getter() { |
| return request_context_getter_; |
| @@ -171,9 +174,8 @@ class PasswordProtectionService : public history::HistoryServiceObserver { |
| int event_tab_id, // -1 if tab id is not available. |
| LoginReputationClientRequest::Frame* frame) = 0; |
| - void FillUserPopulation( |
| - const LoginReputationClientRequest::TriggerType& request_type, |
| - LoginReputationClientRequest* request_proto); |
| + void FillUserPopulation(TriggerType request_type, |
| + LoginReputationClientRequest* request_proto); |
| virtual bool IsExtendedReporting() = 0; |
| @@ -221,6 +223,15 @@ class PasswordProtectionService : public history::HistoryServiceObserver { |
| void RemoveContentSettingsOnURLsDeleted(bool all_history, |
| const history::URLRows& deleted_rows); |
| + // Helper function called by RemoveContentSettingsOnURLsDeleted(..). It |
| + // calculate the number of verdicts of |type| that associate with |url|. |
| + int GetVerdictCountForURL(const GURL& url, TriggerType type); |
| + |
| + // Remove verdict of |type| from |cache_dict|. Return false if no verdict |
| + // removed, true otherwise. |
| + bool RemoveExpiredVerdicts(TriggerType type, |
| + base::DictionaryValue* cache_dict); |
| + |
| static bool ParseVerdictEntry(base::DictionaryValue* verdict_entry, |
| int* out_verdict_received_time, |
| LoginReputationClientResponse* out_verdict); |
| @@ -243,8 +254,12 @@ class PasswordProtectionService : public history::HistoryServiceObserver { |
| static void RecordNoPingingReason(const base::Feature& feature, |
| RequestOutcome reason); |
| - // Number of verdict stored for this profile. |
| - int stored_verdict_count_; |
| + // Number of verdict stored for this profile for password on focus pings. |
| + int stored_verdict_count_password_on_focus_; |
| + |
| + // Number of verdict stored for this profile for protected password entry |
| + // pings. |
| + int stored_verdict_count_password_entry_; |
|
lpz
2017/06/08 15:18:33
do you foresee having other verdict types that wil
Jialiu Lin
2017/06/08 20:47:30
Acknowledged.
No, these are the only two pings.
|
| scoped_refptr<SafeBrowsingDatabaseManager> database_manager_; |