OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/renderer/net/net_error_helper.h" | 5 #include "chrome/renderer/net/net_error_helper.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 void NetErrorHelper::TrackClick(int tracking_id) { | 160 void NetErrorHelper::TrackClick(int tracking_id) { |
161 core_->TrackClick(tracking_id); | 161 core_->TrackClick(tracking_id); |
162 } | 162 } |
163 | 163 |
164 void NetErrorHelper::GenerateLocalizedErrorPage( | 164 void NetErrorHelper::GenerateLocalizedErrorPage( |
165 const blink::WebURLError& error, | 165 const blink::WebURLError& error, |
166 bool is_failed_post, | 166 bool is_failed_post, |
167 scoped_ptr<ErrorPageParams> params, | 167 scoped_ptr<ErrorPageParams> params, |
168 bool* reload_button_shown, | 168 bool* reload_button_shown, |
169 bool* show_saved_copy_button_shown, | 169 bool* show_saved_copy_button_shown, |
| 170 bool* show_cached_copy_button_shown, |
| 171 bool* show_cached_page_button_shown, |
170 std::string* error_html) const { | 172 std::string* error_html) const { |
171 error_html->clear(); | 173 error_html->clear(); |
172 | 174 |
173 int resource_id = IDR_NET_ERROR_HTML; | 175 int resource_id = IDR_NET_ERROR_HTML; |
174 const base::StringPiece template_html( | 176 const base::StringPiece template_html( |
175 ResourceBundle::GetSharedInstance().GetRawDataResource(resource_id)); | 177 ResourceBundle::GetSharedInstance().GetRawDataResource(resource_id)); |
176 if (template_html.empty()) { | 178 if (template_html.empty()) { |
177 NOTREACHED() << "unable to load template."; | 179 NOTREACHED() << "unable to load template."; |
178 } else { | 180 } else { |
179 base::DictionaryValue error_strings; | 181 base::DictionaryValue error_strings; |
180 LocalizedError::GetStrings(error.reason, error.domain.utf8(), | 182 LocalizedError::GetStrings(error.reason, error.domain.utf8(), |
181 error.unreachableURL, is_failed_post, | 183 error.unreachableURL, is_failed_post, |
182 error.staleCopyInCache, | 184 error.staleCopyInCache, |
183 RenderThread::Get()->GetLocale(), | 185 RenderThread::Get()->GetLocale(), |
184 render_frame()->GetRenderView()-> | 186 render_frame()->GetRenderView()-> |
185 GetAcceptLanguages(), | 187 GetAcceptLanguages(), |
186 params.Pass(), &error_strings); | 188 params.Pass(), &error_strings); |
187 *reload_button_shown = error_strings.Get("reloadButton", NULL); | 189 *reload_button_shown = error_strings.Get("reloadButton", NULL); |
188 *show_saved_copy_button_shown = | 190 *show_saved_copy_button_shown = |
189 error_strings.Get("showSavedCopyButton", NULL); | 191 error_strings.Get("showSavedCopyButton", NULL); |
190 | 192 |
| 193 bool show_cache_copy_button_default_label; |
| 194 bool showing_cache_copy_experiment = |
| 195 error_strings.GetBoolean("cacheButton.defaultLabel", |
| 196 &show_cache_copy_button_default_label); |
| 197 if (showing_cache_copy_experiment) { |
| 198 if (show_cache_copy_button_default_label) { |
| 199 *show_cached_copy_button_shown = false; |
| 200 *show_cached_page_button_shown = true; |
| 201 } else { |
| 202 *show_cached_page_button_shown = false; |
| 203 *show_cached_copy_button_shown = true; |
| 204 } |
| 205 } |
191 // "t" is the id of the template's root node. | 206 // "t" is the id of the template's root node. |
192 *error_html = webui::GetTemplatesHtml(template_html, &error_strings, "t"); | 207 *error_html = webui::GetTemplatesHtml(template_html, &error_strings, "t"); |
193 } | 208 } |
194 } | 209 } |
195 | 210 |
196 void NetErrorHelper::LoadErrorPageInMainFrame(const std::string& html, | 211 void NetErrorHelper::LoadErrorPageInMainFrame(const std::string& html, |
197 const GURL& failed_url) { | 212 const GURL& failed_url) { |
198 blink::WebView* web_view = render_frame()->GetRenderView()->GetWebView(); | 213 blink::WebView* web_view = render_frame()->GetRenderView()->GetWebView(); |
199 if (!web_view) | 214 if (!web_view) |
200 return; | 215 return; |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 success ? data : "", | 349 success ? data : "", |
335 render_frame()->GetRenderView()->GetAcceptLanguages(), | 350 render_frame()->GetRenderView()->GetAcceptLanguages(), |
336 base::i18n::IsRTL()); | 351 base::i18n::IsRTL()); |
337 } | 352 } |
338 | 353 |
339 void NetErrorHelper::OnTrackingRequestComplete( | 354 void NetErrorHelper::OnTrackingRequestComplete( |
340 const blink::WebURLResponse& response, | 355 const blink::WebURLResponse& response, |
341 const std::string& data) { | 356 const std::string& data) { |
342 tracking_fetcher_.reset(); | 357 tracking_fetcher_.reset(); |
343 } | 358 } |
OLD | NEW |