| 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_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 25 matching lines...) Expand all Loading... |
| 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(const GURL& main_frame_url, |
| 44 const GURL& password_form_action, | 44 const GURL& password_form_action, |
| 45 const GURL& password_form_frame_url, | 45 const GURL& password_form_frame_url, |
| 46 const std::string& saved_domain, |
| 46 LoginReputationClientRequest::TriggerType type, | 47 LoginReputationClientRequest::TriggerType type, |
| 47 PasswordProtectionService* pps, | 48 PasswordProtectionService* pps, |
| 48 int request_timeout_in_ms); | 49 int request_timeout_in_ms); |
| 49 | 50 |
| 50 base::WeakPtr<PasswordProtectionRequest> GetWeakPtr() { | 51 base::WeakPtr<PasswordProtectionRequest> GetWeakPtr() { |
| 51 return weakptr_factory_.GetWeakPtr(); | 52 return weakptr_factory_.GetWeakPtr(); |
| 52 } | 53 } |
| 53 | 54 |
| 54 // Starts processing request by checking extended reporting and incognito | 55 // Starts processing request by checking extended reporting and incognito |
| 55 // conditions. | 56 // conditions. |
| 56 void Start(); | 57 void Start(); |
| 57 | 58 |
| 58 // Cancels the current request. |timed_out| indicates if this cancellation is | 59 // Cancels the current request. |timed_out| indicates if this cancellation is |
| 59 // due to timeout. This function will call Finish() to destroy |this|. | 60 // due to timeout. This function will call Finish() to destroy |this|. |
| 60 void Cancel(bool timed_out); | 61 void Cancel(bool timed_out); |
| 61 | 62 |
| 62 // net::URLFetcherDelegate override. | 63 // net::URLFetcherDelegate override. |
| 63 // Processes the received response. | 64 // Processes the received response. |
| 64 void OnURLFetchComplete(const net::URLFetcher* source) override; | 65 void OnURLFetchComplete(const net::URLFetcher* source) override; |
| 65 | 66 |
| 66 GURL main_frame_url() const { return main_frame_url_; } | 67 GURL main_frame_url() const { return main_frame_url_; } |
| 67 | 68 |
| 69 LoginReputationClientRequest* request_proto() { return request_proto_.get(); } |
| 70 |
| 68 private: | 71 private: |
| 69 friend class base::RefCountedThreadSafe<PasswordProtectionRequest>; | 72 friend class base::RefCountedThreadSafe<PasswordProtectionRequest>; |
| 70 friend struct content::BrowserThread::DeleteOnThread< | 73 friend struct content::BrowserThread::DeleteOnThread< |
| 71 content::BrowserThread::UI>; | 74 content::BrowserThread::UI>; |
| 72 friend class base::DeleteHelper<PasswordProtectionRequest>; | 75 friend class base::DeleteHelper<PasswordProtectionRequest>; |
| 73 ~PasswordProtectionRequest() override; | 76 ~PasswordProtectionRequest() override; |
| 74 | 77 |
| 75 void CheckWhitelistOnUIThread(); | 78 void CheckWhitelistOnUIThread(); |
| 76 | 79 |
| 77 // If |main_frame_url_| matches whitelist, call Finish() immediately; | 80 // If |main_frame_url_| matches whitelist, call Finish() immediately; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 102 | 105 |
| 103 // Main frame URL of the login form. | 106 // Main frame URL of the login form. |
| 104 const GURL main_frame_url_; | 107 const GURL main_frame_url_; |
| 105 | 108 |
| 106 // The action URL of the password form. | 109 // The action URL of the password form. |
| 107 const GURL password_form_action_; | 110 const GURL password_form_action_; |
| 108 | 111 |
| 109 // Frame url of the detected password form. | 112 // Frame url of the detected password form. |
| 110 const GURL password_form_frame_url_; | 113 const GURL password_form_frame_url_; |
| 111 | 114 |
| 115 // Domain on which a password is saved and gets reused. |
| 116 const std::string saved_domain_; |
| 117 |
| 112 // If this request is for unfamiliar login page or for a password reuse event. | 118 // If this request is for unfamiliar login page or for a password reuse event. |
| 113 const LoginReputationClientRequest::TriggerType request_type_; | 119 const LoginReputationClientRequest::TriggerType request_type_; |
| 114 | 120 |
| 115 // When request is sent. | 121 // When request is sent. |
| 116 base::TimeTicks request_start_time_; | 122 base::TimeTicks request_start_time_; |
| 117 | 123 |
| 118 // URLFetcher instance for sending request and receiving response. | 124 // URLFetcher instance for sending request and receiving response. |
| 119 std::unique_ptr<net::URLFetcher> fetcher_; | 125 std::unique_ptr<net::URLFetcher> fetcher_; |
| 120 | 126 |
| 121 // The PasswordProtectionService instance owns |this|. | 127 // The PasswordProtectionService instance owns |this|. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 135 // Needed for canceling tasks posted to different threads. | 141 // Needed for canceling tasks posted to different threads. |
| 136 base::CancelableTaskTracker tracker_; | 142 base::CancelableTaskTracker tracker_; |
| 137 | 143 |
| 138 base::WeakPtrFactory<PasswordProtectionRequest> weakptr_factory_; | 144 base::WeakPtrFactory<PasswordProtectionRequest> weakptr_factory_; |
| 139 DISALLOW_COPY_AND_ASSIGN(PasswordProtectionRequest); | 145 DISALLOW_COPY_AND_ASSIGN(PasswordProtectionRequest); |
| 140 }; | 146 }; |
| 141 | 147 |
| 142 } // namespace safe_browsing | 148 } // namespace safe_browsing |
| 143 | 149 |
| 144 #endif // COMPONENTS_SAFE_BROWSING_PASSWORD_PROTECTION_PASSWORD_PROTECTION_REQU
EST_H_ | 150 #endif // COMPONENTS_SAFE_BROWSING_PASSWORD_PROTECTION_PASSWORD_PROTECTION_REQU
EST_H_ |
| OLD | NEW |