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 |
new file mode 100644 |
index 0000000000000000000000000000000000000000..102e1e72f83028348f9df76fe65f0dda777a0bf0 |
--- /dev/null |
+++ b/ios/chrome/browser/reading_list/reading_list_web_state_observer.h |
@@ -0,0 +1,54 @@ |
+// Copyright 2016 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef IOS_CHROME_BROWSER_READING_LIST_READING_LIST_WEB_STATE_OBSERVER_H_ |
+#define IOS_CHROME_BROWSER_READING_LIST_READING_LIST_WEB_STATE_OBSERVER_H_ |
+ |
+#include "base/macros.h" |
+#include "base/timer/timer.h" |
+#include "ios/web/public/web_state/web_state_observer.h" |
+#include "ios/web/public/web_state/web_state_user_data.h" |
+ |
+class BrowserState; |
+class ReadingListModel; |
+ |
+// Observes the loading of pages coming from the reading list and determines |
+// whether and loading an offline version of the page is needed. |
+class ReadingListWebStateObserver |
+ : public web::WebStateUserData<ReadingListWebStateObserver>, |
+ public web::WebStateObserver { |
+ public: |
+ static void CreateForWebState(web::WebState* web_state, |
gambard
2016/10/03 09:04:45
Comment?
|
+ web::BrowserState* browser_state); |
+ |
+ ~ReadingListWebStateObserver() override; |
+ |
+ private: |
+ explicit ReadingListWebStateObserver(web::WebState* web_state, |
+ web::BrowserState* browser_state); |
+ friend class WebStateUserData<ReadingListWebStateObserver>; |
+ |
+ // WebContentsObserver implementation. |
gambard
2016/10/03 09:04:45
Are you sure it is WebContentsObserver? You do not
|
+ void NavigationItemChanged() override; |
gambard
2016/10/03 09:04:45
Those methods are public in WebStateObserver
|
+ void NavigationItemCommitted( |
+ const web::LoadCommittedDetails& load_details) override; |
+ void DidStartLoading() override; |
+ void DidStopLoading() override; |
+ void PageLoaded( |
+ web::PageLoadCompletionStatus load_completion_status) override; |
+ void WebStateDestroyed() override; |
+ |
+ private: |
gambard
2016/10/03 09:04:45
2 "private:"?
|
+ // Heuristically determine if the reading list entry is loading quickly. |
+ // If it doesn't load quickly, tries to load an offline version of the page. |
+ void VerifyIfReadingListEntryStartedLoading(); |
+ |
+ web::WebState* web_state_; |
+ ReadingListModel* reading_list_model_; |
+ std::unique_ptr<base::Timer> timer_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(ReadingListWebStateObserver); |
+}; |
+ |
+#endif // IOS_CHROME_BROWSER_READING_LIST_READING_LIST_WEB_STATE_OBSERVER_H_ |