Index: chrome/browser/ui/alternate_error_tab_observer.cc |
=================================================================== |
--- chrome/browser/ui/alternate_error_tab_observer.cc (revision 115777) |
+++ chrome/browser/ui/alternate_error_tab_observer.cc (working copy) |
@@ -7,18 +7,18 @@ |
#include "chrome/browser/google/google_util.h" |
#include "chrome/browser/prefs/pref_service.h" |
#include "chrome/browser/profiles/profile.h" |
-#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
#include "chrome/common/chrome_notification_types.h" |
#include "chrome/common/pref_names.h" |
#include "content/browser/renderer_host/render_view_host.h" |
-#include "content/browser/tab_contents/tab_contents.h" |
#include "content/public/browser/notification_service.h" |
+#include "content/public/browser/web_contents.h" |
+using content::WebContents; |
+ |
AlternateErrorPageTabObserver::AlternateErrorPageTabObserver( |
- TabContentsWrapper* wrapper) |
- : content::WebContentsObserver(wrapper->tab_contents()), |
- wrapper_(wrapper) { |
- PrefService* prefs = wrapper_->profile()->GetPrefs(); |
+ WebContents* web_contents) |
+ : content::WebContentsObserver(web_contents) { |
+ PrefService* prefs = GetProfile()->GetPrefs(); |
if (prefs) { |
pref_change_registrar_.Init(prefs); |
pref_change_registrar_.Add(prefs::kAlternateErrorPagesEnabled, this); |
@@ -38,6 +38,10 @@ |
PrefService::SYNCABLE_PREF); |
} |
+Profile* AlternateErrorPageTabObserver::GetProfile() const { |
+ return Profile::FromBrowserContext(web_contents()->GetBrowserContext()); |
+} |
+ |
//////////////////////////////////////////////////////////////////////////////// |
// WebContentsObserver overrides |
@@ -54,14 +58,14 @@ |
const content::NotificationDetails& details) { |
switch (type) { |
case chrome::NOTIFICATION_GOOGLE_URL_UPDATED: |
- UpdateAlternateErrorPageURL(tab_contents()->GetRenderViewHost()); |
+ UpdateAlternateErrorPageURL(web_contents()->GetRenderViewHost()); |
break; |
case chrome::NOTIFICATION_PREF_CHANGED: { |
std::string* pref_name = content::Details<std::string>(details).ptr(); |
DCHECK(content::Source<PrefService>(source).ptr() == |
- wrapper_->profile()->GetPrefs()); |
+ GetProfile()->GetPrefs()); |
if (*pref_name == prefs::kAlternateErrorPagesEnabled) { |
- UpdateAlternateErrorPageURL(tab_contents()->GetRenderViewHost()); |
+ UpdateAlternateErrorPageURL(web_contents()->GetRenderViewHost()); |
} else { |
NOTREACHED() << "unexpected pref change notification" << *pref_name; |
} |
@@ -78,10 +82,10 @@ |
GURL AlternateErrorPageTabObserver::GetAlternateErrorPageURL() const { |
GURL url; |
// Disable alternate error pages when in Incognito mode. |
- if (wrapper_->profile()->IsOffTheRecord()) |
+ if (GetProfile()->IsOffTheRecord()) |
return url; |
- PrefService* prefs = wrapper_->profile()->GetPrefs(); |
+ PrefService* prefs = GetProfile()->GetPrefs(); |
if (prefs->GetBoolean(prefs::kAlternateErrorPagesEnabled)) { |
url = google_util::AppendGoogleLocaleParam( |
GURL(google_util::kLinkDoctorBaseURL)); |