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

Side by Side Diff: chrome/browser/ui/alternate_error_tab_observer.cc

Issue 137623011: Switch to using the new Link Doctor API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Really fix ChromeOS Created 6 years, 10 months 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "base/prefs/pref_service.h" 7 #include "base/prefs/pref_service.h"
8 #include "chrome/browser/chrome_notification_types.h" 8 #include "chrome/browser/chrome_notification_types.h"
9 #include "chrome/browser/google/google_util.h" 9 #include "chrome/browser/google/google_util.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
11 #include "chrome/common/pref_names.h" 11 #include "chrome/common/pref_names.h"
12 #include "chrome/common/render_messages.h" 12 #include "chrome/common/render_messages.h"
13 #include "components/user_prefs/pref_registry_syncable.h" 13 #include "components/user_prefs/pref_registry_syncable.h"
14 #include "content/public/browser/notification_service.h" 14 #include "content/public/browser/notification_service.h"
15 #include "content/public/browser/render_frame_host.h" 15 #include "content/public/browser/render_frame_host.h"
16 #include "content/public/browser/render_view_host.h" 16 #include "content/public/browser/render_view_host.h"
17 #include "content/public/browser/web_contents.h" 17 #include "content/public/browser/web_contents.h"
18 #include "google_apis/google_api_keys.h"
18 19
19 using content::RenderFrameHost; 20 using content::RenderFrameHost;
20 using content::RenderViewHost; 21 using content::RenderViewHost;
21 using content::WebContents; 22 using content::WebContents;
22 23
23 DEFINE_WEB_CONTENTS_USER_DATA_KEY(AlternateErrorPageTabObserver); 24 DEFINE_WEB_CONTENTS_USER_DATA_KEY(AlternateErrorPageTabObserver);
24 25
25 AlternateErrorPageTabObserver::AlternateErrorPageTabObserver( 26 AlternateErrorPageTabObserver::AlternateErrorPageTabObserver(
26 WebContents* web_contents) 27 WebContents* web_contents)
27 : content::WebContentsObserver(web_contents), 28 : content::WebContentsObserver(web_contents),
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 73
73 //////////////////////////////////////////////////////////////////////////////// 74 ////////////////////////////////////////////////////////////////////////////////
74 // Internal helpers 75 // Internal helpers
75 76
76 GURL AlternateErrorPageTabObserver::GetAlternateErrorPageURL() const { 77 GURL AlternateErrorPageTabObserver::GetAlternateErrorPageURL() const {
77 GURL url; 78 GURL url;
78 // Disable alternate error pages when in Incognito mode. 79 // Disable alternate error pages when in Incognito mode.
79 if (profile_->IsOffTheRecord()) 80 if (profile_->IsOffTheRecord())
80 return url; 81 return url;
81 82
82 if (profile_->GetPrefs()->GetBoolean(prefs::kAlternateErrorPagesEnabled)) { 83 // Don't use alternate error pages when disabled.
83 url = google_util::LinkDoctorBaseURL(); 84 if (!profile_->GetPrefs()->GetBoolean(prefs::kAlternateErrorPagesEnabled))
84 if (!url.is_valid()) 85 return url;
85 return url; 86
86 url = google_util::AppendGoogleLocaleParam(url); 87 url = google_util::LinkDoctorBaseURL();
87 url = google_util::AppendGoogleTLDParam(profile_, url);
88 }
89 return url; 88 return url;
90 } 89 }
91 90
92 void AlternateErrorPageTabObserver::OnAlternateErrorPagesEnabledChanged() { 91 void AlternateErrorPageTabObserver::OnAlternateErrorPagesEnabledChanged() {
93 UpdateAlternateErrorPageURL(web_contents()->GetRenderViewHost()); 92 UpdateAlternateErrorPageURL(web_contents()->GetRenderViewHost());
94 } 93 }
95 94
96 void AlternateErrorPageTabObserver::UpdateAlternateErrorPageURL( 95 void AlternateErrorPageTabObserver::UpdateAlternateErrorPageURL(
97 RenderViewHost* rvh) { 96 RenderViewHost* rvh) {
98 RenderFrameHost* rfh = rvh->GetMainFrame(); 97 RenderFrameHost* rfh = rvh->GetMainFrame();
99 rfh->Send(new ChromeViewMsg_SetAltErrorPageURL( 98 rfh->Send(new ChromeViewMsg_SetLinkDoctorInfo(
100 rfh->GetRoutingID(), GetAlternateErrorPageURL())); 99 rfh->GetRoutingID(),
100 GetAlternateErrorPageURL(),
101 google_util::GetGoogleLocale(),
102 google_util::GetGoogleCountryCodeCode(profile_),
103 google_apis::GetAPIKey(),
104 google_util::GetGoogleSearchURL(profile_)));
101 } 105 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698