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
3 // found in the LICENSE file.
5 #include "chrome/browser/sync/glue/synced_window_delegates_getter_android.h"
7 #include "chrome/browser/ui/android/tab_model/tab_model.h"
8 #include "chrome/browser/ui/android/tab_model/tab_model_list.h"
9 #include "components/sync_driver/glue/synced_window_delegate.h"
11 namespace browser_sync
{
13 SyncedWindowDelegatesGetterAndroid::SyncedWindowDelegatesGetterAndroid() {}
14 SyncedWindowDelegatesGetterAndroid::~SyncedWindowDelegatesGetterAndroid() {}
16 std::set
<const SyncedWindowDelegate
*>
17 SyncedWindowDelegatesGetterAndroid::GetSyncedWindowDelegates() {
18 std::set
<SyncedWindowDelegate
const*> synced_window_delegates
;
19 for (auto i
= TabModelList::begin(); i
!= TabModelList::end(); ++i
) {
20 synced_window_delegates
.insert((*i
)->GetSyncedWindowDelegate());
22 return synced_window_delegates
;
25 const SyncedWindowDelegate
* SyncedWindowDelegatesGetterAndroid::FindById(
26 SessionID::id_type session_id
) {
27 TabModel
* tab_model
= TabModelList::FindTabModelWithId(session_id
);
29 // In case we don't find the browser (e.g. for Developer Tools).
30 return tab_model
? tab_model
->GetSyncedWindowDelegate() : nullptr;
33 } // namespace browser_sync