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_UI_NAVIGATION_CORRECTION_TAB_OBSERVER_H_
6 #define CHROME_BROWSER_UI_NAVIGATION_CORRECTION_TAB_OBSERVER_H_
8 #include "base/prefs/pref_change_registrar.h"
9 #include "content/public/browser/notification_observer.h"
10 #include "content/public/browser/notification_registrar.h"
11 #include "content/public/browser/web_contents_observer.h"
12 #include "content/public/browser/web_contents_user_data.h"
16 namespace user_prefs
{
17 class PrefRegistrySyncable
;
20 // Per-tab class to implement navigation suggestion service functionality.
21 class NavigationCorrectionTabObserver
22 : public content::WebContentsObserver
,
23 public content::NotificationObserver
,
24 public content::WebContentsUserData
<NavigationCorrectionTabObserver
> {
26 virtual ~NavigationCorrectionTabObserver();
28 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable
* registry
);
31 explicit NavigationCorrectionTabObserver(content::WebContents
* web_contents
);
32 friend class content::WebContentsUserData
<NavigationCorrectionTabObserver
>;
34 // content::WebContentsObserver overrides:
35 virtual void RenderViewCreated(
36 content::RenderViewHost
* render_view_host
) OVERRIDE
;
38 // content::NotificationObserver overrides:
39 virtual void Observe(int type
,
40 const content::NotificationSource
& source
,
41 const content::NotificationDetails
& details
) OVERRIDE
;
43 // Internal helpers ----------------------------------------------------------
45 // Returns the URL for the correction service. If the returned URL
46 // is empty, the default error pages will be used.
47 GURL
GetNavigationCorrectionURL() const;
49 // Called when navigation corrections are enabled or disabled.
50 void OnEnabledChanged();
52 // Updates the renderer's navigation correction service configuration.
53 void UpdateNavigationCorrectionInfo(content::RenderViewHost
* rvh
);
56 content::NotificationRegistrar registrar_
;
57 PrefChangeRegistrar pref_change_registrar_
;
59 DISALLOW_COPY_AND_ASSIGN(NavigationCorrectionTabObserver
);
62 #endif // CHROME_BROWSER_UI_NAVIGATION_CORRECTION_TAB_OBSERVER_H_