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