| 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 14 matching lines...) Expand all Loading... |
| 25 } | 25 } |
| 26 | 26 |
| 27 class GURL; | 27 class GURL; |
| 28 class HostContentSettingsMap; | 28 class HostContentSettingsMap; |
| 29 | 29 |
| 30 namespace safe_browsing { | 30 namespace safe_browsing { |
| 31 | 31 |
| 32 class SafeBrowsingDatabaseManager; | 32 class SafeBrowsingDatabaseManager; |
| 33 class PasswordProtectionRequest; | 33 class PasswordProtectionRequest; |
| 34 | 34 |
| 35 using PasswordFormList = google::protobuf::RepeatedPtrField< | |
| 36 LoginReputationClientRequest::Frame::Form>; | |
| 37 | |
| 38 // The PasswordProtectionFrame struct encapsulates information about a render | |
| 39 // frame that has password form(s). | |
| 40 struct PasswordProtectionFrame { | |
| 41 int render_frame_routing_id; | |
| 42 int parent_frame_routing_id; | |
| 43 GURL last_committed_url; | |
| 44 std::unique_ptr<PasswordFormList> password_forms; | |
| 45 | |
| 46 PasswordProtectionFrame() = delete; | |
| 47 | |
| 48 ~PasswordProtectionFrame(); | |
| 49 }; | |
| 50 | |
| 51 using PasswordProtectionFrameList = | |
| 52 std::vector<std::unique_ptr<PasswordProtectionFrame>>; | |
| 53 | |
| 54 // Manage password protection pings and verdicts. There is one instance of this | 35 // Manage password protection pings and verdicts. There is one instance of this |
| 55 // class per profile. Therefore, every PasswordProtectionService instance is | 36 // class per profile. Therefore, every PasswordProtectionService instance is |
| 56 // associated with a unique HistoryService instance and a unique | 37 // associated with a unique HistoryService instance and a unique |
| 57 // HostContentSettingsMap instance. | 38 // HostContentSettingsMap instance. |
| 58 class PasswordProtectionService : public history::HistoryServiceObserver { | 39 class PasswordProtectionService : public history::HistoryServiceObserver { |
| 59 public: | 40 public: |
| 60 PasswordProtectionService( | 41 PasswordProtectionService( |
| 61 const scoped_refptr<SafeBrowsingDatabaseManager>& database_manager, | 42 const scoped_refptr<SafeBrowsingDatabaseManager>& database_manager, |
| 62 scoped_refptr<net::URLRequestContextGetter> request_context_getter, | 43 scoped_refptr<net::URLRequestContextGetter> request_context_getter, |
| 63 history::HistoryService* history_service, | 44 history::HistoryService* history_service, |
| (...skipping 18 matching lines...) Expand all Loading... |
| 82 | 63 |
| 83 // Stores |verdict| in |settings| based on |url|, |verdict| and | 64 // Stores |verdict| in |settings| based on |url|, |verdict| and |
| 84 // |receive_time|. | 65 // |receive_time|. |
| 85 void CacheVerdict(const GURL& url, | 66 void CacheVerdict(const GURL& url, |
| 86 LoginReputationClientResponse* verdict, | 67 LoginReputationClientResponse* verdict, |
| 87 const base::Time& receive_time); | 68 const base::Time& receive_time); |
| 88 | 69 |
| 89 // Creates an instance of PasswordProtectionRequest and call Start() on that | 70 // Creates an instance of PasswordProtectionRequest and call Start() on that |
| 90 // instance. This function also insert this request object in |requests_| for | 71 // instance. This function also insert this request object in |requests_| for |
| 91 // record keeping. | 72 // record keeping. |
| 92 void StartRequest( | 73 void StartRequest(const GURL& main_frame_url, |
| 74 const GURL& password_form_action, |
| 75 const GURL& password_form_frame_url, |
| 76 LoginReputationClientRequest::TriggerType type); |
| 77 |
| 78 virtual void MaybeStartLowReputationRequest( |
| 93 const GURL& main_frame_url, | 79 const GURL& main_frame_url, |
| 94 LoginReputationClientRequest::TriggerType type, | 80 const GURL& password_form_action, |
| 95 std::unique_ptr<PasswordProtectionFrameList> password_frames); | 81 const GURL& password_form_frame_url); |
| 96 | |
| 97 void MaybeStartLowReputationRequest( | |
| 98 const GURL& main_frame_url, | |
| 99 std::unique_ptr<PasswordProtectionFrameList> password_frames); | |
| 100 | 82 |
| 101 scoped_refptr<SafeBrowsingDatabaseManager> database_manager(); | 83 scoped_refptr<SafeBrowsingDatabaseManager> database_manager(); |
| 102 | 84 |
| 103 protected: | 85 protected: |
| 104 friend class PasswordProtectionRequest; | 86 friend class PasswordProtectionRequest; |
| 105 | 87 |
| 106 // Called by a PasswordProtectionRequest instance when it finishes to remove | 88 // Called by a PasswordProtectionRequest instance when it finishes to remove |
| 107 // itself from |requests_|. | 89 // itself from |requests_|. |
| 108 virtual void RequestFinished( | 90 virtual void RequestFinished( |
| 109 PasswordProtectionRequest* request, | 91 PasswordProtectionRequest* request, |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 // we need CancelableTaskTracker to cancel tasks posted to IO thread. | 198 // we need CancelableTaskTracker to cancel tasks posted to IO thread. |
| 217 base::CancelableTaskTracker tracker_; | 199 base::CancelableTaskTracker tracker_; |
| 218 | 200 |
| 219 base::WeakPtrFactory<PasswordProtectionService> weak_factory_; | 201 base::WeakPtrFactory<PasswordProtectionService> weak_factory_; |
| 220 DISALLOW_COPY_AND_ASSIGN(PasswordProtectionService); | 202 DISALLOW_COPY_AND_ASSIGN(PasswordProtectionService); |
| 221 }; | 203 }; |
| 222 | 204 |
| 223 } // namespace safe_browsing | 205 } // namespace safe_browsing |
| 224 | 206 |
| 225 #endif // COMPONENTS_SAFE_BROWSING_PASSWORD_PROTECTION_PASSWORD_PROTECTION_SERV
ICE_H_ | 207 #endif // COMPONENTS_SAFE_BROWSING_PASSWORD_PROTECTION_PASSWORD_PROTECTION_SERV
ICE_H_ |
| OLD | NEW |