summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPete Williamson <petewil@chromium.org>2016-03-23 11:13:04 -0700
committerPete Williamson <petewil@chromium.org>2016-03-23 18:15:44 +0000
commit00ff65bb8d9ece36057585c3a31439adbfd79d1f (patch)
treee88364786c91398f32e70f01f530cf58cd74ce32
parent9c48e88ab90a5f4eb56dd4c65da66e4c0b1db138 (diff)
downloadchromium_src-00ff65bb8d9ece36057585c3a31439adbfd79d1f.zip
chromium_src-00ff65bb8d9ece36057585c3a31439adbfd79d1f.tar.gz
chromium_src-00ff65bb8d9ece36057585c3a31439adbfd79d1f.tar.bz2
One of the outstanding TODO items from our fix to redirect navigations to
offline pages was to switch from the provisional load events to use the newer navigation events. This change switches to the new events, and adds a working test. BUG=591150 Review URL: https://codereview.chromium.org/1754333002 Cr-Commit-Position: refs/heads/master@{#379725} (cherry picked from commit 2ec1dfed7c0e8e9d29ce1c0366321426a8c1b489) Review URL: https://codereview.chromium.org/1829853002 . Cr-Commit-Position: refs/branch-heads/2661@{#363} Cr-Branched-From: ef6f6ae5e4c96622286b563658d5cd62a6cf1197-refs/heads/master@{#378081}
-rw-r--r--chrome/browser/android/offline_pages/offline_page_tab_helper.cc16
-rw-r--r--chrome/browser/android/offline_pages/offline_page_tab_helper.h8
-rw-r--r--chrome/browser/android/offline_pages/offline_page_tab_helper_unittest.cc12
3 files changed, 16 insertions, 20 deletions
diff --git a/chrome/browser/android/offline_pages/offline_page_tab_helper.cc b/chrome/browser/android/offline_pages/offline_page_tab_helper.cc
index c0e6e3b..713d241 100644
--- a/chrome/browser/android/offline_pages/offline_page_tab_helper.cc
+++ b/chrome/browser/android/offline_pages/offline_page_tab_helper.cc
@@ -61,18 +61,14 @@ void OfflinePageTabHelper::DidStartNavigation(
online_url));
}
-void OfflinePageTabHelper::DidFailProvisionalLoad(
- content::RenderFrameHost* render_frame_host,
- const GURL& validated_url,
- int error_code,
- const base::string16& error_description,
- bool was_ignored_by_handler) {
+void OfflinePageTabHelper::DidFinishNavigation(
+ content::NavigationHandle* navigation_handle) {
GURL last_redirect_from_url_copy = last_redirect_from_url_;
last_redirect_from_url_ = GURL();
// Skips non-main frame or load failure other than no network.
- if (error_code != net::ERR_INTERNET_DISCONNECTED ||
- render_frame_host->GetParent() != nullptr) {
+ if (navigation_handle->GetNetErrorCode() != net::ERR_INTERNET_DISCONNECTED ||
+ !navigation_handle->IsInMainFrame()) {
return;
}
@@ -83,14 +79,14 @@ void OfflinePageTabHelper::DidFailProvisionalLoad(
// Skips if not loading an online version of saved page.
GURL offline_url = offline_pages::OfflinePageUtils::GetOfflineURLForOnlineURL(
- web_contents()->GetBrowserContext(), validated_url);
+ web_contents()->GetBrowserContext(), navigation_handle->GetURL());
if (!offline_url.is_valid())
return;
// Avoids looping between online and offline redirections.
if (last_redirect_from_url_copy == offline_url)
return;
- last_redirect_from_url_ = validated_url;
+ last_redirect_from_url_ = navigation_handle->GetURL();
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE,
diff --git a/chrome/browser/android/offline_pages/offline_page_tab_helper.h b/chrome/browser/android/offline_pages/offline_page_tab_helper.h
index 2339197..041e510 100644
--- a/chrome/browser/android/offline_pages/offline_page_tab_helper.h
+++ b/chrome/browser/android/offline_pages/offline_page_tab_helper.h
@@ -33,12 +33,8 @@ class OfflinePageTabHelper :
// Overridden from content::WebContentsObserver:
void DidStartNavigation(
content::NavigationHandle* navigation_handle) override;
- void DidFailProvisionalLoad(
- content::RenderFrameHost* render_frame_host,
- const GURL& validated_url,
- int error_code,
- const base::string16& error_description,
- bool was_ignored_by_handler) override;
+ void DidFinishNavigation(
+ content::NavigationHandle* navigation_handle) override;
void RedirectFromOfflineToOnline(const GURL& online_url);
void RedirectFromOnlineToOffline(const GURL& offline_url);
diff --git a/chrome/browser/android/offline_pages/offline_page_tab_helper_unittest.cc b/chrome/browser/android/offline_pages/offline_page_tab_helper_unittest.cc
index 3501f0e..1cb58a3 100644
--- a/chrome/browser/android/offline_pages/offline_page_tab_helper_unittest.cc
+++ b/chrome/browser/android/offline_pages/offline_page_tab_helper_unittest.cc
@@ -133,13 +133,17 @@ void OfflinePageTabHelperTest::StartLoad(const GURL& url) {
void OfflinePageTabHelperTest::CommitLoad(const GURL& url) {
int entry_id = controller().GetPendingEntry()->GetUniqueID();
- content::RenderFrameHostTester::For(main_rfh())->SendNavigate(
- 0, entry_id, true, url);
+ content::RenderFrameHostTester::For(main_rfh())
+ ->SendNavigate(0, entry_id, true, url);
}
void OfflinePageTabHelperTest::FailLoad(const GURL& url) {
- content::RenderFrameHostTester::For(main_rfh())->SimulateNavigationError(
- url, net::ERR_INTERNET_DISCONNECTED);
+ content::RenderFrameHostTester::For(main_rfh())->SimulateNavigationStart(url);
+ // Set up the error code for the failed navigation.
+ content::RenderFrameHostTester::For(main_rfh())->
+ SimulateNavigationError(url, net::ERR_INTERNET_DISCONNECTED);
+ content::RenderFrameHostTester::For(main_rfh())->
+ SimulateNavigationErrorPageCommit();
// Gives a chance to run delayed task to do redirection.
RunUntilIdle();
}