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