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..1c16afed1ccfe4624596a719084ee81853c1588f 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,10 @@ |
class ReadingListModel; |
+namespace web { |
+class NavigationItem; |
+} |
+ |
// 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). |
@@ -23,34 +27,44 @@ class ReadingListWebStateObserver : public web::WebStateObserver { |
~ReadingListWebStateObserver() override; |
- // Starts checking that the current navigation is loading quickly enough [1]. |
- // If not, starts to load a distilled version of the page (if there is any). |
- // If that same WebStateObserver was already checking that a page was loading |
- // quickly enough, stops checking the loading of that page. |
- // [1] A page loading quickly enough is a page that has loaded 15% within |
- // 1 second. |
- void StartCheckingProgress(const GURL& pending_url); |
- |
private: |
ReadingListWebStateObserver(web::WebState* web_state, |
ReadingListModel* reading_list_model); |
- // Looks at the loading percentage. If less than 15%, attemps to load the |
- // offline version of that page. |
+ // Looks at the loading percentage. If less than 25% * time, attemps to load |
+ // the offline version of that page. |
+ // |time| is the number of seconds since |StartCheckingProgress| was called. |
void VerifyIfReadingListEntryStartedLoading(); |
friend class ReadingListWebStateObserverUserDataWrapper; |
- // Stop checking the loading of the |pending_url_|. |
+ // Stops checking the loading of the |pending_url_|. |
// The WebState will still be observed, but no action will be done on events. |
void StopCheckingProgress(); |
+ // Loads the offline version of the URL in place of the current page. |
+ void LoadOfflineReadingListEntry(web::NavigationItem* item); |
+ |
+ // Returns if the current page with |url| has an offline version that can be |
+ // displayed if the normal loading fails. |
+ bool IsUrlAvailableOffline(const GURL& url) const; |
+ |
+ // Checks if |item| should be observed or not. |
+ // A non-null item should be observed if it is not already loading an offline |
+ // URL. |
+ bool ShouldObserveItem(web::NavigationItem* item) const; |
+ |
// WebContentsObserver implementation. |
- void DidStopLoading() override; |
void PageLoaded( |
web::PageLoadCompletionStatus load_completion_status) override; |
void WebStateDestroyed() override; |
+ // Starts checking that the current navigation is loading quickly enough [1]. |
+ // If not, starts to load a distilled version of the page (if there is any). |
+ // [1] A page loading quickly enough is a page that has loaded 25% within |
+ // 1 second, 50% within 2 seconds and 75% within 3 seconds. |
+ void DidStartLoading() override; |
+ |
ReadingListModel* reading_list_model_; |
std::unique_ptr<base::Timer> timer_; |
GURL pending_url_; |