| OLD | NEW |
| 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 #ifndef CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_TAB_OBSERVER_H_ | 5 #ifndef CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_TAB_OBSERVER_H_ |
| 6 #define CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_TAB_OBSERVER_H_ | 6 #define CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_TAB_OBSERVER_H_ |
| 7 | 7 |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/prefs/public/pref_change_registrar.h" | 9 #include "base/prefs/public/pref_change_registrar.h" |
| 10 #include "content/public/browser/notification_observer.h" | 10 #include "base/prefs/public/pref_observer.h" |
| 11 #include "content/public/browser/web_contents_user_data.h" | 11 #include "content/public/browser/web_contents_user_data.h" |
| 12 | 12 |
| 13 namespace content { | 13 namespace content { |
| 14 class WebContents; | 14 class WebContents; |
| 15 } | 15 } |
| 16 | 16 |
| 17 namespace safe_browsing { | 17 namespace safe_browsing { |
| 18 | 18 |
| 19 class ClientSideDetectionHost; | 19 class ClientSideDetectionHost; |
| 20 | 20 |
| 21 // Per-tab class to handle safe-browsing functionality. | 21 // Per-tab class to handle safe-browsing functionality. |
| 22 class SafeBrowsingTabObserver | 22 class SafeBrowsingTabObserver |
| 23 : public content::NotificationObserver, | 23 : public PrefObserver, |
| 24 public content::WebContentsUserData<SafeBrowsingTabObserver> { | 24 public content::WebContentsUserData<SafeBrowsingTabObserver> { |
| 25 public: | 25 public: |
| 26 virtual ~SafeBrowsingTabObserver(); | 26 virtual ~SafeBrowsingTabObserver(); |
| 27 | 27 |
| 28 private: | 28 private: |
| 29 explicit SafeBrowsingTabObserver(content::WebContents* web_contents); | 29 explicit SafeBrowsingTabObserver(content::WebContents* web_contents); |
| 30 friend class content::WebContentsUserData<SafeBrowsingTabObserver>; | 30 friend class content::WebContentsUserData<SafeBrowsingTabObserver>; |
| 31 | 31 |
| 32 // content::NotificationObserver overrides: | 32 // PrefObserver overrides: |
| 33 virtual void Observe(int type, | 33 virtual void OnPreferenceChanged(PrefServiceBase* service, |
| 34 const content::NotificationSource& source, | 34 const std::string& pref_name) OVERRIDE; |
| 35 const content::NotificationDetails& details) OVERRIDE; | |
| 36 | 35 |
| 37 // Internal helpers ---------------------------------------------------------- | 36 // Internal helpers ---------------------------------------------------------- |
| 38 | 37 |
| 39 // Create or destroy SafebrowsingDetectionHost as needed if the user's | 38 // Create or destroy SafebrowsingDetectionHost as needed if the user's |
| 40 // safe browsing preference has changed. | 39 // safe browsing preference has changed. |
| 41 void UpdateSafebrowsingDetectionHost(); | 40 void UpdateSafebrowsingDetectionHost(); |
| 42 | 41 |
| 43 // Handles IPCs. | 42 // Handles IPCs. |
| 44 scoped_ptr<ClientSideDetectionHost> safebrowsing_detection_host_; | 43 scoped_ptr<ClientSideDetectionHost> safebrowsing_detection_host_; |
| 45 | 44 |
| 46 // Our owning WebContents. | 45 // Our owning WebContents. |
| 47 content::WebContents* web_contents_; | 46 content::WebContents* web_contents_; |
| 48 | 47 |
| 49 PrefChangeRegistrar pref_change_registrar_; | 48 PrefChangeRegistrar pref_change_registrar_; |
| 50 | 49 |
| 51 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingTabObserver); | 50 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingTabObserver); |
| 52 }; | 51 }; |
| 53 | 52 |
| 54 } // namespace safe_browsing | 53 } // namespace safe_browsing |
| 55 | 54 |
| 56 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_TAB_OBSERVER_H_ | 55 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_TAB_OBSERVER_H_ |
| OLD | NEW |