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

Side by Side Diff: chrome/browser/sync/sessions/browser_list_router_helper.cc

Issue 2887513002: [sync] Scope BrowserListRouterHelper to browsers with a matching profile (Closed)
Patch Set: Created 3 years, 7 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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 "chrome/browser/sync/sessions/browser_list_router_helper.h" 5 #include "chrome/browser/sync/sessions/browser_list_router_helper.h"
6 6
7 #include "chrome/browser/ui/browser.h" 7 #include "chrome/browser/ui/browser.h"
8 #include "chrome/browser/ui/browser_list.h" 8 #include "chrome/browser/ui/browser_list.h"
9 #include "chrome/browser/ui/sync/tab_contents_synced_tab_delegate.h" 9 #include "chrome/browser/ui/sync/tab_contents_synced_tab_delegate.h"
10 #include "chrome/browser/ui/tabs/tab_strip_model.h" 10 #include "chrome/browser/ui/tabs/tab_strip_model.h"
11 11
12 namespace sync_sessions { 12 namespace sync_sessions {
13 13
14 BrowserListRouterHelper::BrowserListRouterHelper( 14 BrowserListRouterHelper::BrowserListRouterHelper(
15 SyncSessionsWebContentsRouter* router) 15 SyncSessionsWebContentsRouter* router,
16 : router_(router) { 16 Profile* profile)
17 : router_(router), profile_(profile) {
17 BrowserList* browser_list = BrowserList::GetInstance(); 18 BrowserList* browser_list = BrowserList::GetInstance();
18 for (Browser* browser : *browser_list) 19 for (Browser* browser : *browser_list) {
19 browser->tab_strip_model()->AddObserver(this); 20 if (browser->profile() == profile_) {
21 browser->tab_strip_model()->AddObserver(this);
22 attached_browsers_.insert(browser);
23 }
24 }
20 browser_list->AddObserver(this); 25 browser_list->AddObserver(this);
21 } 26 }
22 27
23 BrowserListRouterHelper::~BrowserListRouterHelper() { 28 BrowserListRouterHelper::~BrowserListRouterHelper() {
24 BrowserList* browser_list = BrowserList::GetInstance(); 29 for (Browser* browser : attached_browsers_) {
25 for (Browser* browser : *browser_list) 30 if (browser->profile() == profile_) {
26 browser->tab_strip_model()->RemoveObserver(this); 31 browser->tab_strip_model()->RemoveObserver(this);
32 }
33 }
34
27 BrowserList::GetInstance()->RemoveObserver(this); 35 BrowserList::GetInstance()->RemoveObserver(this);
28 } 36 }
29 37
30 void BrowserListRouterHelper::OnBrowserAdded(Browser* browser) { 38 void BrowserListRouterHelper::OnBrowserAdded(Browser* browser) {
31 browser->tab_strip_model()->AddObserver(this); 39 if (browser->profile() == profile_) {
40 browser->tab_strip_model()->AddObserver(this);
41 attached_browsers_.insert(browser);
42 }
32 } 43 }
33 44
34 void BrowserListRouterHelper::OnBrowserRemoved(Browser* browser) { 45 void BrowserListRouterHelper::OnBrowserRemoved(Browser* browser) {
35 browser->tab_strip_model()->RemoveObserver(this); 46 if (browser->profile() == profile_) {
47 browser->tab_strip_model()->RemoveObserver(this);
48 attached_browsers_.erase(browser);
49 }
36 } 50 }
37 51
38 void BrowserListRouterHelper::TabInsertedAt(TabStripModel* model, 52 void BrowserListRouterHelper::TabInsertedAt(TabStripModel* model,
39 content::WebContents* web_contents, 53 content::WebContents* web_contents,
40 int index, 54 int index,
41 bool foreground) { 55 bool foreground) {
42 router_->NotifyTabModified(web_contents, false); 56 router_->NotifyTabModified(web_contents, false);
43 } 57 }
44 58
45 } // namespace sync_sessions 59 } // namespace sync_sessions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698