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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_TAB_OBSERVER_H_
6 #define CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_TAB_OBSERVER_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "base/prefs/pref_change_registrar.h"
10 #include "content/public/browser/web_contents_user_data.h"
16 namespace safe_browsing
{
18 class ClientSideDetectionHost
;
20 // Per-tab class to handle safe-browsing functionality.
21 class SafeBrowsingTabObserver
22 : public content::WebContentsUserData
<SafeBrowsingTabObserver
> {
24 virtual ~SafeBrowsingTabObserver();
26 ClientSideDetectionHost
* detection_host() {
27 return safebrowsing_detection_host_
.get();
30 const ClientSideDetectionHost
* detection_host() const {
31 return safebrowsing_detection_host_
.get();
35 explicit SafeBrowsingTabObserver(content::WebContents
* web_contents
);
36 friend class content::WebContentsUserData
<SafeBrowsingTabObserver
>;
38 // Internal helpers ----------------------------------------------------------
40 // Create or destroy SafebrowsingDetectionHost as needed if the user's
41 // safe browsing preference has changed.
42 void UpdateSafebrowsingDetectionHost();
45 scoped_ptr
<ClientSideDetectionHost
> safebrowsing_detection_host_
;
47 // Our owning WebContents.
48 content::WebContents
* web_contents_
;
50 PrefChangeRegistrar pref_change_registrar_
;
52 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingTabObserver
);
55 } // namespace safe_browsing
57 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_TAB_OBSERVER_H_