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