| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "chrome/browser/prefs/pref_change_registrar.h" | 9 #include "chrome/browser/prefs/pref_change_registrar.h" |
| 10 #include "content/public/browser/notification_observer.h" | 10 #include "content/public/browser/notification_observer.h" |
| 11 #include "content/public/browser/notification_registrar.h" | 11 #include "content/public/browser/notification_registrar.h" |
| 12 #include "content/public/browser/web_contents_observer.h" | 12 #include "content/public/browser/web_contents_observer.h" |
| 13 | 13 |
| 14 class Profile; | 14 class Profile; |
| 15 | 15 |
| 16 // Per-tab class to implement alternate error page functionality. | 16 // Per-tab class to implement alternate error page functionality. |
| 17 class AlternateErrorPageTabObserver : public content::WebContentsObserver, | 17 class AlternateErrorPageTabObserver : public content::WebContentsObserver, |
| 18 public content::NotificationObserver { | 18 public content::NotificationObserver { |
| 19 public: | 19 public: |
| 20 explicit AlternateErrorPageTabObserver(content::WebContents* web_contents); | 20 explicit AlternateErrorPageTabObserver(content::WebContents* web_contents); |
| 21 virtual ~AlternateErrorPageTabObserver(); | 21 virtual ~AlternateErrorPageTabObserver(); |
| 22 | 22 |
| 23 static void RegisterUserPrefs(PrefService* prefs); | 23 static void RegisterUserPrefs(PrefService* prefs); |
| 24 | 24 |
| 25 private: | 25 private: |
| 26 // Helper to return the profile for this tab. | 26 // Helper to return the profile for this tab. |
| 27 Profile* GetProfile() const; | 27 Profile* GetProfile() const; |
| 28 | 28 |
| 29 // content::WebContentsObserver overrides: | 29 // content::WebContentsObserver overrides: |
| 30 virtual void RenderViewCreated(RenderViewHost* render_view_host) OVERRIDE; | 30 virtual void RenderViewCreated( |
| 31 content::RenderViewHost* render_view_host) OVERRIDE; |
| 31 | 32 |
| 32 // content::NotificationObserver overrides: | 33 // content::NotificationObserver overrides: |
| 33 virtual void Observe(int type, | 34 virtual void Observe(int type, |
| 34 const content::NotificationSource& source, | 35 const content::NotificationSource& source, |
| 35 const content::NotificationDetails& details) OVERRIDE; | 36 const content::NotificationDetails& details) OVERRIDE; |
| 36 | 37 |
| 37 // Internal helpers ---------------------------------------------------------- | 38 // Internal helpers ---------------------------------------------------------- |
| 38 | 39 |
| 39 // Returns the server that can provide alternate error pages. If the returned | 40 // Returns the server that can provide alternate error pages. If the returned |
| 40 // URL is empty, the default error page built into WebKit will be used. | 41 // URL is empty, the default error page built into WebKit will be used. |
| 41 GURL GetAlternateErrorPageURL() const; | 42 GURL GetAlternateErrorPageURL() const; |
| 42 | 43 |
| 43 // Send the alternate error page URL to the renderer. | 44 // Send the alternate error page URL to the renderer. |
| 44 void UpdateAlternateErrorPageURL(RenderViewHost* rvh); | 45 void UpdateAlternateErrorPageURL(content::RenderViewHost* rvh); |
| 45 | 46 |
| 46 content::NotificationRegistrar registrar_; | 47 content::NotificationRegistrar registrar_; |
| 47 PrefChangeRegistrar pref_change_registrar_; | 48 PrefChangeRegistrar pref_change_registrar_; |
| 48 | 49 |
| 49 DISALLOW_COPY_AND_ASSIGN(AlternateErrorPageTabObserver); | 50 DISALLOW_COPY_AND_ASSIGN(AlternateErrorPageTabObserver); |
| 50 }; | 51 }; |
| 51 | 52 |
| 52 #endif // CHROME_BROWSER_UI_ALTERNATE_ERROR_TAB_OBSERVER_H_ | 53 #endif // CHROME_BROWSER_UI_ALTERNATE_ERROR_TAB_OBSERVER_H_ |
| OLD | NEW |