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