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

Side by Side Diff: chrome/renderer/chrome_content_renderer_client.cc

Issue 8142032: Add error description to the DidFailProvisionalLoad callback. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: rebase Created 9 years, 2 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
« no previous file with comments | « chrome/renderer/chrome_content_renderer_client.h ('k') | chrome/renderer/localized_error.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/chrome_content_renderer_client.h" 5 #include "chrome/renderer/chrome_content_renderer_client.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/logging.h" 10 #include "base/logging.h"
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 // Use an internal error page, if we have one for the status code. 526 // Use an internal error page, if we have one for the status code.
527 if (!LocalizedError::HasStrings(LocalizedError::kHttpErrorDomain, 527 if (!LocalizedError::HasStrings(LocalizedError::kHttpErrorDomain,
528 http_status_code)) { 528 http_status_code)) {
529 return false; 529 return false;
530 } 530 }
531 531
532 *error_domain = LocalizedError::kHttpErrorDomain; 532 *error_domain = LocalizedError::kHttpErrorDomain;
533 return true; 533 return true;
534 } 534 }
535 535
536 std::string ChromeContentRendererClient::GetNavigationErrorHtml( 536 void ChromeContentRendererClient::GetNavigationErrorStrings(
537 const WebURLRequest& failed_request, 537 const WebKit::WebURLRequest& failed_request,
538 const WebURLError& error) { 538 const WebKit::WebURLError& error,
539 GURL failed_url = error.unreachableURL; 539 std::string* error_html,
540 std::string html; 540 string16* error_description) {
541 const GURL failed_url = error.unreachableURL;
541 const Extension* extension = NULL; 542 const Extension* extension = NULL;
543 const bool is_repost =
544 error.reason == net::ERR_CACHE_MISS &&
545 error.domain == WebString::fromUTF8(net::kErrorDomain) &&
546 EqualsASCII(failed_request.httpMethod(), "POST");
542 547
543 // Use a local error page.
544 int resource_id;
545 DictionaryValue error_strings;
546 if (failed_url.is_valid() && !failed_url.SchemeIs(chrome::kExtensionScheme)) 548 if (failed_url.is_valid() && !failed_url.SchemeIs(chrome::kExtensionScheme))
547 extension = extension_dispatcher_->extensions()->GetByURL(failed_url); 549 extension = extension_dispatcher_->extensions()->GetByURL(failed_url);
548 if (extension) {
549 LocalizedError::GetAppErrorStrings(error, failed_url, extension,
550 &error_strings);
551 550
552 // TODO(erikkay): Should we use a different template for different 551 if (error_html) {
553 // error messages? 552 // Use a local error page.
554 resource_id = IDR_ERROR_APP_HTML; 553 int resource_id;
555 } else { 554 DictionaryValue error_strings;
556 if (error.domain == WebString::fromUTF8(net::kErrorDomain) && 555 if (extension) {
557 error.reason == net::ERR_CACHE_MISS && 556 LocalizedError::GetAppErrorStrings(error, failed_url, extension,
558 EqualsASCII(failed_request.httpMethod(), "POST")) { 557 &error_strings);
559 LocalizedError::GetFormRepostStrings(failed_url, &error_strings); 558
559 // TODO(erikkay): Should we use a different template for different
560 // error messages?
561 resource_id = IDR_ERROR_APP_HTML;
560 } else { 562 } else {
561 LocalizedError::GetStrings(error, &error_strings); 563 if (is_repost) {
564 LocalizedError::GetFormRepostStrings(failed_url, &error_strings);
565 } else {
566 LocalizedError::GetStrings(error, &error_strings);
567 }
568 resource_id = IDR_NET_ERROR_HTML;
562 } 569 }
563 resource_id = IDR_NET_ERROR_HTML; 570
571 const base::StringPiece template_html(
572 ResourceBundle::GetSharedInstance().GetRawDataResource(resource_id));
573 if (template_html.empty()) {
574 NOTREACHED() << "unable to load template. ID: " << resource_id;
575 } else {
576 // "t" is the id of the templates root node.
577 *error_html = jstemplate_builder::GetTemplatesHtml(
578 template_html, &error_strings, "t");
579 }
564 } 580 }
565 581
566 const base::StringPiece template_html( 582 if (error_description) {
567 ResourceBundle::GetSharedInstance().GetRawDataResource(resource_id)); 583 if (!extension && !is_repost)
568 if (template_html.empty()) { 584 *error_description = LocalizedError::GetErrorDetails(error);
569 NOTREACHED() << "unable to load template. ID: " << resource_id;
570 } else {
571 // "t" is the id of the templates root node.
572 html = jstemplate_builder::GetTemplatesHtml(
573 template_html, &error_strings, "t");
574 } 585 }
575
576 return html;
577 } 586 }
578 587
579 bool ChromeContentRendererClient::RunIdleHandlerWhenWidgetsHidden() { 588 bool ChromeContentRendererClient::RunIdleHandlerWhenWidgetsHidden() {
580 return !extension_dispatcher_->is_extension_process(); 589 return !extension_dispatcher_->is_extension_process();
581 } 590 }
582 591
583 bool ChromeContentRendererClient::AllowPopup(const GURL& creator) { 592 bool ChromeContentRendererClient::AllowPopup(const GURL& creator) {
584 // Extensions and apps always allowed to create unrequested popups. The second 593 // Extensions and apps always allowed to create unrequested popups. The second
585 // check is necessary to include content scripts. 594 // check is necessary to include content scripts.
586 return extension_dispatcher_->extensions()->GetByURL(creator) || 595 return extension_dispatcher_->extensions()->GetByURL(creator) ||
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
773 if (spellcheck_.get()) 782 if (spellcheck_.get())
774 thread->RemoveObserver(spellcheck_.get()); 783 thread->RemoveObserver(spellcheck_.get());
775 SpellCheck* new_spellcheck = new SpellCheck(); 784 SpellCheck* new_spellcheck = new SpellCheck();
776 if (spellcheck_provider_) 785 if (spellcheck_provider_)
777 spellcheck_provider_->SetSpellCheck(new_spellcheck); 786 spellcheck_provider_->SetSpellCheck(new_spellcheck);
778 spellcheck_.reset(new_spellcheck); 787 spellcheck_.reset(new_spellcheck);
779 thread->AddObserver(new_spellcheck); 788 thread->AddObserver(new_spellcheck);
780 } 789 }
781 790
782 } // namespace chrome 791 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/renderer/chrome_content_renderer_client.h ('k') | chrome/renderer/localized_error.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698