Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(76)

Side by Side Diff: ios/chrome/browser/sync/ios_chrome_sync_client.mm

Issue 2753753005: [sync] WebContentsObserver based sessions notifications (Closed)
Patch Set: Separate non-android class Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_sync_client.h" 5 #include "ios/chrome/browser/sync/ios_chrome_sync_client.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 namespace { 73 namespace {
74 74
75 // iOS implementation of SyncSessionsClient. Needs to be in a separate class 75 // iOS implementation of SyncSessionsClient. Needs to be in a separate class
76 // due to possible multiple inheritance issues, wherein IOSChromeSyncClient 76 // due to possible multiple inheritance issues, wherein IOSChromeSyncClient
77 // might inherit from other interfaces with same methods. 77 // might inherit from other interfaces with same methods.
78 class SyncSessionsClientImpl : public sync_sessions::SyncSessionsClient { 78 class SyncSessionsClientImpl : public sync_sessions::SyncSessionsClient {
79 public: 79 public:
80 explicit SyncSessionsClientImpl(ios::ChromeBrowserState* browser_state) 80 explicit SyncSessionsClientImpl(ios::ChromeBrowserState* browser_state)
81 : browser_state_(browser_state), 81 : browser_state_(browser_state),
82 window_delegates_getter_( 82 window_delegates_getter_(
83 base::MakeUnique<TabModelSyncedWindowDelegatesGetter>()) {} 83 base::MakeUnique<TabModelSyncedWindowDelegatesGetter>()),
84 local_session_event_router_(
85 base::MakeUnique<IOSChromeLocalSessionEventRouter>(
86 browser_state_,
87 this,
88 ios::sync_start_util::GetFlareForSyncableService(
89 browser_state_->GetStatePath()))) {}
84 90
85 ~SyncSessionsClientImpl() override {} 91 ~SyncSessionsClientImpl() override {}
86 92
87 // SyncSessionsClient implementation. 93 // SyncSessionsClient implementation.
88 bookmarks::BookmarkModel* GetBookmarkModel() override { 94 bookmarks::BookmarkModel* GetBookmarkModel() override {
89 DCHECK_CURRENTLY_ON(web::WebThread::UI); 95 DCHECK_CURRENTLY_ON(web::WebThread::UI);
90 return ios::BookmarkModelFactory::GetForBrowserState(browser_state_); 96 return ios::BookmarkModelFactory::GetForBrowserState(browser_state_);
91 } 97 }
92 98
93 favicon::FaviconService* GetFaviconService() override { 99 favicon::FaviconService* GetFaviconService() override {
(...skipping 16 matching lines...) Expand all
110 } 116 }
111 return url.is_valid() && !url.SchemeIs(kChromeUIScheme) && 117 return url.is_valid() && !url.SchemeIs(kChromeUIScheme) &&
112 !url.SchemeIsFile(); 118 !url.SchemeIsFile();
113 } 119 }
114 120
115 sync_sessions::SyncedWindowDelegatesGetter* GetSyncedWindowDelegatesGetter() 121 sync_sessions::SyncedWindowDelegatesGetter* GetSyncedWindowDelegatesGetter()
116 override { 122 override {
117 return window_delegates_getter_.get(); 123 return window_delegates_getter_.get();
118 } 124 }
119 125
120 std::unique_ptr<sync_sessions::LocalSessionEventRouter> 126 sync_sessions::LocalSessionEventRouter* GetLocalSessionEventRouter()
121 GetLocalSessionEventRouter() override { 127 override {
122 syncer::SyncableService::StartSyncFlare flare( 128 return local_session_event_router_.get();
123 ios::sync_start_util::GetFlareForSyncableService(
124 browser_state_->GetStatePath()));
125 return base::MakeUnique<IOSChromeLocalSessionEventRouter>(browser_state_,
126 this, flare);
127 } 129 }
128 130
129 private: 131 private:
130 ios::ChromeBrowserState* const browser_state_; 132 ios::ChromeBrowserState* const browser_state_;
131 const std::unique_ptr<sync_sessions::SyncedWindowDelegatesGetter> 133 const std::unique_ptr<sync_sessions::SyncedWindowDelegatesGetter>
132 window_delegates_getter_; 134 window_delegates_getter_;
135 const std::unique_ptr<IOSChromeLocalSessionEventRouter>
136 local_session_event_router_;
133 137
134 DISALLOW_COPY_AND_ASSIGN(SyncSessionsClientImpl); 138 DISALLOW_COPY_AND_ASSIGN(SyncSessionsClientImpl);
135 }; 139 };
136 140
137 } // namespace 141 } // namespace
138 142
139 IOSChromeSyncClient::IOSChromeSyncClient(ios::ChromeBrowserState* browser_state) 143 IOSChromeSyncClient::IOSChromeSyncClient(ios::ChromeBrowserState* browser_state)
140 : browser_state_(browser_state), 144 : browser_state_(browser_state),
141 sync_sessions_client_( 145 sync_sessions_client_(
142 base::MakeUnique<SyncSessionsClientImpl>(browser_state)), 146 base::MakeUnique<SyncSessionsClientImpl>(browser_state)),
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 IOSChromeProfileSyncServiceFactory::GetForBrowserState(browser_state); 429 IOSChromeProfileSyncServiceFactory::GetForBrowserState(browser_state);
426 if (profile_sync_service != nullptr) { 430 if (profile_sync_service != nullptr) {
427 const syncer::DeviceInfoTracker* tracker = 431 const syncer::DeviceInfoTracker* tracker =
428 profile_sync_service->GetDeviceInfoTracker(); 432 profile_sync_service->GetDeviceInfoTracker();
429 if (tracker != nullptr) { 433 if (tracker != nullptr) {
430 trackers->push_back(tracker); 434 trackers->push_back(tracker);
431 } 435 }
432 } 436 }
433 } 437 }
434 } 438 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698