Index: chrome/browser/ui/link_doctor_tab_observer.cc |
=================================================================== |
--- chrome/browser/ui/link_doctor_tab_observer.cc (revision 248295) |
+++ chrome/browser/ui/link_doctor_tab_observer.cc (working copy) |
@@ -2,7 +2,7 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#include "chrome/browser/ui/alternate_error_tab_observer.h" |
+#include "chrome/browser/ui/link_doctor_tab_observer.h" |
#include "base/prefs/pref_service.h" |
#include "chrome/browser/chrome_notification_types.h" |
@@ -15,15 +15,15 @@ |
#include "content/public/browser/render_frame_host.h" |
#include "content/public/browser/render_view_host.h" |
#include "content/public/browser/web_contents.h" |
+#include "google_apis/google_api_keys.h" |
using content::RenderFrameHost; |
using content::RenderViewHost; |
using content::WebContents; |
-DEFINE_WEB_CONTENTS_USER_DATA_KEY(AlternateErrorPageTabObserver); |
+DEFINE_WEB_CONTENTS_USER_DATA_KEY(LinkDoctorTabObserver); |
-AlternateErrorPageTabObserver::AlternateErrorPageTabObserver( |
- WebContents* web_contents) |
+LinkDoctorTabObserver::LinkDoctorTabObserver(WebContents* web_contents) |
: content::WebContentsObserver(web_contents), |
profile_(Profile::FromBrowserContext(web_contents->GetBrowserContext())) { |
PrefService* prefs = profile_->GetPrefs(); |
@@ -31,8 +31,7 @@ |
pref_change_registrar_.Init(prefs); |
pref_change_registrar_.Add( |
prefs::kAlternateErrorPagesEnabled, |
- base::Bind(&AlternateErrorPageTabObserver:: |
- OnAlternateErrorPagesEnabledChanged, |
+ base::Bind(&LinkDoctorTabObserver::OnLinkDoctorEnabledChanged, |
base::Unretained(this))); |
} |
@@ -40,11 +39,11 @@ |
content::Source<Profile>(profile_->GetOriginalProfile())); |
} |
-AlternateErrorPageTabObserver::~AlternateErrorPageTabObserver() { |
+LinkDoctorTabObserver::~LinkDoctorTabObserver() { |
} |
// static |
-void AlternateErrorPageTabObserver::RegisterProfilePrefs( |
+void LinkDoctorTabObserver::RegisterProfilePrefs( |
user_prefs::PrefRegistrySyncable* prefs) { |
prefs->RegisterBooleanPref(prefs::kAlternateErrorPagesEnabled, |
true, |
@@ -54,48 +53,51 @@ |
//////////////////////////////////////////////////////////////////////////////// |
// WebContentsObserver overrides |
-void AlternateErrorPageTabObserver::RenderViewCreated( |
+void LinkDoctorTabObserver::RenderViewCreated( |
RenderViewHost* render_view_host) { |
- UpdateAlternateErrorPageURL(render_view_host); |
+ UpdateLinkDoctorInfo(render_view_host); |
} |
//////////////////////////////////////////////////////////////////////////////// |
// content::NotificationObserver overrides |
-void AlternateErrorPageTabObserver::Observe( |
+void LinkDoctorTabObserver::Observe( |
int type, |
const content::NotificationSource& source, |
const content::NotificationDetails& details) { |
DCHECK_EQ(chrome::NOTIFICATION_GOOGLE_URL_UPDATED, type); |
- UpdateAlternateErrorPageURL(web_contents()->GetRenderViewHost()); |
+ UpdateLinkDoctorInfo(web_contents()->GetRenderViewHost()); |
} |
//////////////////////////////////////////////////////////////////////////////// |
// Internal helpers |
-GURL AlternateErrorPageTabObserver::GetAlternateErrorPageURL() const { |
+GURL LinkDoctorTabObserver::GetLinkDoctorURL() const { |
GURL url; |
Peter Kasting
2014/02/10 23:19:46
Nit: Remove this temp; return GURL() or google_uti
mmenke
2014/02/11 16:02:19
Done.
|
- // Disable alternate error pages when in Incognito mode. |
+ // Disable aLink Doctor suggestions when in Incognito mode. |
Peter Kasting
2014/02/10 23:19:46
Nit: aLink -> Link
mmenke
2014/02/11 16:02:19
Done.
|
if (profile_->IsOffTheRecord()) |
Peter Kasting
2014/02/10 23:19:46
Nit: I'd combine this statement (and its comment)
mmenke
2014/02/11 16:02:19
Done.
|
return url; |
- if (profile_->GetPrefs()->GetBoolean(prefs::kAlternateErrorPagesEnabled)) { |
- url = google_util::LinkDoctorBaseURL(); |
- if (!url.is_valid()) |
- return url; |
- url = google_util::AppendGoogleLocaleParam(url); |
- url = google_util::AppendGoogleTLDParam(profile_, url); |
- } |
+ // Don't use Link Doctor suggestions when disabled. |
+ if (!profile_->GetPrefs()->GetBoolean(prefs::kAlternateErrorPagesEnabled)) |
+ return url; |
+ |
+ url = google_util::LinkDoctorBaseURL(); |
return url; |
} |
-void AlternateErrorPageTabObserver::OnAlternateErrorPagesEnabledChanged() { |
- UpdateAlternateErrorPageURL(web_contents()->GetRenderViewHost()); |
+void LinkDoctorTabObserver::OnLinkDoctorEnabledChanged() { |
+ UpdateLinkDoctorInfo(web_contents()->GetRenderViewHost()); |
} |
-void AlternateErrorPageTabObserver::UpdateAlternateErrorPageURL( |
+void LinkDoctorTabObserver::UpdateLinkDoctorInfo( |
RenderViewHost* rvh) { |
RenderFrameHost* rfh = rvh->GetMainFrame(); |
- rfh->Send(new ChromeViewMsg_SetAltErrorPageURL( |
- rfh->GetRoutingID(), GetAlternateErrorPageURL())); |
+ rfh->Send(new ChromeViewMsg_SetLinkDoctorInfo( |
+ rfh->GetRoutingID(), |
Peter Kasting
2014/02/10 23:19:46
Nit: Indent 4, not 14
You may list more than one
mmenke
2014/02/11 16:02:19
Done.
|
+ GetLinkDoctorURL(), |
+ google_util::GetGoogleLocale(), |
+ google_util::GetGoogleCountryCode(profile_), |
+ google_apis::GetAPIKey(), |
+ google_util::GetGoogleSearchURL(profile_))); |
} |