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_ALTERNATE_ERROR_TAB_OBSERVER_H_ | 5 #ifndef CHROME_BROWSER_UI_ALTERNATE_ERROR_TAB_OBSERVER_H_ |
6 #define CHROME_BROWSER_UI_ALTERNATE_ERROR_TAB_OBSERVER_H_ | 6 #define CHROME_BROWSER_UI_ALTERNATE_ERROR_TAB_OBSERVER_H_ |
7 | 7 |
8 #include "base/prefs/public/pref_change_registrar.h" | 8 #include "base/prefs/public/pref_change_registrar.h" |
9 #include "base/prefs/public/pref_observer.h" | |
10 #include "chrome/browser/prefs/pref_service.h" | 9 #include "chrome/browser/prefs/pref_service.h" |
11 #include "content/public/browser/notification_observer.h" | 10 #include "content/public/browser/notification_observer.h" |
12 #include "content/public/browser/notification_registrar.h" | 11 #include "content/public/browser/notification_registrar.h" |
13 #include "content/public/browser/web_contents_observer.h" | 12 #include "content/public/browser/web_contents_observer.h" |
14 #include "content/public/browser/web_contents_user_data.h" | 13 #include "content/public/browser/web_contents_user_data.h" |
15 | 14 |
16 class Profile; | 15 class Profile; |
17 | 16 |
18 // Per-tab class to implement alternate error page functionality. | 17 // Per-tab class to implement alternate error page functionality. |
19 class AlternateErrorPageTabObserver | 18 class AlternateErrorPageTabObserver |
20 : public content::WebContentsObserver, | 19 : public content::WebContentsObserver, |
21 public content::NotificationObserver, | 20 public content::NotificationObserver, |
22 public content::WebContentsUserData<AlternateErrorPageTabObserver>, | 21 public content::WebContentsUserData<AlternateErrorPageTabObserver> { |
23 public PrefObserver { | |
24 public: | 22 public: |
25 virtual ~AlternateErrorPageTabObserver(); | 23 virtual ~AlternateErrorPageTabObserver(); |
26 | 24 |
27 static void RegisterUserPrefs(PrefService* prefs); | 25 static void RegisterUserPrefs(PrefService* prefs); |
28 | 26 |
29 private: | 27 private: |
30 explicit AlternateErrorPageTabObserver(content::WebContents* web_contents); | 28 explicit AlternateErrorPageTabObserver(content::WebContents* web_contents); |
31 friend class content::WebContentsUserData<AlternateErrorPageTabObserver>; | 29 friend class content::WebContentsUserData<AlternateErrorPageTabObserver>; |
32 | 30 |
33 // content::WebContentsObserver overrides: | 31 // content::WebContentsObserver overrides: |
34 virtual void RenderViewCreated( | 32 virtual void RenderViewCreated( |
35 content::RenderViewHost* render_view_host) OVERRIDE; | 33 content::RenderViewHost* render_view_host) OVERRIDE; |
36 | 34 |
37 // content::NotificationObserver overrides: | 35 // content::NotificationObserver overrides: |
38 virtual void Observe(int type, | 36 virtual void Observe(int type, |
39 const content::NotificationSource& source, | 37 const content::NotificationSource& source, |
40 const content::NotificationDetails& details) OVERRIDE; | 38 const content::NotificationDetails& details) OVERRIDE; |
41 | 39 |
42 // PrefObserver overrides: | |
43 virtual void OnPreferenceChanged(PrefServiceBase* service, | |
44 const std::string& pref_name) OVERRIDE; | |
45 | |
46 // Internal helpers ---------------------------------------------------------- | 40 // Internal helpers ---------------------------------------------------------- |
47 | 41 |
48 // Returns the server that can provide alternate error pages. If the returned | 42 // Returns the server that can provide alternate error pages. If the returned |
49 // URL is empty, the default error page built into WebKit will be used. | 43 // URL is empty, the default error page built into WebKit will be used. |
50 GURL GetAlternateErrorPageURL() const; | 44 GURL GetAlternateErrorPageURL() const; |
51 | 45 |
| 46 void OnAlternateErrorPagesEnabledChanged(); |
| 47 |
52 // Send the alternate error page URL to the renderer. | 48 // Send the alternate error page URL to the renderer. |
53 void UpdateAlternateErrorPageURL(content::RenderViewHost* rvh); | 49 void UpdateAlternateErrorPageURL(content::RenderViewHost* rvh); |
54 | 50 |
55 Profile* profile_; | 51 Profile* profile_; |
56 content::NotificationRegistrar registrar_; | 52 content::NotificationRegistrar registrar_; |
57 PrefChangeRegistrar pref_change_registrar_; | 53 PrefChangeRegistrar pref_change_registrar_; |
58 | 54 |
59 DISALLOW_COPY_AND_ASSIGN(AlternateErrorPageTabObserver); | 55 DISALLOW_COPY_AND_ASSIGN(AlternateErrorPageTabObserver); |
60 }; | 56 }; |
61 | 57 |
62 #endif // CHROME_BROWSER_UI_ALTERNATE_ERROR_TAB_OBSERVER_H_ | 58 #endif // CHROME_BROWSER_UI_ALTERNATE_ERROR_TAB_OBSERVER_H_ |
OLD | NEW |