| 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 #include "chrome/browser/ui/alternate_error_tab_observer.h" | 5 #include "chrome/browser/ui/alternate_error_tab_observer.h" |
| 6 | 6 |
| 7 #include "chrome/browser/google/google_util.h" | 7 #include "chrome/browser/google/google_util.h" |
| 8 #include "chrome/browser/prefs/pref_service.h" | 8 #include "chrome/browser/prefs/pref_service.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/common/chrome_notification_types.h" | 10 #include "chrome/common/chrome_notification_types.h" |
| 11 #include "chrome/common/pref_names.h" | 11 #include "chrome/common/pref_names.h" |
| 12 #include "content/public/browser/notification_service.h" | 12 #include "content/public/browser/notification_service.h" |
| 13 #include "content/public/browser/render_view_host.h" | 13 #include "content/public/browser/render_view_host.h" |
| 14 #include "content/public/browser/web_contents.h" | 14 #include "content/public/browser/web_contents.h" |
| 15 | 15 |
| 16 using content::RenderViewHost; | 16 using content::RenderViewHost; |
| 17 using content::WebContents; | 17 using content::WebContents; |
| 18 | 18 |
| 19 int AlternateErrorPageTabObserver::kUserDataKey; | 19 DEFINE_WEB_CONTENTS_USER_DATA_KEY(AlternateErrorPageTabObserver) |
| 20 | 20 |
| 21 AlternateErrorPageTabObserver::AlternateErrorPageTabObserver( | 21 AlternateErrorPageTabObserver::AlternateErrorPageTabObserver( |
| 22 WebContents* web_contents) | 22 WebContents* web_contents) |
| 23 : content::WebContentsObserver(web_contents), | 23 : content::WebContentsObserver(web_contents), |
| 24 profile_(Profile::FromBrowserContext(web_contents->GetBrowserContext())) { | 24 profile_(Profile::FromBrowserContext(web_contents->GetBrowserContext())) { |
| 25 PrefService* prefs = profile_->GetPrefs(); | 25 PrefService* prefs = profile_->GetPrefs(); |
| 26 if (prefs) { | 26 if (prefs) { |
| 27 pref_change_registrar_.Init(prefs); | 27 pref_change_registrar_.Init(prefs); |
| 28 pref_change_registrar_.Add(prefs::kAlternateErrorPagesEnabled, this); | 28 pref_change_registrar_.Add(prefs::kAlternateErrorPagesEnabled, this); |
| 29 } | 29 } |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 url = google_util::AppendGoogleLocaleParam(url); | 82 url = google_util::AppendGoogleLocaleParam(url); |
| 83 url = google_util::AppendGoogleTLDParam(profile_, url); | 83 url = google_util::AppendGoogleTLDParam(profile_, url); |
| 84 } | 84 } |
| 85 return url; | 85 return url; |
| 86 } | 86 } |
| 87 | 87 |
| 88 void AlternateErrorPageTabObserver::UpdateAlternateErrorPageURL( | 88 void AlternateErrorPageTabObserver::UpdateAlternateErrorPageURL( |
| 89 RenderViewHost* rvh) { | 89 RenderViewHost* rvh) { |
| 90 rvh->SetAltErrorPageURL(GetAlternateErrorPageURL()); | 90 rvh->SetAltErrorPageURL(GetAlternateErrorPageURL()); |
| 91 } | 91 } |
| OLD | NEW |