Index: components/error_page/renderer/net_error_helper_core.h |
diff --git a/components/error_page/renderer/net_error_helper_core.h b/components/error_page/renderer/net_error_helper_core.h |
index d5c8930d943d5c4f88809546b1510449b0df8f6f..1cc03f02bc69413d8387e499c296e26f89815bb7 100644 |
--- a/components/error_page/renderer/net_error_helper_core.h |
+++ b/components/error_page/renderer/net_error_helper_core.h |
@@ -5,13 +5,16 @@ |
#ifndef COMPONENTS_ERROR_PAGE_RENDERER_NET_ERROR_HELPER_CORE_H_ |
#define COMPONENTS_ERROR_PAGE_RENDERER_NET_ERROR_HELPER_CORE_H_ |
+#include <set> |
#include <string> |
+#include <vector> |
#include "base/callback.h" |
#include "base/memory/scoped_ptr.h" |
#include "base/memory/weak_ptr.h" |
#include "base/timer/timer.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 { |
@@ -50,7 +53,8 @@ class NetErrorHelperCore { |
EASTER_EGG, |
SHOW_CACHED_COPY_BUTTON, // "Google cached copy" button label experiment. |
DIAGNOSE_ERROR, |
- SHOW_SAVED_PAGES_BUTTON, |
+ SHOW_OFFLINE_PAGES_BUTTON, // "Offline pages" experiment. |
+ SHOW_OFFLINE_COPY_BUTTON, // "Offline pages" experiment. |
}; |
// The Delegate handles all interaction with the RenderView, WebFrame, and |
@@ -62,12 +66,13 @@ class NetErrorHelperCore { |
const blink::WebURLError& error, |
bool is_failed_post, |
bool can_show_network_diagnostics_dialog, |
- bool has_offline_pages, |
+ OfflinePageStatus offline_page_status, |
scoped_ptr<ErrorPageParams> params, |
bool* reload_button_shown, |
bool* show_saved_copy_button_shown, |
bool* show_cached_copy_button_shown, |
- bool* show_saved_pages_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. |
@@ -84,7 +89,7 @@ class NetErrorHelperCore { |
virtual void UpdateErrorPage(const blink::WebURLError& error, |
bool is_failed_post, |
bool can_show_network_diagnostics_dialog, |
- bool has_offline_pages) = 0; |
+ OfflinePageStatus offline_page_status) = 0; |
// Fetches an error page and calls into OnErrorPageFetched when done. Any |
// previous fetch must either be canceled or finished before calling. Can't |
@@ -112,9 +117,14 @@ class NetErrorHelperCore { |
// Run the platform diagnostics too for the specified URL. |
virtual void DiagnoseError(const GURL& page_url) = 0; |
- // Shows the UI for offline pages. |
+ // 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() {} |
}; |
@@ -178,8 +188,9 @@ class NetErrorHelperCore { |
const std::string& api_key, |
const GURL& search_url); |
- // Notifies by the browser whether an offline page exists. |
- void OnSetHasOfflinePages(bool has_offline_pages); |
+ // Notifies |this| that information about the presence of an offline version |
+ // of the page has been received. |
+ void OnSetOfflinePageInfo(const std::vector<GURL>& offline_page_urls); |
// Notifies |this| that the network's online status changed. |
// Handler for NetworkStateChanged notification from the browser process. If |
@@ -235,6 +246,9 @@ class NetErrorHelperCore { |
void AutoReloadTimerFired(); |
void PauseAutoReloadTimer(); |
+ OfflinePageStatus GetOfflinePageStatusForError( |
+ const blink::WebURLError& error) const; |
+ |
static bool IsReloadableError(const ErrorPageInfo& info); |
Delegate* delegate_; |
@@ -287,14 +301,14 @@ class NetErrorHelperCore { |
int auto_reload_count_; |
+#if defined(OS_ANDROID) |
+ std::set<GURL> offline_page_urls_; |
+#endif // defined(OS_ANDROID) |
+ |
// This value is set only when a navigation has been initiated from |
// the error page. It is used to detect when such navigations result |
// in errors. |
Button navigation_from_button_; |
- |
- // Whether an offline page exists. This is used to decide if "Show saved |
- // pages" will be provided in certain error page. |
- bool has_offline_pages_; |
}; |
} // namespace error_page |