OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef IOS_CHROME_BROWSER_SYNC_SESSIONS_IOS_CHROME_LOCAL_EVENT_SESSION_ROUTER_H
_ | 5 #ifndef IOS_CHROME_BROWSER_SYNC_SESSIONS_IOS_CHROME_LOCAL_SESSION_EVENT_ROUTER_H
_ |
6 #define IOS_CHROME_BROWSER_SYNC_SESSIONS_IOS_CHROME_LOCAL_EVENT_SESSION_ROUTER_H
_ | 6 #define IOS_CHROME_BROWSER_SYNC_SESSIONS_IOS_CHROME_LOCAL_SESSION_EVENT_ROUTER_H
_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
11 #include <set> | 11 #include <set> |
12 | 12 |
13 #include "base/callback_list.h" | 13 #include "base/callback_list.h" |
14 #include "base/macros.h" | 14 #include "base/macros.h" |
15 #include "components/sync/api/syncable_service.h" | 15 #include "components/sync/api/syncable_service.h" |
16 #include "components/sync_sessions/local_session_event_router.h" | 16 #include "components/sync_sessions/local_session_event_router.h" |
17 #include "ios/web/public/web_state/global_web_state_observer.h" | 17 #include "ios/web/public/web_state/global_web_state_observer.h" |
18 | 18 |
19 class GURL; | 19 class GURL; |
20 | 20 |
21 namespace ios { | 21 namespace ios { |
22 class ChromeBrowserState; | 22 class ChromeBrowserState; |
23 } | 23 } |
24 | 24 |
25 namespace sync_sessions { | 25 namespace sync_sessions { |
26 class SyncSessionsClient; | 26 class SyncSessionsClient; |
27 } | 27 } |
28 | 28 |
29 // A LocalEventRouter that drives session sync via observation of | 29 // A LocalEventRouter that drives session sync via observation of |
30 // web::WebState-related events. | 30 // web::WebState-related events. |
31 class IOSChromeLocalSessionEventRouter | 31 class IOSChromeLocalSessionEventRouter |
32 : public browser_sync::LocalSessionEventRouter, | 32 : public sync_sessions::LocalSessionEventRouter, |
33 public web::GlobalWebStateObserver { | 33 public web::GlobalWebStateObserver { |
34 public: | 34 public: |
35 IOSChromeLocalSessionEventRouter( | 35 IOSChromeLocalSessionEventRouter( |
36 ios::ChromeBrowserState* browser_state, | 36 ios::ChromeBrowserState* browser_state, |
37 sync_sessions::SyncSessionsClient* sessions_client_, | 37 sync_sessions::SyncSessionsClient* sessions_client_, |
38 const syncer::SyncableService::StartSyncFlare& flare); | 38 const syncer::SyncableService::StartSyncFlare& flare); |
39 ~IOSChromeLocalSessionEventRouter() override; | 39 ~IOSChromeLocalSessionEventRouter() override; |
40 | 40 |
41 // LocalEventRouter: | 41 // LocalEventRouter: |
42 void StartRoutingTo(browser_sync::LocalSessionEventHandler* handler) override; | 42 void StartRoutingTo( |
| 43 sync_sessions::LocalSessionEventHandler* handler) override; |
43 void Stop() override; | 44 void Stop() override; |
44 | 45 |
45 // web::GlobalWebStateObserver: | 46 // web::GlobalWebStateObserver: |
46 void NavigationItemsPruned(web::WebState* web_state, | 47 void NavigationItemsPruned(web::WebState* web_state, |
47 size_t pruned_item_count) override; | 48 size_t pruned_item_count) override; |
48 void NavigationItemChanged(web::WebState* web_state) override; | 49 void NavigationItemChanged(web::WebState* web_state) override; |
49 void NavigationItemCommitted( | 50 void NavigationItemCommitted( |
50 web::WebState* web_state, | 51 web::WebState* web_state, |
51 const web::LoadCommittedDetails& load_details) override; | 52 const web::LoadCommittedDetails& load_details) override; |
52 void PageLoaded( | 53 void PageLoaded( |
53 web::WebState* web_state, | 54 web::WebState* web_state, |
54 web::PageLoadCompletionStatus load_completion_status) override; | 55 web::PageLoadCompletionStatus load_completion_status) override; |
55 void WebStateDestroyed(web::WebState* web_state) override; | 56 void WebStateDestroyed(web::WebState* web_state) override; |
56 | 57 |
57 private: | 58 private: |
58 // Called when a tab is parented. | 59 // Called when a tab is parented. |
59 void OnTabParented(web::WebState* web_state); | 60 void OnTabParented(web::WebState* web_state); |
60 | 61 |
61 // Called on observation of a change in |web_state|. | 62 // Called on observation of a change in |web_state|. |
62 void OnWebStateChange(web::WebState* web_state); | 63 void OnWebStateChange(web::WebState* web_state); |
63 | 64 |
64 // Called when the favicons for the given page URLs | 65 // Called when the favicons for the given page URLs |
65 // (e.g. http://www.google.com) and the given icon URL (e.g. | 66 // (e.g. http://www.google.com) and the given icon URL (e.g. |
66 // http://www.google.com/favicon.ico) have changed. It is valid to call | 67 // http://www.google.com/favicon.ico) have changed. It is valid to call |
67 // OnFaviconsChanged() with non-empty |page_urls| and an empty |icon_url| | 68 // OnFaviconsChanged() with non-empty |page_urls| and an empty |icon_url| |
68 // and vice versa. | 69 // and vice versa. |
69 void OnFaviconsChanged(const std::set<GURL>& page_urls, const GURL& icon_url); | 70 void OnFaviconsChanged(const std::set<GURL>& page_urls, const GURL& icon_url); |
70 | 71 |
71 browser_sync::LocalSessionEventHandler* handler_; | 72 sync_sessions::LocalSessionEventHandler* handler_; |
72 ios::ChromeBrowserState* const browser_state_; | 73 ios::ChromeBrowserState* const browser_state_; |
73 sync_sessions::SyncSessionsClient* const sessions_client_; | 74 sync_sessions::SyncSessionsClient* const sessions_client_; |
74 syncer::SyncableService::StartSyncFlare flare_; | 75 syncer::SyncableService::StartSyncFlare flare_; |
75 | 76 |
76 std::unique_ptr<base::CallbackList<void(const std::set<GURL>&, | 77 std::unique_ptr<base::CallbackList<void(const std::set<GURL>&, |
77 const GURL&)>::Subscription> | 78 const GURL&)>::Subscription> |
78 favicon_changed_subscription_; | 79 favicon_changed_subscription_; |
79 | 80 |
80 std::unique_ptr<base::CallbackList<void(web::WebState*)>::Subscription> | 81 std::unique_ptr<base::CallbackList<void(web::WebState*)>::Subscription> |
81 tab_parented_subscription_; | 82 tab_parented_subscription_; |
82 | 83 |
83 DISALLOW_COPY_AND_ASSIGN(IOSChromeLocalSessionEventRouter); | 84 DISALLOW_COPY_AND_ASSIGN(IOSChromeLocalSessionEventRouter); |
84 }; | 85 }; |
85 | 86 |
86 #endif // IOS_CHROME_BROWSER_SYNC_SESSIONS_IOS_CHROME_LOCAL_EVENT_SESSION_ROUTE
R_H_ | 87 #endif // IOS_CHROME_BROWSER_SYNC_SESSIONS_IOS_CHROME_LOCAL_SESSION_EVENT_ROUTE
R_H_ |
OLD | NEW |