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

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

Issue 2628273004: Revert of Use ChromeBrowserStateManager instead of BrowserListIOS. (Closed)
Patch Set: Created 3 years, 11 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/tabs/tab_model_synced_window_delegate_getter.h" 5 #include "ios/chrome/browser/tabs/tab_model_synced_window_delegate_getter.h"
6 6
7 #include "base/logging.h"
8 #include "ios/chrome/browser/application_context.h"
9 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" 7 #include "ios/chrome/browser/browser_state/chrome_browser_state.h"
10 #include "ios/chrome/browser/browser_state/chrome_browser_state_manager.h" 8 #include "ios/chrome/browser/tabs/tab_model.h"
11 #import "ios/chrome/browser/tabs/tab_model.h"
12 #import "ios/chrome/browser/tabs/tab_model_list.h"
13 #import "ios/chrome/browser/tabs/tab_model_synced_window_delegate.h" 9 #import "ios/chrome/browser/tabs/tab_model_synced_window_delegate.h"
10 #import "ios/chrome/browser/ui/browser_list_ios.h"
14 11
15 TabModelSyncedWindowDelegatesGetter::TabModelSyncedWindowDelegatesGetter() {} 12 TabModelSyncedWindowDelegatesGetter::TabModelSyncedWindowDelegatesGetter(
13 ios::ChromeBrowserState* browser_state)
14 : browser_state_(browser_state) {}
16 15
17 TabModelSyncedWindowDelegatesGetter::~TabModelSyncedWindowDelegatesGetter() {} 16 TabModelSyncedWindowDelegatesGetter::~TabModelSyncedWindowDelegatesGetter() {}
18 17
19 std::set<const sync_sessions::SyncedWindowDelegate*> 18 std::set<const sync_sessions::SyncedWindowDelegate*>
20 TabModelSyncedWindowDelegatesGetter::GetSyncedWindowDelegates() { 19 TabModelSyncedWindowDelegatesGetter::GetSyncedWindowDelegates() {
21 std::set<const sync_sessions::SyncedWindowDelegate*> synced_window_delegates; 20 std::set<const sync_sessions::SyncedWindowDelegate*> synced_window_delegates;
22 21
23 std::vector<ios::ChromeBrowserState*> browser_states = 22 for (BrowserListIOS::const_iterator iter = BrowserListIOS::begin();
24 GetApplicationContext() 23 iter != BrowserListIOS::end(); ++iter) {
25 ->GetChromeBrowserStateManager() 24 id<BrowserIOS> browser = *iter;
26 ->GetLoadedBrowserStates(); 25 TabModel* tabModel = [browser tabModel];
27 26 // TODO(crbug.com/548612): BrowserState may be unnecessary as iOS does not
28 for (auto* browser_state : browser_states) { 27 // support multiple profiles starting with M47. There should still be a way
29 DCHECK(!browser_state->IsOffTheRecord()); 28 // to filter out Incognito delegates, though.
30 NSArray<TabModel*>* tabModels = 29 if (tabModel.browserState != browser_state_)
31 GetTabModelsForChromeBrowserState(browser_state); 30 continue;
32 for (TabModel* tabModel in tabModels) { 31 // Do not return windows without any tabs, to match desktop.
33 if (tabModel.currentTab) { 32 if ([tabModel currentTab])
34 synced_window_delegates.insert([tabModel syncedWindowDelegate]); 33 synced_window_delegates.insert([tabModel syncedWindowDelegate]);
35 }
36 }
37 } 34 }
38 35
39 return synced_window_delegates; 36 return synced_window_delegates;
40 } 37 }
41 38
42 const sync_sessions::SyncedWindowDelegate* 39 const sync_sessions::SyncedWindowDelegate*
43 TabModelSyncedWindowDelegatesGetter::FindById(SessionID::id_type session_id) { 40 TabModelSyncedWindowDelegatesGetter::FindById(SessionID::id_type session_id) {
44 for (const auto* delegate : GetSyncedWindowDelegates()) { 41 for (const sync_sessions::SyncedWindowDelegate* delegate :
42 GetSyncedWindowDelegates()) {
45 if (session_id == delegate->GetSessionId()) 43 if (session_id == delegate->GetSessionId())
46 return delegate; 44 return delegate;
47 } 45 }
48 return nullptr; 46 return nullptr;
49 } 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