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 #include "ios/chrome/browser/sync/ios_chrome_synced_tab_delegate.h" | 5 #include "ios/chrome/browser/sync/ios_chrome_synced_tab_delegate.h" |
6 | 6 |
7 #include "base/memory/ref_counted.h" | 7 #include "base/memory/ref_counted.h" |
8 #include "components/sessions/ios/ios_serialized_navigation_builder.h" | 8 #include "components/sessions/ios/ios_serialized_navigation_builder.h" |
9 #include "components/sync_sessions/sync_sessions_client.h" | 9 #include "components/sync_sessions/sync_sessions_client.h" |
10 #include "components/sync_sessions/synced_window_delegate.h" | 10 #include "components/sync_sessions/synced_window_delegate.h" |
11 #include "components/sync_sessions/synced_window_delegates_getter.h" | 11 #include "components/sync_sessions/synced_window_delegates_getter.h" |
| 12 #include "components/sync_sessions/tab_node_pool.h" |
12 #include "ios/chrome/browser/sessions/ios_chrome_session_tab_helper.h" | 13 #include "ios/chrome/browser/sessions/ios_chrome_session_tab_helper.h" |
13 #include "ios/web/public/favicon_status.h" | 14 #include "ios/web/public/favicon_status.h" |
14 #include "ios/web/public/navigation_item.h" | 15 #include "ios/web/public/navigation_item.h" |
15 #import "ios/web/public/navigation_manager.h" | 16 #import "ios/web/public/navigation_manager.h" |
16 #include "ios/web/public/web_state/web_state.h" | 17 #include "ios/web/public/web_state/web_state.h" |
17 | 18 |
18 #if !defined(__has_feature) || !__has_feature(objc_arc) | 19 #if !defined(__has_feature) || !__has_feature(objc_arc) |
19 #error "This file requires ARC support." | 20 #error "This file requires ARC support." |
20 #endif | 21 #endif |
21 | 22 |
22 using web::NavigationItem; | 23 using web::NavigationItem; |
23 | 24 |
24 DEFINE_WEB_STATE_USER_DATA_KEY(IOSChromeSyncedTabDelegate); | 25 DEFINE_WEB_STATE_USER_DATA_KEY(IOSChromeSyncedTabDelegate); |
25 | 26 |
26 namespace { | 27 namespace { |
27 | 28 |
28 // Helper to access the correct NavigationItem, accounting for pending entries. | 29 // Helper to access the correct NavigationItem, accounting for pending entries. |
29 NavigationItem* GetPossiblyPendingItemAtIndex(web::WebState* web_state, int i) { | 30 NavigationItem* GetPossiblyPendingItemAtIndex(web::WebState* web_state, int i) { |
30 int pending_index = web_state->GetNavigationManager()->GetPendingItemIndex(); | 31 int pending_index = web_state->GetNavigationManager()->GetPendingItemIndex(); |
31 return (pending_index == i) | 32 return (pending_index == i) |
32 ? web_state->GetNavigationManager()->GetPendingItem() | 33 ? web_state->GetNavigationManager()->GetPendingItem() |
33 : web_state->GetNavigationManager()->GetItemAtIndex(i); | 34 : web_state->GetNavigationManager()->GetItemAtIndex(i); |
34 } | 35 } |
35 | 36 |
36 } // namespace | 37 } // namespace |
37 | 38 |
38 IOSChromeSyncedTabDelegate::IOSChromeSyncedTabDelegate(web::WebState* web_state) | 39 IOSChromeSyncedTabDelegate::IOSChromeSyncedTabDelegate(web::WebState* web_state) |
39 : web_state_(web_state), sync_session_id_(0) {} | 40 : web_state_(web_state), |
| 41 sync_session_id_(sync_sessions::TabNodePool::kInvalidTabNodeID) {} |
40 | 42 |
41 IOSChromeSyncedTabDelegate::~IOSChromeSyncedTabDelegate() {} | 43 IOSChromeSyncedTabDelegate::~IOSChromeSyncedTabDelegate() {} |
42 | 44 |
43 SessionID::id_type IOSChromeSyncedTabDelegate::GetWindowId() const { | 45 SessionID::id_type IOSChromeSyncedTabDelegate::GetWindowId() const { |
44 return IOSChromeSessionTabHelper::FromWebState(web_state_)->window_id().id(); | 46 return IOSChromeSessionTabHelper::FromWebState(web_state_)->window_id().id(); |
45 } | 47 } |
46 | 48 |
47 SessionID::id_type IOSChromeSyncedTabDelegate::GetSessionId() const { | 49 SessionID::id_type IOSChromeSyncedTabDelegate::GetSessionId() const { |
48 return IOSChromeSessionTabHelper::FromWebState(web_state_)->session_id().id(); | 50 return IOSChromeSessionTabHelper::FromWebState(web_state_)->session_id().id(); |
49 } | 51 } |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 for (int i = 0; i < entry_count; ++i) { | 135 for (int i = 0; i < entry_count; ++i) { |
134 const GURL& virtual_url = GetVirtualURLAtIndex(i); | 136 const GURL& virtual_url = GetVirtualURLAtIndex(i); |
135 if (!virtual_url.is_valid()) | 137 if (!virtual_url.is_valid()) |
136 continue; | 138 continue; |
137 | 139 |
138 if (sessions_client->ShouldSyncURL(virtual_url)) | 140 if (sessions_client->ShouldSyncURL(virtual_url)) |
139 return true; | 141 return true; |
140 } | 142 } |
141 return false; | 143 return false; |
142 } | 144 } |
OLD | NEW |