Skip to content

Commit

Permalink
Remove "Show saved copy" button from error page
Browse files Browse the repository at this point in the history
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}
  • Loading branch information
jianli-chromium authored and Commit bot committed Mar 2, 2016
1 parent 76abf52 commit 9ea0b74
Show file tree
Hide file tree
Showing 21 changed files with 71 additions and 252 deletions.
14 changes: 0 additions & 14 deletions chrome/browser/android/tab_android.cc
Original file line number Diff line number Diff line change
Expand Up @@ -753,10 +753,6 @@ void TabAndroid::LoadOriginalImage(JNIEnv* env,
jlong TabAndroid::GetBookmarkId(JNIEnv* env,
const JavaParamRef<jobject>& obj,
jboolean only_editable) {
return GetBookmarkIdHelper(only_editable);
}

int64_t TabAndroid::GetBookmarkIdHelper(bool only_editable) const {
GURL url = dom_distiller::url_utils::GetOriginalUrlFromDistillerUrl(
web_contents()->GetURL());
Profile* profile = GetProfile();
Expand Down Expand Up @@ -802,16 +798,6 @@ void TabAndroid::ShowOfflinePages() {
Java_Tab_showOfflinePages(env, weak_java_tab_.get(env).obj());
}

void TabAndroid::LoadOfflineCopy(const GURL& url) {
GURL offline_url = offline_pages::OfflinePageUtils::GetOfflineURLForOnlineURL(
GetProfile(), url);
if (!offline_url.is_valid())
return;

content::NavigationController::LoadURLParams load_params(offline_url);
web_contents()->GetController().LoadURLWithParams(load_params);
}

void TabAndroid::OnLoFiResponseReceived(bool is_preview) {
JNIEnv* env = base::android::AttachCurrentThread();
Java_Tab_onLoFiResponseReceived(env, weak_java_tab_.get(env).obj(),
Expand Down
3 changes: 0 additions & 3 deletions chrome/browser/android/tab_android.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ class TabAndroid : public CoreTabHelperDelegate,

bool HasOfflinePages() const;
void ShowOfflinePages();
void LoadOfflineCopy(const GURL& url);

// Notifies this TabAndroid that a Lo-Fi response has been received. The
// TabAndroid then handles showing Lo-Fi UI if this is the first Lo-Fi
Expand Down Expand Up @@ -267,8 +266,6 @@ class TabAndroid : public CoreTabHelperDelegate,
private:
prerender::PrerenderManager* GetPrerenderManager() const;

int64_t GetBookmarkIdHelper(bool only_editable) const;

JavaObjectWeakGlobalRef weak_java_tab_;

// The identifier used by session restore for this tab.
Expand Down
37 changes: 6 additions & 31 deletions chrome/browser/net/net_error_tab_helper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ using content::WebContents;
using content::WebContentsObserver;
using error_page::DnsProbeStatus;
using error_page::DnsProbeStatusToString;
using error_page::OfflinePageStatus;
using ui::PageTransition;

DEFINE_WEB_CONTENTS_USER_DATA_KEY(chrome_browser_net::NetErrorTabHelper);
Expand Down Expand Up @@ -132,7 +131,7 @@ void NetErrorTabHelper::DidStartProvisionalLoadForFrame(
is_error_page_ = is_error_page;

#if BUILDFLAG(ANDROID_JAVA_UI)
SetOfflinePageInfo(render_frame_host, validated_url);
SetHasOfflinePages(render_frame_host);
#endif // BUILDFLAG(ANDROID_JAVA_UI)
}

Expand Down Expand Up @@ -187,7 +186,6 @@ bool NetErrorTabHelper::OnMessageReceived(
RunNetworkDiagnostics)
#if BUILDFLAG(ANDROID_JAVA_UI)
IPC_MESSAGE_HANDLER(ChromeViewHostMsg_ShowOfflinePages, ShowOfflinePages)
IPC_MESSAGE_HANDLER(ChromeViewHostMsg_LoadOfflineCopy, LoadOfflineCopy)
#endif // BUILDFLAG(ANDROID_JAVA_UI)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
Expand Down Expand Up @@ -297,9 +295,8 @@ void NetErrorTabHelper::RunNetworkDiagnosticsHelper(
}

#if BUILDFLAG(ANDROID_JAVA_UI)
void NetErrorTabHelper::SetOfflinePageInfo(
content::RenderFrameHost* render_frame_host,
const GURL& url) {
void NetErrorTabHelper::SetHasOfflinePages(
content::RenderFrameHost* render_frame_host) {
// Bails out if offline pages not supported.
if (!offline_pages::IsOfflinePagesEnabled())
return;
Expand All @@ -310,14 +307,9 @@ void NetErrorTabHelper::SetOfflinePageInfo(
if (!offline_page_model)
return;

OfflinePageStatus status = OfflinePageStatus::NONE;
if (offline_page_model->HasOfflinePages()) {
status = offline_page_model->GetPageByOnlineURL(url)
? OfflinePageStatus::HAS_OFFLINE_PAGE
: OfflinePageStatus::HAS_OTHER_OFFLINE_PAGES;
}
render_frame_host->Send(new ChromeViewMsg_SetOfflinePageInfo(
render_frame_host->GetRoutingID(), status));
render_frame_host->Send(new ChromeViewMsg_SetHasOfflinePages(
render_frame_host->GetRoutingID(),
offline_page_model->HasOfflinePages()));
}

void NetErrorTabHelper::ShowOfflinePages() {
Expand All @@ -331,23 +323,6 @@ void NetErrorTabHelper::ShowOfflinePages() {
tab->ShowOfflinePages();
}

void NetErrorTabHelper::LoadOfflineCopy(const GURL& url) {
// Makes sure that this is coming from an error page.
if (!IsFromErrorPage())
return;

GURL validated_url(url);
if (!validated_url.is_valid())
return;

if (validated_url != web_contents()->GetLastCommittedURL())
return;

TabAndroid* tab = TabAndroid::FromWebContents(web_contents());
if (tab)
tab->LoadOfflineCopy(url);
}

bool NetErrorTabHelper::IsFromErrorPage() const {
content::NavigationEntry* entry =
web_contents()->GetController().GetLastCommittedEntry();
Expand Down
4 changes: 1 addition & 3 deletions chrome/browser/net/net_error_tab_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,8 @@ class NetErrorTabHelper

// Relates to offline pages handling.
#if BUILDFLAG(ANDROID_JAVA_UI)
void SetOfflinePageInfo(content::RenderFrameHost* render_frame_host,
const GURL& url);
void SetHasOfflinePages(content::RenderFrameHost* render_frame_host);
void ShowOfflinePages();
void LoadOfflineCopy(const GURL& url);
bool IsFromErrorPage() const;
#endif // BUILDFLAG(ANDROID_JAVA_UI)

Expand Down
14 changes: 3 additions & 11 deletions chrome/common/render_messages.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#include "chrome/common/ntp_logging_events.h"
#include "chrome/common/search_provider.h"
#include "chrome/common/web_application_info.h"
#include "components/error_page/common/offline_page_types.h"
#include "components/omnibox/common/omnibox_focus_state.h"
#include "content/public/common/common_param_traits.h"
#include "content/public/common/top_controls_state.h"
Expand Down Expand Up @@ -78,9 +77,6 @@ IPC_ENUM_TRAITS_MAX_VALUE(blink::WebConsoleMessage::Level,
blink::WebConsoleMessage::LevelLast)
IPC_ENUM_TRAITS_MAX_VALUE(content::TopControlsState,
content::TOP_CONTROLS_STATE_LAST)
IPC_ENUM_TRAITS_MAX_VALUE(
error_page::OfflinePageStatus,
error_page::OfflinePageStatus::OFFLINE_PAGE_STATUS_LAST)

// Output parameters for ChromeViewHostMsg_GetPluginInfo message.
IPC_STRUCT_BEGIN(ChromeViewHostMsg_GetPluginInfo_Output)
Expand Down Expand Up @@ -320,10 +316,10 @@ IPC_MESSAGE_ROUTED1(ChromeViewMsg_SetCanShowNetworkDiagnosticsDialog,
bool /* can_show_network_diagnostics_dialog */)

#if defined(OS_ANDROID)
// Tells the renderer about the status of the offline pages. This is used to
// Tells the renderer whether or not offline pages exist. This is used to
// decide if offline related button will be provided on certain error page.
IPC_MESSAGE_ROUTED1(ChromeViewMsg_SetOfflinePageInfo,
error_page::OfflinePageStatus /* offline_page_status */)
IPC_MESSAGE_ROUTED1(ChromeViewMsg_SetHasOfflinePages,
bool /* has_offline_pages */)
#endif // defined(OS_ANDROID)

// Provides the information needed by the renderer process to contact a
Expand All @@ -342,10 +338,6 @@ IPC_MESSAGE_ROUTED1(ChromeViewHostMsg_RunNetworkDiagnostics,
// Message sent from the renderer to the browser to show the UI for offline
// pages.
IPC_MESSAGE_ROUTED0(ChromeViewHostMsg_ShowOfflinePages)

// Message sent from the renderer to the browser to load the offline copy of
// the page that fails to load due to no network connectivity.
IPC_MESSAGE_ROUTED1(ChromeViewHostMsg_LoadOfflineCopy, GURL /* url */)
#endif // defined(OS_ANDROID)

//-----------------------------------------------------------------------------
Expand Down
26 changes: 7 additions & 19 deletions chrome/renderer/net/net_error_helper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ using error_page::DnsProbeStatusToString;
using error_page::ErrorPageParams;
using error_page::LocalizedError;
using error_page::NetErrorHelperCore;
using error_page::OfflinePageStatus;

namespace {

Expand Down Expand Up @@ -155,7 +154,7 @@ bool NetErrorHelper::OnMessageReceived(const IPC::Message& message) {
IPC_MESSAGE_HANDLER(ChromeViewMsg_SetNavigationCorrectionInfo,
OnSetNavigationCorrectionInfo);
#if defined(OS_ANDROID)
IPC_MESSAGE_HANDLER(ChromeViewMsg_SetOfflinePageInfo, OnSetOfflinePageInfo)
IPC_MESSAGE_HANDLER(ChromeViewMsg_SetHasOfflinePages, OnSetHasOfflinePages)
#endif
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
Expand Down Expand Up @@ -183,13 +182,12 @@ void NetErrorHelper::GenerateLocalizedErrorPage(
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* error_html) const {
error_html->clear();

Expand All @@ -203,7 +201,7 @@ void NetErrorHelper::GenerateLocalizedErrorPage(
LocalizedError::GetStrings(
error.reason, error.domain.utf8(), error.unreachableURL, is_failed_post,
error.staleCopyInCache, can_show_network_diagnostics_dialog,
offline_page_status, RenderThread::Get()->GetLocale(),
has_offline_pages, RenderThread::Get()->GetLocale(),
render_frame()->GetRenderView()->GetAcceptLanguages(),
std::move(params), &error_strings);
*reload_button_shown = error_strings.Get("reloadButton", nullptr);
Expand All @@ -213,8 +211,6 @@ void NetErrorHelper::GenerateLocalizedErrorPage(
error_strings.Get("cacheButton", nullptr);
*show_offline_pages_button_shown =
error_strings.Get("showOfflinePagesButton", nullptr);
*show_offline_copy_button_shown =
error_strings.Get("showOfflineCopyButton", nullptr);
// "t" is the id of the template's root node.
*error_html = webui::GetTemplatesHtml(template_html, &error_strings, "t");
}
Expand All @@ -234,7 +230,7 @@ void NetErrorHelper::EnablePageHelperFunctions() {
void NetErrorHelper::UpdateErrorPage(const blink::WebURLError& error,
bool is_failed_post,
bool can_show_network_diagnostics_dialog,
OfflinePageStatus offline_page_status) {
bool has_offline_pages) {
base::DictionaryValue error_strings;
LocalizedError::GetStrings(
error.reason,
Expand All @@ -243,7 +239,7 @@ void NetErrorHelper::UpdateErrorPage(const blink::WebURLError& error,
is_failed_post,
error.staleCopyInCache,
can_show_network_diagnostics_dialog,
offline_page_status,
has_offline_pages,
RenderThread::Get()->GetLocale(),
render_frame()->GetRenderView()->GetAcceptLanguages(),
scoped_ptr<ErrorPageParams>(),
Expand Down Expand Up @@ -336,13 +332,6 @@ void NetErrorHelper::ShowOfflinePages() {
#endif // defined(OS_ANDROID)
}

void NetErrorHelper::LoadOfflineCopy(const GURL& page_url) {
#if defined(OS_ANDROID)
render_frame()->Send(new ChromeViewHostMsg_LoadOfflineCopy(
render_frame()->GetRoutingID(), page_url));
#endif // defined(OS_ANDROID)
}

void NetErrorHelper::OnNetErrorInfo(int status_num) {
DCHECK(status_num >= 0 && status_num < error_page::DNS_PROBE_MAX);

Expand Down Expand Up @@ -388,8 +377,7 @@ void NetErrorHelper::OnTrackingRequestComplete(
}

#if defined(OS_ANDROID)
void NetErrorHelper::OnSetOfflinePageInfo(
OfflinePageStatus offline_page_status) {
core_->OnSetOfflinePageInfo(offline_page_status);
void NetErrorHelper::OnSetHasOfflinePages(bool has_offline_pages) {
core_->OnSetHasOfflinePages(has_offline_pages);
}
#endif // defined(OS_ANDROID)
18 changes: 7 additions & 11 deletions chrome/renderer/net/net_error_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#include "build/build_config.h"
#include "chrome/renderer/net/net_error_page_controller.h"
#include "components/error_page/common/net_error_info.h"
#include "components/error_page/common/offline_page_types.h"
#include "components/error_page/renderer/net_error_helper_core.h"
#include "content/public/renderer/render_frame_observer.h"
#include "content/public/renderer/render_frame_observer_tracker.h"
Expand Down Expand Up @@ -87,21 +86,19 @@ class NetErrorHelper
const blink::WebURLError& error,
bool is_failed_post,
bool can_use_local_diagnostics_service,
error_page::OfflinePageStatus offline_page_status,
bool has_offline_pages,
scoped_ptr<error_page::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;
void LoadErrorPage(const std::string& html, const GURL& failed_url) override;
void EnablePageHelperFunctions() override;
void UpdateErrorPage(
const blink::WebURLError& error,
bool is_failed_post,
bool can_use_local_diagnostics_service,
error_page::OfflinePageStatus offline_page_status) override;
void UpdateErrorPage(const blink::WebURLError& error,
bool is_failed_post,
bool can_use_local_diagnostics_service,
bool has_offline_pages) override;
void FetchNavigationCorrections(
const GURL& navigation_correction_url,
const std::string& navigation_correction_request_body) override;
Expand All @@ -112,7 +109,6 @@ class NetErrorHelper
void LoadPageFromCache(const GURL& page_url) override;
void DiagnoseError(const GURL& page_url) override;
void ShowOfflinePages() override;
void LoadOfflineCopy(const GURL& page_url) override;

void OnNetErrorInfo(int status);
void OnSetCanShowNetworkDiagnosticsDialog(
Expand All @@ -130,9 +126,9 @@ class NetErrorHelper
const std::string& data);

#if defined(OS_ANDROID)
// Called to set the status of the offline pages that will be used to decide
// Called to set whether offline pages exists, which will be used to decide
// if offline related button will be provided in the error page.
void OnSetOfflinePageInfo(error_page::OfflinePageStatus offline_page_status);
void OnSetHasOfflinePages(bool has_offline_pages);
#endif

scoped_ptr<content::ResourceFetcher> correction_fetcher_;
Expand Down
6 changes: 0 additions & 6 deletions chrome/renderer/net/net_error_page_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,6 @@ bool NetErrorPageController::ShowOfflinePagesButtonClick() {
return ButtonClick(error_page::NetErrorHelperCore::SHOW_OFFLINE_PAGES_BUTTON);
}

bool NetErrorPageController::ShowOfflineCopyButtonClick() {
return ButtonClick(error_page::NetErrorHelperCore::SHOW_OFFLINE_COPY_BUTTON);
}

bool NetErrorPageController::ReloadButtonClick() {
return ButtonClick(error_page::NetErrorHelperCore::RELOAD_BUTTON);
}
Expand Down Expand Up @@ -102,8 +98,6 @@ gin::ObjectTemplateBuilder NetErrorPageController::GetObjectTemplateBuilder(
&NetErrorPageController::ShowSavedCopyButtonClick)
.SetMethod("showOfflinePagesButtonClick",
&NetErrorPageController::ShowOfflinePagesButtonClick)
.SetMethod("showOfflineCopyButtonClick",
&NetErrorPageController::ShowOfflineCopyButtonClick)
.SetMethod("reloadButtonClick",
&NetErrorPageController::ReloadButtonClick)
.SetMethod("detailsButtonClick",
Expand Down
3 changes: 0 additions & 3 deletions chrome/renderer/net/net_error_page_controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,6 @@ class NetErrorPageController : public gin::Wrappable<NetErrorPageController> {
// Execute a button click to show the list of all offline pages.
bool ShowOfflinePagesButtonClick();

// Execute a button click to show the offline copy of this page.
bool ShowOfflineCopyButtonClick();

// Execute a "Reload" button click.
bool ReloadButtonClick();

Expand Down
1 change: 0 additions & 1 deletion components/error_page.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
'error_page/common/localized_error.h',
'error_page/common/net_error_info.cc',
'error_page/common/net_error_info.h',
'error_page/common/offline_page_types.h',
],
},
],
Expand Down
1 change: 0 additions & 1 deletion components/error_page/common/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ static_library("common") {
"localized_error.h",
"net_error_info.cc",
"net_error_info.h",
"offline_page_types.h",
]

deps = [
Expand Down
Loading

0 comments on commit 9ea0b74

Please sign in to comment.