diff options
author | erikwright@chromium.org <erikwright@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-28 21:46:52 +0000 |
---|---|---|
committer | erikwright@chromium.org <erikwright@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-28 21:46:52 +0000 |
commit | f49aef886cb0e0fb93b7c533a1355a7fd1219c48 (patch) | |
tree | dd22feb36e99949b05c8406cedc666f259985a9b /chrome/common/localized_error.cc | |
parent | d6da23353b400477e6537b043323b6ed807ea4f8 (diff) | |
download | chromium_src-f49aef886cb0e0fb93b7c533a1355a7fd1219c48.zip chromium_src-f49aef886cb0e0fb93b7c533a1355a7fd1219c48.tar.gz chromium_src-f49aef886cb0e0fb93b7c533a1355a7fd1219c48.tar.bz2 |
Revert 254207 "Switch to using the new Link Doctor API."
This caused a memory leak. It appears |suggestions| was mismanaged?
http://build.chromium.org/p/chromium.memory/builders/Linux%20Chromium%20OS%20ASAN%20Tests%20%283%29/builds/13714/steps/unit_tests/logs/OfflinePageDontProceed
Direct leak of 40 byte(s) in 1 object(s) allocated from:
#0 0x4b1711 in operator new(unsigned long) /usr/local/google/work/chromium/src/third_party/llvm/projects/compiler-rt/lib/asan/asan_new_delete.cc:54
#1 0x61e7518 in LocalizedError::GetStrings(int, std::string const&, GURL const&, bool, bool, std::string const&, std::string const&, scoped_ptr\u003CLocalizedError::ErrorPageParams, base::DefaultDeleter\u003CLocalizedError::ErrorPageParams> >, base::DictionaryValue*) chrome/common/localized_error.cc:686
#2 0x111d82c0 in chromeos::OfflineLoadPage::GetHTMLContents() chrome/browser/chromeos/offline/offline_load_page.cc:98
#3 0xfb6f1fd in content::InterstitialPageImpl::Show() content/browser/frame_host/interstitial_page_impl.cc:248
#4 0x13fc43e in chromeos::OfflineLoadPageTest::ShowInterstitial(char const*) chrome/browser/chromeos/offline/offline_load_page_unittest.cc:71
#5 0x13fc870 in chromeos::OfflineLoadPageTest_OfflinePageDontProceed_Test::TestBody() chrome/browser/chromeos/offline/offline_load_page_unittest.cc:128
#6 0x800bf1a in HandleExceptionsInMethodIfSupported\u003Ctesting::Test, void> testing/gtest/src/gtest.cc:2045
#7 0x800bf1a in testing::Test::Run() testing/gtest/src/gtest.cc:2061
#8 0x800e349 in testing::TestInfo::Run() testing/gtest/src/gtest.cc:2237
#9 0x800f0c3 in testing::TestCase::Run() testing/gtest/src/gtest.cc:2344
#10 0x801fd1a in testing::internal::UnitTestImpl::RunAllTests() testing/gtest/src/gtest.cc:4065
#11 0x801f320 in HandleExceptionsInMethodIfSupported\u003Ctesting::internal::UnitTestImpl, bool> testing/gtest/src/gtest.cc:2045
#12 0x801f320 in testing::UnitTest::Run() testing/gtest/src/gtest.cc:3697
#13 0x129f3154 in RUN_ALL_TESTS testing/gtest/include/gtest/gtest.h:2231
#14 0x129f3154 in base::TestSuite::Run() base/test/test_suite.cc:213
#15 0x129ea3b7 in Run base/callback.h:401
#16 0x129ea3b7 in base::(anonymous namespace)::LaunchUnitTestsInternal(int, char**, base::Callback\u003Cint ()> const&, int) base/test/launcher/unit_test_launcher.cc:494
#17 0x820ee6d in main chrome/test/base/run_all_unittests.cc:13
#18 0x7f1d7d44d76c in __libc_start_main /build/buildd/eglibc-2.15/csu/libc-start.c:226
> Switch to using the new Link Doctor API.
>
> The new API allows Link Doctor results to be integrated into Chrome's
> own error pages.
>
> BUG=64832
> R=pkasting@chromium.org, thakis@chromium.org, tsepez@chromium.org, ttuttle@chromium.org
>
> Review URL: https://codereview.chromium.org/137623011
TBR=mmenke@chromium.org
Review URL: https://codereview.chromium.org/185003002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@254241 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/localized_error.cc')
-rw-r--r-- | chrome/common/localized_error.cc | 108 |
1 files changed, 33 insertions, 75 deletions
diff --git a/chrome/common/localized_error.cc b/chrome/common/localized_error.cc index 0c8453e..129618d 100644 --- a/chrome/common/localized_error.cc +++ b/chrome/common/localized_error.cc @@ -23,6 +23,7 @@ #include "third_party/WebKit/public/platform/WebURLError.h" #include "ui/base/l10n/l10n_util.h" #include "ui/base/webui/web_ui_util.h" +#include "url/gurl.h" #if defined(OS_WIN) #include "base/win/windows_version.h" @@ -485,66 +486,10 @@ const char* GetIconClassForError(const std::string& error_domain, return "icon-generic"; } -// Adds a suggestion to reload the page. Depending on whether the request was -// a post or not, either updates |error_strings| to show a reload button or -// |suggestions| to suggest reloading without a button. -void AddReloadSuggestion(const GURL& failed_url, - bool is_post, - base::DictionaryValue* error_strings, - base::ListValue* suggestions) { - if (!is_post) { - base::DictionaryValue* reload_button = new base::DictionaryValue; - reload_button->SetString("msg", - l10n_util::GetStringUTF16(IDS_ERRORPAGES_BUTTON_RELOAD)); - reload_button->SetString("reloadUrl", failed_url.spec()); - error_strings->Set("reload", reload_button); - } else { - // If the page was created by a post, it can't be reloaded in the same - // way, so just add a suggestion instead. - // TODO(mmenke): Make the reload button bring up the repost confirmation - // dialog for pages resulting from posts. - base::DictionaryValue* suggest_reload_repost = new base::DictionaryValue; - suggest_reload_repost->SetString("header", - l10n_util::GetStringUTF16( - IDS_ERRORPAGES_SUGGESTION_RELOAD_REPOST_HEADER)); - suggest_reload_repost->SetString("body", - l10n_util::GetStringUTF16( - IDS_ERRORPAGES_SUGGESTION_RELOAD_REPOST_BODY)); - // Add at the front, so it appears before other suggestions, in the case - // suggestions are being overridden by |params|. - suggestions->Insert(0, suggest_reload_repost); - } -} - -// Updaes |error_strings| according to the information contained in |params|. -void ApplyParamsToErrorStrings( - const GURL& failed_url, - bool is_post, - scoped_ptr<LocalizedError::ErrorPageParams> params, - base::DictionaryValue* error_strings) { - base::ListValue* suggestions = params->override_suggestions.release(); - if (params->suggest_reload) - AddReloadSuggestion(failed_url, is_post, error_strings, suggestions); - error_strings->Set("suggestions", suggestions); - - if (params->search_url.is_valid()) { - error_strings->SetString("searchHeader", - l10n_util::GetStringUTF16(IDS_ERRORPAGES_SUGGESTION_GOOGLE_SEARCH)); - error_strings->SetString("searchUrl", params->search_url.spec()); - error_strings->SetString("searchTerms", params->search_terms); - } -} - } // namespace const char LocalizedError::kHttpErrorDomain[] = "http"; -LocalizedError::ErrorPageParams::ErrorPageParams() : suggest_reload(false) { -} - -LocalizedError::ErrorPageParams::~ErrorPageParams() { -} - void LocalizedError::GetStrings(int error_code, const std::string& error_domain, const GURL& failed_url, @@ -552,7 +497,6 @@ void LocalizedError::GetStrings(int error_code, bool stale_copy_in_cache, const std::string& locale, const std::string& accept_languages, - scoped_ptr<ErrorPageParams> params, base::DictionaryValue* error_strings) { bool rtl = LocaleIsRTL(); error_strings->SetString("textdirection", rtl ? "rtl" : "ltr"); @@ -615,6 +559,12 @@ void LocalizedError::GetStrings(int error_code, error_strings->SetString( "less", l10n_util::GetStringUTF16(IDS_ERRORPAGES_BUTTON_LESS)); error_strings->Set("summary", summary); + error_strings->SetBoolean("staleCopyInCache", stale_copy_in_cache); + +#if defined(OS_CHROMEOS) + error_strings->SetString( + "diagnose", l10n_util::GetStringUTF16(IDS_ERRORPAGES_BUTTON_DIAGNOSE)); +#endif // defined(OS_CHROMEOS) if (options.details_resource_id != kErrorPagesNoDetails) { error_strings->SetString( @@ -639,7 +589,9 @@ void LocalizedError::GetStrings(int error_code, error_strings->SetString("errorCode", l10n_util::GetStringFUTF16(IDS_ERRORPAGES_ERROR_CODE, error_string)); - // Platform specific information for diagnosing network issues on OSX and + base::ListValue* suggestions = new base::ListValue(); + + // Platform specific instructions for diagnosing network issues on OSX and // Windows. #if defined(OS_MACOSX) || defined(OS_WIN) if (error_domain == net::kErrorDomain && @@ -669,25 +621,29 @@ void LocalizedError::GetStrings(int error_code, } #endif // defined(OS_MACOSX) || defined(OS_WIN) - // If there are |params|, just apply them, and there's nothing else to do. - if (params) { - ApplyParamsToErrorStrings(failed_url, is_post, params.Pass(), - error_strings); - return; + if (options.suggestions & SUGGEST_RELOAD) { + if (!is_post) { + base::DictionaryValue* reload_button = new base::DictionaryValue; + reload_button->SetString("msg", + l10n_util::GetStringUTF16(IDS_ERRORPAGES_BUTTON_RELOAD)); + reload_button->SetString("reloadUrl", failed_url.spec()); + error_strings->Set("reload", reload_button); + } else { + // If the page was created by a post, it can't be reloaded in the same + // way, so just add a suggestion instead. + // TODO(mmenke): Make the reload button bring up the repost confirmation + // dialog for pages resulting from posts. + base::DictionaryValue* suggest_reload_repost = new base::DictionaryValue; + suggest_reload_repost->SetString("header", + l10n_util::GetStringUTF16( + IDS_ERRORPAGES_SUGGESTION_RELOAD_REPOST_HEADER)); + suggest_reload_repost->SetString("body", + l10n_util::GetStringUTF16( + IDS_ERRORPAGES_SUGGESTION_RELOAD_REPOST_BODY)); + suggestions->Append(suggest_reload_repost); + } } - error_strings->SetBoolean("staleCopyInCache", stale_copy_in_cache); - -#if defined(OS_CHROMEOS) - error_strings->SetString( - "diagnose", l10n_util::GetStringUTF16(IDS_ERRORPAGES_BUTTON_DIAGNOSE)); -#endif // defined(OS_CHROMEOS) - - base::ListValue* suggestions = new base::ListValue(); - - if (options.suggestions & SUGGEST_RELOAD) - AddReloadSuggestion(failed_url, is_post, error_strings, suggestions); - if (options.suggestions & SUGGEST_CHECK_CONNECTION) { base::DictionaryValue* suggest_check_connection = new base::DictionaryValue; suggest_check_connection->SetString("header", @@ -811,6 +767,8 @@ void LocalizedError::GetStrings(int error_code, suggestions->Append(suggest_learn_more); } } + + error_strings->Set("suggestions", suggestions); } base::string16 LocalizedError::GetErrorDetails(const blink::WebURLError& error, |