OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef IOS_CHROME_BROWSER_READING_LIST_READING_LIST_WEB_STATE_OBSERVER_H_ | |
6 #define IOS_CHROME_BROWSER_READING_LIST_READING_LIST_WEB_STATE_OBSERVER_H_ | |
7 | |
8 #include "base/macros.h" | |
9 #include "base/timer/timer.h" | |
10 #include "ios/web/public/web_state/web_state_observer.h" | |
11 #include "ios/web/public/web_state/web_state_user_data.h" | |
12 | |
13 class BrowserState; | |
14 class ReadingListModel; | |
15 | |
16 // Observes the loading of pages coming from the reading list and determines | |
17 // whether and loading an offline version of the page is needed. | |
18 class ReadingListWebStateObserver | |
19 : public web::WebStateUserData<ReadingListWebStateObserver>, | |
20 public web::WebStateObserver { | |
21 public: | |
22 static void CreateForWebState(web::WebState* web_state, | |
gambard
2016/10/03 09:04:45
Comment?
| |
23 web::BrowserState* browser_state); | |
24 | |
25 ~ReadingListWebStateObserver() override; | |
26 | |
27 private: | |
28 explicit ReadingListWebStateObserver(web::WebState* web_state, | |
29 web::BrowserState* browser_state); | |
30 friend class WebStateUserData<ReadingListWebStateObserver>; | |
31 | |
32 // WebContentsObserver implementation. | |
gambard
2016/10/03 09:04:45
Are you sure it is WebContentsObserver? You do not
| |
33 void NavigationItemChanged() override; | |
gambard
2016/10/03 09:04:45
Those methods are public in WebStateObserver
| |
34 void NavigationItemCommitted( | |
35 const web::LoadCommittedDetails& load_details) override; | |
36 void DidStartLoading() override; | |
37 void DidStopLoading() override; | |
38 void PageLoaded( | |
39 web::PageLoadCompletionStatus load_completion_status) override; | |
40 void WebStateDestroyed() override; | |
41 | |
42 private: | |
gambard
2016/10/03 09:04:45
2 "private:"?
| |
43 // Heuristically determine if the reading list entry is loading quickly. | |
44 // If it doesn't load quickly, tries to load an offline version of the page. | |
45 void VerifyIfReadingListEntryStartedLoading(); | |
46 | |
47 web::WebState* web_state_; | |
48 ReadingListModel* reading_list_model_; | |
49 std::unique_ptr<base::Timer> timer_; | |
50 | |
51 DISALLOW_COPY_AND_ASSIGN(ReadingListWebStateObserver); | |
52 }; | |
53 | |
54 #endif // IOS_CHROME_BROWSER_READING_LIST_READING_LIST_WEB_STATE_OBSERVER_H_ | |
OLD | NEW |