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