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 AlternateErrorPageTabObserver(content::WebContents* web_contents, |
| 21 Profile* profile); |
21 virtual ~AlternateErrorPageTabObserver(); | 22 virtual ~AlternateErrorPageTabObserver(); |
22 | 23 |
23 static void RegisterUserPrefs(PrefService* prefs); | 24 static void RegisterUserPrefs(PrefService* prefs); |
24 | 25 |
25 private: | 26 private: |
26 // Helper to return the profile for this tab. | |
27 Profile* GetProfile() const; | |
28 | |
29 // content::WebContentsObserver overrides: | 27 // content::WebContentsObserver overrides: |
30 virtual void RenderViewCreated( | 28 virtual void RenderViewCreated( |
31 content::RenderViewHost* render_view_host) OVERRIDE; | 29 content::RenderViewHost* render_view_host) OVERRIDE; |
32 | 30 |
33 // content::NotificationObserver overrides: | 31 // content::NotificationObserver overrides: |
34 virtual void Observe(int type, | 32 virtual void Observe(int type, |
35 const content::NotificationSource& source, | 33 const content::NotificationSource& source, |
36 const content::NotificationDetails& details) OVERRIDE; | 34 const content::NotificationDetails& details) OVERRIDE; |
37 | 35 |
38 // Internal helpers ---------------------------------------------------------- | 36 // Internal helpers ---------------------------------------------------------- |
39 | 37 |
40 // 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 |
41 // 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. |
42 GURL GetAlternateErrorPageURL() const; | 40 GURL GetAlternateErrorPageURL() const; |
43 | 41 |
44 // Send the alternate error page URL to the renderer. | 42 // Send the alternate error page URL to the renderer. |
45 void UpdateAlternateErrorPageURL(content::RenderViewHost* rvh); | 43 void UpdateAlternateErrorPageURL(content::RenderViewHost* rvh); |
46 | 44 |
| 45 Profile* profile_; |
47 content::NotificationRegistrar registrar_; | 46 content::NotificationRegistrar registrar_; |
48 PrefChangeRegistrar pref_change_registrar_; | 47 PrefChangeRegistrar pref_change_registrar_; |
49 | 48 |
50 DISALLOW_COPY_AND_ASSIGN(AlternateErrorPageTabObserver); | 49 DISALLOW_COPY_AND_ASSIGN(AlternateErrorPageTabObserver); |
51 }; | 50 }; |
52 | 51 |
53 #endif // CHROME_BROWSER_UI_ALTERNATE_ERROR_TAB_OBSERVER_H_ | 52 #endif // CHROME_BROWSER_UI_ALTERNATE_ERROR_TAB_OBSERVER_H_ |
OLD | NEW |