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

Side by Side Diff: chrome/browser/safe_browsing/safe_browsing_service.h

Issue 2783773002: Link PasswordProtectionService to Profile and SB Service (Closed)
Patch Set: rebase Created 3 years, 8 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // The Safe Browsing service is responsible for downloading anti-phishing and 5 // The Safe Browsing service is responsible for downloading anti-phishing and
6 // anti-malware tables and checking urls against them. 6 // anti-malware tables and checking urls against them.
7 7
8 #ifndef CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_SERVICE_H_ 8 #ifndef CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_SERVICE_H_
9 #define CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_SERVICE_H_ 9 #define CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_SERVICE_H_
10 10
11 #include <map> 11 #include <map>
12 #include <memory> 12 #include <memory>
13 #include <string> 13 #include <string>
14 14
15 #include "base/callback.h" 15 #include "base/callback.h"
16 #include "base/callback_list.h" 16 #include "base/callback_list.h"
17 #include "base/files/file_path.h" 17 #include "base/files/file_path.h"
18 #include "base/macros.h" 18 #include "base/macros.h"
19 #include "base/memory/ref_counted.h" 19 #include "base/memory/ref_counted.h"
20 #include "base/observer_list.h" 20 #include "base/observer_list.h"
21 #include "base/sequenced_task_runner_helpers.h" 21 #include "base/sequenced_task_runner_helpers.h"
22 #include "chrome/browser/safe_browsing/services_delegate.h" 22 #include "chrome/browser/safe_browsing/services_delegate.h"
23 #include "components/keyed_service/core/keyed_service_shutdown_notifier.h"
23 #include "components/safe_browsing_db/safe_browsing_prefs.h" 24 #include "components/safe_browsing_db/safe_browsing_prefs.h"
24 #include "components/safe_browsing_db/util.h" 25 #include "components/safe_browsing_db/util.h"
25 #include "components/safe_browsing_db/v4_feature_list.h" 26 #include "components/safe_browsing_db/v4_feature_list.h"
26 #include "content/public/browser/browser_thread.h" 27 #include "content/public/browser/browser_thread.h"
27 #include "content/public/browser/notification_observer.h" 28 #include "content/public/browser/notification_observer.h"
28 #include "content/public/browser/notification_registrar.h" 29 #include "content/public/browser/notification_registrar.h"
29 30
30 #if defined(FULL_SAFE_BROWSING) 31 #if defined(FULL_SAFE_BROWSING)
31 #include "chrome/browser/safe_browsing/incident_reporting/delayed_analysis_callb ack.h" 32 #include "chrome/browser/safe_browsing/incident_reporting/delayed_analysis_callb ack.h"
32 #endif 33 #endif
(...skipping 14 matching lines...) Expand all
47 namespace prefs { 48 namespace prefs {
48 namespace mojom { 49 namespace mojom {
49 class TrackedPreferenceValidationDelegate; 50 class TrackedPreferenceValidationDelegate;
50 } 51 }
51 } 52 }
52 53
53 namespace safe_browsing { 54 namespace safe_browsing {
54 class ClientSideDetectionService; 55 class ClientSideDetectionService;
55 class DownloadProtectionService; 56 class DownloadProtectionService;
56 class PasswordProtectionService; 57 class PasswordProtectionService;
58 class ChromePasswordProtectionService;
57 struct ResourceRequestInfo; 59 struct ResourceRequestInfo;
58 struct SafeBrowsingProtocolConfig; 60 struct SafeBrowsingProtocolConfig;
59 class SafeBrowsingDatabaseManager; 61 class SafeBrowsingDatabaseManager;
60 class SafeBrowsingNavigationObserverManager; 62 class SafeBrowsingNavigationObserverManager;
61 class SafeBrowsingPingManager; 63 class SafeBrowsingPingManager;
62 class SafeBrowsingProtocolManager; 64 class SafeBrowsingProtocolManager;
63 class SafeBrowsingProtocolManagerDelegate; 65 class SafeBrowsingProtocolManagerDelegate;
64 class SafeBrowsingServiceFactory; 66 class SafeBrowsingServiceFactory;
65 class SafeBrowsingUIManager; 67 class SafeBrowsingUIManager;
66 class SafeBrowsingURLRequestContextGetter; 68 class SafeBrowsingURLRequestContextGetter;
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 navigation_observer_manager(); 158 navigation_observer_manager();
157 159
158 SafeBrowsingProtocolManager* protocol_manager() const; 160 SafeBrowsingProtocolManager* protocol_manager() const;
159 161
160 SafeBrowsingPingManager* ping_manager() const; 162 SafeBrowsingPingManager* ping_manager() const;
161 163
162 // This may be NULL if v4 is not enabled by experiment. 164 // This may be NULL if v4 is not enabled by experiment.
163 const scoped_refptr<SafeBrowsingDatabaseManager>& v4_local_database_manager() 165 const scoped_refptr<SafeBrowsingDatabaseManager>& v4_local_database_manager()
164 const; 166 const;
165 167
166 PasswordProtectionService* password_protection_service(); 168 // Gets PasswordProtectionService by profile.
169 PasswordProtectionService* GetPasswordProtectionService(
170 Profile* profile) const;
167 171
168 // Returns a preference validation delegate that adds incidents to the 172 // Returns a preference validation delegate that adds incidents to the
169 // incident reporting service for validation failures. Returns NULL if the 173 // incident reporting service for validation failures. Returns NULL if the
170 // service is not applicable for the given profile. 174 // service is not applicable for the given profile.
171 std::unique_ptr<prefs::mojom::TrackedPreferenceValidationDelegate> 175 std::unique_ptr<prefs::mojom::TrackedPreferenceValidationDelegate>
172 CreatePreferenceValidationDelegate(Profile* profile) const; 176 CreatePreferenceValidationDelegate(Profile* profile) const;
173 177
174 // Registers |callback| to be run after some delay following process launch. 178 // Registers |callback| to be run after some delay following process launch.
175 // |callback| will be dropped if the service is not applicable for the 179 // |callback| will be dropped if the service is not applicable for the
176 // process. 180 // process.
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 271
268 // Checks if any profile is currently using the safe browsing service, and 272 // Checks if any profile is currently using the safe browsing service, and
269 // starts or stops the service accordingly. 273 // starts or stops the service accordingly.
270 void RefreshState(); 274 void RefreshState();
271 275
272 void OnSendSerializedDownloadReport(const std::string& report); 276 void OnSendSerializedDownloadReport(const std::string& report);
273 277
274 // Process the observed resource requests on the UI thread. 278 // Process the observed resource requests on the UI thread.
275 void ProcessResourceRequest(const ResourceRequestInfo& request); 279 void ProcessResourceRequest(const ResourceRequestInfo& request);
276 280
281 void CreatePasswordProtectionService(Profile* profile);
282
283 void RemovePasswordProtectionService(Profile* profile);
284
285 void OnProfileDestroyed(Profile* profile);
Nathan Parker 2017/04/05 18:05:22 Comment for this one? Isn't not obvious what ti d
Jialiu Lin 2017/04/05 18:48:25 Oops, I forgot to remove this function. It is not
286
277 // The factory used to instantiate a SafeBrowsingService object. 287 // The factory used to instantiate a SafeBrowsingService object.
278 // Useful for tests, so they can provide their own implementation of 288 // Useful for tests, so they can provide their own implementation of
279 // SafeBrowsingService. 289 // SafeBrowsingService.
280 static SafeBrowsingServiceFactory* factory_; 290 static SafeBrowsingServiceFactory* factory_;
281 291
282 // The SafeBrowsingURLRequestContextGetter used to access 292 // The SafeBrowsingURLRequestContextGetter used to access
283 // |url_request_context_|. Accessed on UI thread. 293 // |url_request_context_|. Accessed on UI thread.
284 scoped_refptr<SafeBrowsingURLRequestContextGetter> 294 scoped_refptr<SafeBrowsingURLRequestContextGetter>
285 url_request_context_getter_; 295 url_request_context_getter_;
286 296
(...skipping 26 matching lines...) Expand all
313 // |use_v4_only_| is true. 323 // |use_v4_only_| is true.
314 bool v4_enabled_; 324 bool v4_enabled_;
315 325
316 // Tracks existing PrefServices, and the safe browsing preference on each. 326 // Tracks existing PrefServices, and the safe browsing preference on each.
317 // This is used to determine if any profile is currently using the safe 327 // This is used to determine if any profile is currently using the safe
318 // browsing service, and to start it up or shut it down accordingly. 328 // browsing service, and to start it up or shut it down accordingly.
319 // Accessed on UI thread. 329 // Accessed on UI thread.
320 std::map<PrefService*, std::unique_ptr<PrefChangeRegistrar>> prefs_map_; 330 std::map<PrefService*, std::unique_ptr<PrefChangeRegistrar>> prefs_map_;
321 331
322 // Used to track creation and destruction of profiles on the UI thread. 332 // Used to track creation and destruction of profiles on the UI thread.
323 content::NotificationRegistrar prefs_registrar_; 333 content::NotificationRegistrar profiles_registrar_;
324 334
325 // Callbacks when SafeBrowsing state might have changed. 335 // Callbacks when SafeBrowsing state might have changed.
326 // Should only be accessed on the UI thread. 336 // Should only be accessed on the UI thread.
327 base::CallbackList<void(void)> state_callback_list_; 337 base::CallbackList<void(void)> state_callback_list_;
328 338
329 // Callbacks when SafeBrowsing service starts shutting down. 339 // Callbacks when SafeBrowsing service starts shutting down.
330 // Should only be accessed on the UI thread. 340 // Should only be accessed on the UI thread.
331 base::CallbackList<void(void)> shutdown_callback_list_; 341 base::CallbackList<void(void)> shutdown_callback_list_;
332 342
333 // The UI manager handles showing interstitials. Accessed on both UI and IO 343 // The UI manager handles showing interstitials. Accessed on both UI and IO
334 // thread. 344 // thread.
335 scoped_refptr<SafeBrowsingUIManager> ui_manager_; 345 scoped_refptr<SafeBrowsingUIManager> ui_manager_;
336 346
337 // The database manager handles the database and download logic. Accessed on 347 // The database manager handles the database and download logic. Accessed on
338 // both UI and IO thread. 348 // both UI and IO thread.
339 scoped_refptr<SafeBrowsingDatabaseManager> database_manager_; 349 scoped_refptr<SafeBrowsingDatabaseManager> database_manager_;
340 350
341 // The navigation observer manager handles attribution of safe browsing 351 // The navigation observer manager handles attribution of safe browsing
342 // events. 352 // events.
343 scoped_refptr<SafeBrowsingNavigationObserverManager> 353 scoped_refptr<SafeBrowsingNavigationObserverManager>
344 navigation_observer_manager_; 354 navigation_observer_manager_;
345 355
346 // The password protection service detects and handles password related 356 // Tracks existing Profiles, and their corresponding
347 // incidents. 357 // ChromePasswordProtectionService instances.
348 std::unique_ptr<PasswordProtectionService> password_protection_service_; 358 // Accessed on UI thread.
359 std::map<Profile*, std::unique_ptr<ChromePasswordProtectionService>>
360 password_protection_service_map_;
361
362 std::map<Profile*,
363 std::unique_ptr<KeyedServiceShutdownNotifier::Subscription>>
364 profile_shutdown_notifiers_;
Nathan Parker 2017/04/05 18:05:22 Is this used? I didn't see it.
Jialiu Lin 2017/04/05 18:48:25 You're right. this is not needed.
349 365
350 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingService); 366 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingService);
351 }; 367 };
352 368
353 // Factory for creating SafeBrowsingService. Useful for tests. 369 // Factory for creating SafeBrowsingService. Useful for tests.
354 class SafeBrowsingServiceFactory { 370 class SafeBrowsingServiceFactory {
355 public: 371 public:
356 SafeBrowsingServiceFactory() { } 372 SafeBrowsingServiceFactory() { }
357 virtual ~SafeBrowsingServiceFactory() { } 373 virtual ~SafeBrowsingServiceFactory() { }
358 virtual SafeBrowsingService* CreateSafeBrowsingService() = 0; 374 virtual SafeBrowsingService* CreateSafeBrowsingService() = 0;
359 private: 375 private:
360 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingServiceFactory); 376 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingServiceFactory);
361 }; 377 };
362 378
363 } // namespace safe_browsing 379 } // namespace safe_browsing
364 380
365 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_SERVICE_H_ 381 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698