Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2990)

Unified Diff: chrome/browser/ui/alternate_error_tab_observer.cc

Issue 9030010: Move most of the remaining users of WebContentsObserver::tab_contents() to use web_contents(). (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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));
« no previous file with comments | « chrome/browser/ui/alternate_error_tab_observer.h ('k') | chrome/browser/ui/bookmarks/bookmark_tab_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698