diff options
author | jianli <jianli@chromium.org> | 2016-03-01 17:19:48 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-03-02 01:21:04 +0000 |
commit | 9ea0b744e361b07bac102f1ae24e413effa8a7fc (patch) | |
tree | a8e04f3443fc978818bcfbbb29403ff73367ee83 /components/error_page | |
parent | 76abf5241c467e11324254d20de3dce30e7ee999 (diff) | |
download | chromium_src-9ea0b744e361b07bac102f1ae24e413effa8a7fc.zip chromium_src-9ea0b744e361b07bac102f1ae24e413effa8a7fc.tar.gz chromium_src-9ea0b744e361b07bac102f1ae24e413effa8a7fc.tar.bz2 |
Remove "Show saved copy" button from error page
This is not longer needed after we redirect to offline copy when an
online version fails to load.
BUG=590886
Review URL: https://codereview.chromium.org/1750113002
Cr-Commit-Position: refs/heads/master@{#378645}
Diffstat (limited to 'components/error_page')
-rw-r--r-- | components/error_page/common/BUILD.gn | 1 | ||||
-rw-r--r-- | components/error_page/common/localized_error.cc | 32 | ||||
-rw-r--r-- | components/error_page/common/localized_error.h | 3 | ||||
-rw-r--r-- | components/error_page/common/net_error_info.h | 5 | ||||
-rw-r--r-- | components/error_page/common/offline_page_types.h | 24 | ||||
-rw-r--r-- | components/error_page/renderer/net_error_helper_core.cc | 37 | ||||
-rw-r--r-- | components/error_page/renderer/net_error_helper_core.h | 26 | ||||
-rw-r--r-- | components/error_page/renderer/net_error_helper_core_unittest.cc | 41 |
8 files changed, 44 insertions, 125 deletions
diff --git a/components/error_page/common/BUILD.gn b/components/error_page/common/BUILD.gn index 7d89fdc..98cd30d 100644 --- a/components/error_page/common/BUILD.gn +++ b/components/error_page/common/BUILD.gn @@ -12,7 +12,6 @@ static_library("common") { "localized_error.h", "net_error_info.cc", "net_error_info.h", - "offline_page_types.h", ] deps = [ diff --git a/components/error_page/common/localized_error.cc b/components/error_page/common/localized_error.cc index ead0a35..80dad57 100644 --- a/components/error_page/common/localized_error.cc +++ b/components/error_page/common/localized_error.cc @@ -839,7 +839,7 @@ void LocalizedError::GetStrings(int error_code, bool is_post, bool stale_copy_in_cache, bool can_show_network_diagnostics_dialog, - OfflinePageStatus offline_page_status, + bool has_offline_pages, const std::string& locale, const std::string& accept_languages, scoped_ptr<error_page::ErrorPageParams> params, @@ -1057,26 +1057,16 @@ void LocalizedError::GetStrings(int error_code, #if defined(OS_ANDROID) // Offline button will not be provided when we want to show something in the // cache. - if (!show_saved_copy_visible) { - if (offline_page_status == OfflinePageStatus::HAS_OFFLINE_PAGE) { - base::DictionaryValue* show_offline_copy_button = - new base::DictionaryValue; - base::string16 button_text = - l10n_util::GetStringUTF16(IDS_ERRORPAGES_BUTTON_SHOW_OFFLINE_COPY); - show_offline_copy_button->SetString("msg", button_text); - error_strings->Set("showOfflineCopyButton", show_offline_copy_button); - } else if (offline_page_status == - OfflinePageStatus::HAS_OTHER_OFFLINE_PAGES) { - base::DictionaryValue* show_offline_pages_button = - new base::DictionaryValue; - base::string16 button_text = l10n_util::GetStringUTF16( - offline_pages::GetOfflinePageFeatureMode() == - offline_pages::FeatureMode::ENABLED_AS_BOOKMARKS - ? IDS_ERRORPAGES_BUTTON_SHOW_OFFLINE_PAGES_AS_BOOKMARKS - : IDS_ERRORPAGES_BUTTON_SHOW_OFFLINE_PAGES); - show_offline_pages_button->SetString("msg", button_text); - error_strings->Set("showOfflinePagesButton", show_offline_pages_button); - } + if (!show_saved_copy_visible && has_offline_pages) { + base::DictionaryValue* show_offline_pages_button = + new base::DictionaryValue; + base::string16 button_text = l10n_util::GetStringUTF16( + offline_pages::GetOfflinePageFeatureMode() == + offline_pages::FeatureMode::ENABLED_AS_BOOKMARKS + ? IDS_ERRORPAGES_BUTTON_SHOW_OFFLINE_PAGES_AS_BOOKMARKS + : IDS_ERRORPAGES_BUTTON_SHOW_OFFLINE_PAGES); + show_offline_pages_button->SetString("msg", button_text); + error_strings->Set("showOfflinePagesButton", show_offline_pages_button); } #endif // defined(OS_ANDROID) diff --git a/components/error_page/common/localized_error.h b/components/error_page/common/localized_error.h index 564ab17..ba1143b 100644 --- a/components/error_page/common/localized_error.h +++ b/components/error_page/common/localized_error.h @@ -10,7 +10,6 @@ #include "base/macros.h" #include "base/memory/scoped_ptr.h" #include "base/strings/string16.h" -#include "components/error_page/common/offline_page_types.h" #include "url/gurl.h" namespace base { @@ -31,7 +30,7 @@ class LocalizedError { bool is_post, bool stale_copy_in_cache, bool can_show_network_diagnostics_dialog, - error_page::OfflinePageStatus offline_page_status, + bool has_offline_pages, const std::string& locale, const std::string& accept_languages, scoped_ptr<error_page::ErrorPageParams> params, diff --git a/components/error_page/common/net_error_info.h b/components/error_page/common/net_error_info.h index 42f528b..3abde57 100644 --- a/components/error_page/common/net_error_info.h +++ b/components/error_page/common/net_error_info.h @@ -46,8 +46,9 @@ enum NetworkErrorPageEvent { NETWORK_ERROR_PAGE_SHOW_OFFLINE_PAGES_BUTTON_CLICKED = 19, // For the button to show offline copy. - NETWORK_ERROR_PAGE_SHOW_OFFLINE_COPY_BUTTON_SHOWN = 20, - NETWORK_ERROR_PAGE_SHOW_OFFLINE_COPY_BUTTON_CLICKED = 21, + // Obsolete. No longer showing this. + // NETWORK_ERROR_PAGE_SHOW_OFFLINE_COPY_BUTTON_SHOWN = 20, + // NETWORK_ERROR_PAGE_SHOW_OFFLINE_COPY_BUTTON_CLICKED = 21, NETWORK_ERROR_PAGE_EVENT_MAX, }; diff --git a/components/error_page/common/offline_page_types.h b/components/error_page/common/offline_page_types.h deleted file mode 100644 index ce027b4..0000000 --- a/components/error_page/common/offline_page_types.h +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2015 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef COMPONENTS_ERROR_PAGE_COMMON_OFFLINE_PAGE_TYPES_H_ -#define COMPONENTS_ERROR_PAGE_COMMON_OFFLINE_PAGE_TYPES_H_ - -namespace error_page { - -enum class OfflinePageStatus { - // No offline page exists. - NONE, - // An offline copy of current page exists. - HAS_OFFLINE_PAGE, - // An offline copy of current page does not exist, but the offline copies of - // other pages exist. - HAS_OTHER_OFFLINE_PAGES, - - OFFLINE_PAGE_STATUS_LAST = HAS_OTHER_OFFLINE_PAGES, -}; - -} // namespace error_page - -#endif // COMPONENTS_ERROR_PAGE_COMMON_OFFLINE_PAGE_TYPES_H_ diff --git a/components/error_page/renderer/net_error_helper_core.cc b/components/error_page/renderer/net_error_helper_core.cc index d7c602d..d5c6ca7 100644 --- a/components/error_page/renderer/net_error_helper_core.cc +++ b/components/error_page/renderer/net_error_helper_core.cc @@ -431,7 +431,6 @@ struct NetErrorHelperCore::ErrorPageInfo { show_saved_copy_button_in_page(false), show_cached_copy_button_in_page(false), show_offline_pages_button_in_page(false), - show_offline_copy_button_in_page(false), is_finished_loading(false), auto_reload_triggered(false) {} @@ -467,7 +466,6 @@ struct NetErrorHelperCore::ErrorPageInfo { bool show_saved_copy_button_in_page; bool show_cached_copy_button_in_page; bool show_offline_pages_button_in_page; - bool show_offline_copy_button_in_page; // True if a page has completed loading, at which point it can receive // updates. @@ -526,7 +524,7 @@ NetErrorHelperCore::NetErrorHelperCore(Delegate* delegate, visible_(is_visible), auto_reload_count_(0), #if defined(OS_ANDROID) - offline_page_status_(OfflinePageStatus::NONE), + has_offline_pages_(false), #endif // defined(OS_ANDROID) navigation_from_button_(NO_BUTTON) { } @@ -656,9 +654,6 @@ void NetErrorHelperCore::OnFinishLoad(FrameType frame_type) { if (committed_error_page_info_->show_offline_pages_button_in_page) { RecordEvent(NETWORK_ERROR_PAGE_SHOW_OFFLINE_PAGES_BUTTON_SHOWN); } - if (committed_error_page_info_->show_offline_copy_button_in_page) { - RecordEvent(NETWORK_ERROR_PAGE_SHOW_OFFLINE_COPY_BUTTON_SHOWN); - } if (committed_error_page_info_->reload_button_in_page && committed_error_page_info_->show_saved_copy_button_in_page) { RecordEvent(NETWORK_ERROR_PAGE_BOTH_BUTTONS_SHOWN); @@ -714,16 +709,14 @@ void NetErrorHelperCore::GetErrorHTML(FrameType frame_type, bool show_saved_copy_button_in_page; bool show_cached_copy_button_in_page; bool show_offline_pages_button_in_page; - bool show_offline_copy_button_in_page; delegate_->GenerateLocalizedErrorPage( error, is_failed_post, false /* No diagnostics dialogs allowed for subframes. */, - OfflinePageStatus::NONE /* No offline button provided in subframes */, + false /* No offline button provided in subframes */, scoped_ptr<ErrorPageParams>(), &reload_button_in_page, &show_saved_copy_button_in_page, &show_cached_copy_button_in_page, - &show_offline_pages_button_in_page, - &show_offline_copy_button_in_page, error_html); + &show_offline_pages_button_in_page, error_html); } } @@ -759,10 +752,9 @@ void NetErrorHelperCore::OnSetNavigationCorrectionInfo( navigation_correction_params_.search_url = search_url; } -void NetErrorHelperCore::OnSetOfflinePageInfo( - OfflinePageStatus offline_page_status) { +void NetErrorHelperCore::OnSetHasOfflinePages(bool has_offline_pages) { #if defined(OS_ANDROID) - offline_page_status_ = offline_page_status; + has_offline_pages_ = has_offline_pages; #endif // defined(OS_ANDROID) } @@ -793,13 +785,12 @@ void NetErrorHelperCore::GetErrorHtmlForMainFrame( delegate_->GenerateLocalizedErrorPage( error, pending_error_page_info->was_failed_post, can_show_network_diagnostics_dialog_, - GetOfflinePageStatus(), + HasOfflinePages(), scoped_ptr<ErrorPageParams>(), &pending_error_page_info->reload_button_in_page, &pending_error_page_info->show_saved_copy_button_in_page, &pending_error_page_info->show_cached_copy_button_in_page, &pending_error_page_info->show_offline_pages_button_in_page, - &pending_error_page_info->show_offline_copy_button_in_page, error_html); } @@ -824,7 +815,7 @@ void NetErrorHelperCore::UpdateErrorPage() { GetUpdatedError(committed_error_page_info_->error), committed_error_page_info_->was_failed_post, can_show_network_diagnostics_dialog_, - GetOfflinePageStatus()); + HasOfflinePages()); } void NetErrorHelperCore::OnNavigationCorrectionsFetched( @@ -861,12 +852,11 @@ void NetErrorHelperCore::OnNavigationCorrectionsFetched( delegate_->GenerateLocalizedErrorPage( pending_error_page_info_->error, pending_error_page_info_->was_failed_post, - can_show_network_diagnostics_dialog_, GetOfflinePageStatus(), + can_show_network_diagnostics_dialog_, HasOfflinePages(), std::move(params), &pending_error_page_info_->reload_button_in_page, &pending_error_page_info_->show_saved_copy_button_in_page, &pending_error_page_info_->show_cached_copy_button_in_page, &pending_error_page_info_->show_offline_pages_button_in_page, - &pending_error_page_info_->show_offline_copy_button_in_page, &error_html); } else { // Since |navigation_correction_params| in |pending_error_page_info_| is @@ -1035,11 +1025,6 @@ void NetErrorHelperCore::ExecuteButtonPress(Button button) { RecordEvent(NETWORK_ERROR_PAGE_SHOW_OFFLINE_PAGES_BUTTON_CLICKED); delegate_->ShowOfflinePages(); return; - case SHOW_OFFLINE_COPY_BUTTON: - RecordEvent(NETWORK_ERROR_PAGE_SHOW_OFFLINE_COPY_BUTTON_CLICKED); - delegate_->LoadOfflineCopy( - committed_error_page_info_->error.unreachableURL); - return; case NO_BUTTON: NOTREACHED(); return; @@ -1084,11 +1069,11 @@ void NetErrorHelperCore::TrackClick(int tracking_id) { request_body); } -OfflinePageStatus NetErrorHelperCore::GetOfflinePageStatus() const { +bool NetErrorHelperCore::HasOfflinePages() const { #if defined(OS_ANDROID) - return offline_page_status_; + return has_offline_pages_; #else - return OfflinePageStatus::NONE; + return false; #endif // defined(OS_ANDROID) } diff --git a/components/error_page/renderer/net_error_helper_core.h b/components/error_page/renderer/net_error_helper_core.h index c4031b3..1dc97e6 100644 --- a/components/error_page/renderer/net_error_helper_core.h +++ b/components/error_page/renderer/net_error_helper_core.h @@ -13,7 +13,6 @@ #include "base/timer/timer.h" #include "build/build_config.h" #include "components/error_page/common/net_error_info.h" -#include "components/error_page/common/offline_page_types.h" #include "url/gurl.h" namespace base { @@ -53,7 +52,6 @@ class NetErrorHelperCore { SHOW_CACHED_COPY_BUTTON, // "Google cached copy" button label experiment. DIAGNOSE_ERROR, SHOW_OFFLINE_PAGES_BUTTON, // "Offline pages" experiment. - SHOW_OFFLINE_COPY_BUTTON, // "Offline pages" experiment. }; // The Delegate handles all interaction with the RenderView, WebFrame, and @@ -65,13 +63,12 @@ class NetErrorHelperCore { const blink::WebURLError& error, bool is_failed_post, bool can_show_network_diagnostics_dialog, - OfflinePageStatus offline_page_status, + bool has_offline_pages, scoped_ptr<ErrorPageParams> params, bool* reload_button_shown, bool* show_saved_copy_button_shown, bool* show_cached_copy_button_shown, bool* show_offline_pages_button_shown, - bool* show_offline_copy_button_shown, std::string* html) const = 0; // Loads the given HTML in the frame for use as an error page. @@ -88,7 +85,7 @@ class NetErrorHelperCore { virtual void UpdateErrorPage(const blink::WebURLError& error, bool is_failed_post, bool can_show_network_diagnostics_dialog, - OfflinePageStatus offline_page_status) = 0; + bool has_offline_pages) = 0; // Fetches an error page and calls into OnErrorPageFetched when done. Any // previous fetch must either be canceled or finished before calling. Can't @@ -119,11 +116,6 @@ class NetErrorHelperCore { // Shows all the offline pages that were saved in storage. virtual void ShowOfflinePages() = 0; - // Loads the offline copy of the page that was saved in storage. - // Note that this is different from the saved copy in the cache as in - // LoadPageFromCache. - virtual void LoadOfflineCopy(const GURL& page_url) = 0; - protected: virtual ~Delegate() {} }; @@ -188,9 +180,9 @@ class NetErrorHelperCore { const std::string& api_key, const GURL& search_url); - // Notifies |this| that information about the presence of an offline version - // of the page has been received. - void OnSetOfflinePageInfo(OfflinePageStatus offline_page_status); + // Notifies |this| that information about whether offline pages exist has been + // received. + void OnSetHasOfflinePages(bool has_offline_pages); // Notifies |this| that the network's online status changed. // Handler for NetworkStateChanged notification from the browser process. If @@ -246,7 +238,7 @@ class NetErrorHelperCore { void AutoReloadTimerFired(); void PauseAutoReloadTimer(); - OfflinePageStatus GetOfflinePageStatus() const; + bool HasOfflinePages() const; static bool IsReloadableError(const ErrorPageInfo& info); @@ -301,9 +293,9 @@ class NetErrorHelperCore { int auto_reload_count_; #if defined(OS_ANDROID) - // Status of offline pages. This is used to decide if offline related button - // will be shown in certain error page. - OfflinePageStatus offline_page_status_; + // Whether offline pages exist. This is used to decide if offline related + // button will be shown in certain error page. + bool has_offline_pages_; #endif // defined(OS_ANDROID) // This value is set only when a navigation has been initiated from diff --git a/components/error_page/renderer/net_error_helper_core_unittest.cc b/components/error_page/renderer/net_error_helper_core_unittest.cc index 15f9ab2..2b3a3a9 100644 --- a/components/error_page/renderer/net_error_helper_core_unittest.cc +++ b/components/error_page/renderer/net_error_helper_core_unittest.cc @@ -165,7 +165,6 @@ class NetErrorHelperCoreTest : public testing::Test, show_saved_copy_count_(0), diagnose_error_count_(0), show_offline_pages_count_(0), - load_offline_copy_count_(0), enable_page_helper_functions_count_(0), default_url_(GURL(kFailedUrl)), error_url_(GURL(content::kUnreachableWebDataURL)), @@ -225,8 +224,6 @@ class NetErrorHelperCoreTest : public testing::Test, int show_offline_pages_count() const { return show_offline_pages_count_; } - int load_offline_copy_count() const { return load_offline_copy_count_; } - const GURL& default_url() const { return default_url_; } @@ -249,8 +246,8 @@ class NetErrorHelperCoreTest : public testing::Test, return last_can_show_network_diagnostics_dialog_; } - OfflinePageStatus last_offline_page_status() const { - return last_offline_page_status_; + bool last_has_offline_pages() const { + return last_has_offline_pages_; } const ErrorPageParams* last_error_page_params() const { @@ -358,23 +355,21 @@ class NetErrorHelperCoreTest : public testing::Test, void GenerateLocalizedErrorPage(const WebURLError& error, bool is_failed_post, bool can_show_network_diagnostics_dialog, - OfflinePageStatus offline_page_status, + bool has_offline_pages, scoped_ptr<ErrorPageParams> params, bool* reload_button_shown, bool* show_saved_copy_button_shown, bool* show_cached_copy_button_shown, bool* show_offline_pages_button_shown, - bool* show_offline_copy_button_shown, std::string* html) const override { last_can_show_network_diagnostics_dialog_ = can_show_network_diagnostics_dialog; - last_offline_page_status_ = offline_page_status; + last_has_offline_pages_ = has_offline_pages; last_error_page_params_.reset(params.release()); *reload_button_shown = false; *show_saved_copy_button_shown = false; *show_cached_copy_button_shown = false; *show_offline_pages_button_shown = false; - *show_offline_copy_button_shown = false; *html = ErrorToString(error, is_failed_post); } @@ -390,11 +385,11 @@ class NetErrorHelperCoreTest : public testing::Test, void UpdateErrorPage(const WebURLError& error, bool is_failed_post, bool can_show_network_diagnostics_dialog, - OfflinePageStatus offline_page_status) override { + bool has_offline_pages) override { update_count_++; last_can_show_network_diagnostics_dialog_ = can_show_network_diagnostics_dialog; - last_offline_page_status_ = offline_page_status; + last_has_offline_pages_ = has_offline_pages; last_error_page_params_.reset(nullptr); last_error_html_ = ErrorToString(error, is_failed_post); } @@ -447,10 +442,6 @@ class NetErrorHelperCoreTest : public testing::Test, void ShowOfflinePages() override { show_offline_pages_count_++; } - void LoadOfflineCopy(const GURL& page_url) override { - load_offline_copy_count_++; - } - void SendTrackingRequest(const GURL& tracking_url, const std::string& tracking_request_body) override { last_tracking_url_ = tracking_url; @@ -493,7 +484,7 @@ class NetErrorHelperCoreTest : public testing::Test, // Values passed in to the last call of GenerateLocalizedErrorPage or // UpdateErrorPage. Mutable because GenerateLocalizedErrorPage is const. mutable bool last_can_show_network_diagnostics_dialog_; - mutable OfflinePageStatus last_offline_page_status_; + mutable bool last_has_offline_pages_; mutable scoped_ptr<ErrorPageParams> last_error_page_params_; int reload_count_; @@ -503,7 +494,6 @@ class NetErrorHelperCoreTest : public testing::Test, int diagnose_error_count_; GURL diagnose_error_url_; int show_offline_pages_count_; - int load_offline_copy_count_; int enable_page_helper_functions_count_; @@ -2587,26 +2577,13 @@ TEST_F(NetErrorHelperCoreTest, CanShowNetworkDiagnostics) { #if defined(OS_ANDROID) TEST_F(NetErrorHelperCoreTest, ShowOfflinePages) { - core()->OnSetOfflinePageInfo(OfflinePageStatus::HAS_OTHER_OFFLINE_PAGES); + core()->OnSetHasOfflinePages(true); DoErrorLoad(net::ERR_INTERNET_DISCONNECTED); - EXPECT_EQ(OfflinePageStatus::HAS_OTHER_OFFLINE_PAGES, - last_offline_page_status()); + EXPECT_TRUE(last_has_offline_pages()); EXPECT_EQ(0, show_offline_pages_count()); - EXPECT_EQ(0, load_offline_copy_count()); core()->ExecuteButtonPress(NetErrorHelperCore::SHOW_OFFLINE_PAGES_BUTTON); EXPECT_EQ(1, show_offline_pages_count()); } - -TEST_F(NetErrorHelperCoreTest, LoadOfflineCopy) { - core()->OnSetOfflinePageInfo(OfflinePageStatus::HAS_OFFLINE_PAGE); - DoErrorLoad(net::ERR_INTERNET_DISCONNECTED); - EXPECT_EQ(OfflinePageStatus::HAS_OFFLINE_PAGE, last_offline_page_status()); - EXPECT_EQ(0, show_offline_pages_count()); - EXPECT_EQ(0, load_offline_copy_count()); - core()->ExecuteButtonPress(NetErrorHelperCore::SHOW_OFFLINE_COPY_BUTTON); - EXPECT_EQ(0, show_offline_pages_count()); - EXPECT_EQ(1, load_offline_copy_count()); -} #endif // defined(OS_ANDROID) } // namespace |