Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(129)

Unified Diff: ios/chrome/browser/ui/reading_list/offline_page_native_content.mm

Issue 2578973002: Reload offline version on load failure (Closed)
Patch Set: rebase + const Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ios/chrome/browser/ui/reading_list/offline_page_native_content.mm
diff --git a/ios/chrome/browser/ui/reading_list/offline_page_native_content.mm b/ios/chrome/browser/ui/reading_list/offline_page_native_content.mm
index 90454c15ab4c6c570898fd7bcbc79058a0b4f49e..4f2c0fc7a9ada2926c0b89ccd5039d2e4619a499 100644
--- a/ios/chrome/browser/ui/reading_list/offline_page_native_content.mm
+++ b/ios/chrome/browser/ui/reading_list/offline_page_native_content.mm
@@ -10,18 +10,21 @@
#include "components/reading_list/ios/reading_list_model.h"
#include "ios/chrome/browser/browser_state/chrome_browser_state.h"
#include "ios/chrome/browser/reading_list/offline_url_utils.h"
-#include "ios/chrome/browser/reading_list/reading_list_entry_loading_util.h"
#include "ios/chrome/browser/reading_list/reading_list_model_factory.h"
#import "ios/chrome/browser/ui/static_content/static_html_view_controller.h"
#include "ios/web/public/browser_state.h"
-#include "net/base/network_change_notifier.h"
+#import "ios/web/public/navigation_item.h"
+#import "ios/web/public/navigation_manager.h"
+#import "ios/web/public/web_state/web_state.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
-#pragma mark -
-#pragma mark Public
+@interface OfflinePageNativeContent ()
+// Restores the last committed item to its initial state.
+- (void)restoreOnlineURL;
+@end
@implementation OfflinePageNativeContent {
// The virtual URL that will be displayed to the user.
@@ -62,21 +65,29 @@
URL:URL];
}
+- (void)willBeDismissed {
+ [self restoreOnlineURL];
+}
+
+- (void)close {
+ [self restoreOnlineURL];
+ [super close];
+}
+
- (GURL)virtualURL {
return _virtualURL;
}
- (void)reload {
- if (!_model || net::NetworkChangeNotifier::IsOffline()) {
- [super reload];
- return;
- }
- const ReadingListEntry* entry = _model->GetEntryByURL([self virtualURL]);
- if (entry) {
- reading_list::LoadReadingListEntry(*entry, _model, _webState);
- } else {
- [super reload];
- }
+ [self restoreOnlineURL];
+ _webState->GetNavigationManager()->Reload(false);
+}
+
+- (void)restoreOnlineURL {
+ web::NavigationItem* item =
+ _webState->GetNavigationManager()->GetLastCommittedItem();
+ item->SetURL([self virtualURL]);
+ item->SetVirtualURL([self virtualURL]);
}
@end
« no previous file with comments | « ios/chrome/browser/tabs/tab.mm ('k') | ios/chrome/browser/ui/reading_list/reading_list_side_swipe_provider.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698