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

Unified Diff: ios/chrome/browser/reading_list/reading_list_web_state_observer.h

Issue 2578973002: Reload offline version on load failure (Closed)
Patch Set: clean 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/reading_list/reading_list_web_state_observer.h
diff --git a/ios/chrome/browser/reading_list/reading_list_web_state_observer.h b/ios/chrome/browser/reading_list/reading_list_web_state_observer.h
index 47fcfb6f9aa4c0075e442c5ac0b852bb6dfc376f..d527bd4d360c7a51082aba3db77200ea61bc33ae 100644
--- a/ios/chrome/browser/reading_list/reading_list_web_state_observer.h
+++ b/ios/chrome/browser/reading_list/reading_list_web_state_observer.h
@@ -12,6 +12,17 @@
class ReadingListModel;
+@protocol ReadingListWebStateObserverDelegate
+
+// Tells the delegate the the loading of the online version failed and the
+// offline version must be displayed.
+- (void)displayOfflineVersionForURL:(const GURL&)URL;
+
+@end
+
+typedef id<ReadingListWebStateObserverDelegate>
+ ReadingListWebStateObserverDelegateType;
+
// Observes the loading of pages coming from the reading list, determines
// whether loading an offline version of the page is needed, and actually
// trigger the loading of the offline page (if possible).
@@ -19,7 +30,8 @@ class ReadingListWebStateObserver : public web::WebStateObserver {
public:
static ReadingListWebStateObserver* FromWebState(
web::WebState* web_state,
- ReadingListModel* reading_list_model);
+ ReadingListModel* reading_list_model,
+ ReadingListWebStateObserverDelegateType delegate);
~ReadingListWebStateObserver() override;
@@ -33,7 +45,8 @@ class ReadingListWebStateObserver : public web::WebStateObserver {
private:
ReadingListWebStateObserver(web::WebState* web_state,
- ReadingListModel* reading_list_model);
+ ReadingListModel* reading_list_model,
+ ReadingListWebStateObserverDelegateType delegate);
// Looks at the loading percentage. If less than 15%, attemps to load the
// offline version of that page.
@@ -46,15 +59,18 @@ class ReadingListWebStateObserver : public web::WebStateObserver {
void StopCheckingProgress();
// WebContentsObserver implementation.
- void DidStopLoading() override;
+ void DidStartLoading() override;
void PageLoaded(
web::PageLoadCompletionStatus load_completion_status) override;
void WebStateDestroyed() override;
+ void LoadReadingListDistilled();
+
ReadingListModel* reading_list_model_;
std::unique_ptr<base::Timer> timer_;
GURL pending_url_;
int try_number_;
+ ReadingListWebStateObserverDelegateType delegate_;
DISALLOW_COPY_AND_ASSIGN(ReadingListWebStateObserver);
};

Powered by Google App Engine
This is Rietveld 408576698