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

Side by Side Diff: ios/chrome/browser/tabs/tab_model_synced_window_delegate_getter.mm

Issue 2585233003: Upstream Chrome on iOS source code [2/11]. (Closed)
Patch Set: Created 4 years 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
(Empty)
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.
4
5 #include "ios/chrome/browser/tabs/tab_model_synced_window_delegate_getter.h"
6
7 #include "ios/chrome/browser/browser_state/chrome_browser_state.h"
8 #include "ios/chrome/browser/tabs/tab_model.h"
9 #import "ios/chrome/browser/tabs/tab_model_synced_window_delegate.h"
10 #import "ios/chrome/browser/ui/browser_list_ios.h"
11
12 TabModelSyncedWindowDelegatesGetter::TabModelSyncedWindowDelegatesGetter(
13 ios::ChromeBrowserState* browser_state)
14 : browser_state_(browser_state) {}
15
16 TabModelSyncedWindowDelegatesGetter::~TabModelSyncedWindowDelegatesGetter() {}
17
18 std::set<const sync_sessions::SyncedWindowDelegate*>
19 TabModelSyncedWindowDelegatesGetter::GetSyncedWindowDelegates() {
20 std::set<const sync_sessions::SyncedWindowDelegate*> synced_window_delegates;
21
22 for (BrowserListIOS::const_iterator iter = BrowserListIOS::begin();
23 iter != BrowserListIOS::end(); ++iter) {
24 id<BrowserIOS> browser = *iter;
25 TabModel* tabModel = [browser tabModel];
26 // TODO(crbug.com/548612): BrowserState may be unnecessary as iOS does not
27 // support multiple profiles starting with M47. There should still be a way
28 // to filter out Incognito delegates, though.
29 if (tabModel.browserState != browser_state_)
30 continue;
31 // Do not return windows without any tabs, to match desktop.
32 if ([tabModel currentTab])
33 synced_window_delegates.insert([tabModel syncedWindowDelegate]);
34 }
35
36 return synced_window_delegates;
37 }
38
39 const sync_sessions::SyncedWindowDelegate*
40 TabModelSyncedWindowDelegatesGetter::FindById(SessionID::id_type session_id) {
41 for (const sync_sessions::SyncedWindowDelegate* delegate :
42 GetSyncedWindowDelegates()) {
43 if (session_id == delegate->GetSessionId())
44 return delegate;
45 }
46 return nullptr;
47 }
OLDNEW
« no previous file with comments | « ios/chrome/browser/tabs/tab_model_synced_window_delegate_getter.h ('k') | ios/chrome/browser/tabs/tab_model_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698