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_UI_NAVIGATION_CORRECTION_TAB_OBSERVER_H_ | 5 #ifndef CHROME_BROWSER_UI_NAVIGATION_CORRECTION_TAB_OBSERVER_H_ |
6 #define CHROME_BROWSER_UI_NAVIGATION_CORRECTION_TAB_OBSERVER_H_ | 6 #define CHROME_BROWSER_UI_NAVIGATION_CORRECTION_TAB_OBSERVER_H_ |
7 | 7 |
8 #include "base/prefs/pref_change_registrar.h" | 8 #include "base/prefs/pref_change_registrar.h" |
9 #include "components/google/core/browser/google_url_tracker.h" | 9 #include "components/google/core/browser/google_url_tracker.h" |
10 #include "content/public/browser/web_contents_observer.h" | 10 #include "content/public/browser/web_contents_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 class Profile; | 13 class Profile; |
14 | 14 |
15 namespace user_prefs { | 15 namespace user_prefs { |
16 class PrefRegistrySyncable; | 16 class PrefRegistrySyncable; |
17 } | 17 } |
18 | 18 |
19 // Per-tab class to implement navigation suggestion service functionality. | 19 // Per-tab class to implement navigation suggestion service functionality. |
20 class NavigationCorrectionTabObserver | 20 class NavigationCorrectionTabObserver |
21 : public content::WebContentsObserver, | 21 : public content::WebContentsObserver, |
22 public content::WebContentsUserData<NavigationCorrectionTabObserver> { | 22 public content::WebContentsUserData<NavigationCorrectionTabObserver> { |
23 public: | 23 public: |
24 virtual ~NavigationCorrectionTabObserver(); | 24 ~NavigationCorrectionTabObserver() override; |
25 | 25 |
26 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); | 26 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); |
27 | 27 |
28 private: | 28 private: |
29 explicit NavigationCorrectionTabObserver(content::WebContents* web_contents); | 29 explicit NavigationCorrectionTabObserver(content::WebContents* web_contents); |
30 friend class content::WebContentsUserData<NavigationCorrectionTabObserver>; | 30 friend class content::WebContentsUserData<NavigationCorrectionTabObserver>; |
31 | 31 |
32 // content::WebContentsObserver overrides: | 32 // content::WebContentsObserver overrides: |
33 virtual void RenderViewCreated( | 33 void RenderViewCreated(content::RenderViewHost* render_view_host) override; |
34 content::RenderViewHost* render_view_host) override; | |
35 | 34 |
36 // Internal helpers ---------------------------------------------------------- | 35 // Internal helpers ---------------------------------------------------------- |
37 | 36 |
38 // Callback that is called when the Google URL is updated. | 37 // Callback that is called when the Google URL is updated. |
39 void OnGoogleURLUpdated(); | 38 void OnGoogleURLUpdated(); |
40 | 39 |
41 // Returns the URL for the correction service. If the returned URL | 40 // Returns the URL for the correction service. If the returned URL |
42 // is empty, the default error pages will be used. | 41 // is empty, the default error pages will be used. |
43 GURL GetNavigationCorrectionURL() const; | 42 GURL GetNavigationCorrectionURL() const; |
44 | 43 |
45 // Called when navigation corrections are enabled or disabled. | 44 // Called when navigation corrections are enabled or disabled. |
46 void OnEnabledChanged(); | 45 void OnEnabledChanged(); |
47 | 46 |
48 // Updates the renderer's navigation correction service configuration. | 47 // Updates the renderer's navigation correction service configuration. |
49 void UpdateNavigationCorrectionInfo(content::RenderViewHost* rvh); | 48 void UpdateNavigationCorrectionInfo(content::RenderViewHost* rvh); |
50 | 49 |
51 Profile* profile_; | 50 Profile* profile_; |
52 PrefChangeRegistrar pref_change_registrar_; | 51 PrefChangeRegistrar pref_change_registrar_; |
53 scoped_ptr<GoogleURLTracker::Subscription> google_url_updated_subscription_; | 52 scoped_ptr<GoogleURLTracker::Subscription> google_url_updated_subscription_; |
54 | 53 |
55 DISALLOW_COPY_AND_ASSIGN(NavigationCorrectionTabObserver); | 54 DISALLOW_COPY_AND_ASSIGN(NavigationCorrectionTabObserver); |
56 }; | 55 }; |
57 | 56 |
58 #endif // CHROME_BROWSER_UI_NAVIGATION_CORRECTION_TAB_OBSERVER_H_ | 57 #endif // CHROME_BROWSER_UI_NAVIGATION_CORRECTION_TAB_OBSERVER_H_ |
OLD | NEW |