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

Side by Side Diff: chrome/browser/ui/sync/browser_synced_window_delegate.cc

Issue 1310373009: [Sync] Remove static methods on SyncedWindowDelegate. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 5 years, 3 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/ui/sync/browser_synced_window_delegate.h" 5 #include "chrome/browser/ui/sync/browser_synced_window_delegate.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "chrome/browser/ui/browser.h" 9 #include "chrome/browser/ui/browser.h"
10 #include "chrome/browser/ui/browser_finder.h" 10 #include "chrome/browser/ui/browser_finder.h"
11 #include "chrome/browser/ui/browser_iterator.h" 11 #include "chrome/browser/ui/browser_iterator.h"
12 #include "chrome/browser/ui/sync/tab_contents_synced_tab_delegate.h" 12 #include "chrome/browser/ui/sync/tab_contents_synced_tab_delegate.h"
13 #include "chrome/browser/ui/tabs/tab_strip_model.h" 13 #include "chrome/browser/ui/tabs/tab_strip_model.h"
14 #include "components/sessions/session_id.h" 14 #include "components/sessions/session_id.h"
15 15
16 // static SyncedWindowDelegate implementations
17
18 namespace browser_sync {
19
20 // static
21 std::set<const SyncedWindowDelegate*> SyncedWindowDelegate::GetAll() {
22 std::set<const SyncedWindowDelegate*> synced_window_delegates;
23 BrowserSyncedWindowDelegate::GetAllHelper(&synced_window_delegates);
24 return synced_window_delegates;
25 }
26
27 // static
28 const SyncedWindowDelegate* SyncedWindowDelegate::FindById(
29 SessionID::id_type id) {
30 const SyncedWindowDelegate* synced_window_delegate =
31 BrowserSyncedWindowDelegate::FindByIdHelper(id);
32 return synced_window_delegate;
33 }
34
35 } // namespace browser_sync
36
37 // BrowserSyncedWindowDelegate implementations 16 // BrowserSyncedWindowDelegate implementations
38 17
39 BrowserSyncedWindowDelegate::BrowserSyncedWindowDelegate(Browser* browser) 18 BrowserSyncedWindowDelegate::BrowserSyncedWindowDelegate(Browser* browser)
40 : browser_(browser) {} 19 : browser_(browser) {}
41 20
42 BrowserSyncedWindowDelegate::~BrowserSyncedWindowDelegate() {} 21 BrowserSyncedWindowDelegate::~BrowserSyncedWindowDelegate() {}
43 22
44 // static
45 void BrowserSyncedWindowDelegate::GetAllHelper(
46 std::set<const browser_sync::SyncedWindowDelegate*>* delegates) {
47 // Add all the browser windows.
48 for (chrome::BrowserIterator it; !it.done(); it.Next())
49 delegates->insert(it->synced_window_delegate());
50 }
51
52 // static
53 const browser_sync::SyncedWindowDelegate*
54 BrowserSyncedWindowDelegate::FindByIdHelper(SessionID::id_type id) {
55 Browser* browser = chrome::FindBrowserWithID(id);
56 return (browser != NULL) ? browser->synced_window_delegate() : NULL;
57 }
58
59 bool BrowserSyncedWindowDelegate::IsTabPinned( 23 bool BrowserSyncedWindowDelegate::IsTabPinned(
60 const browser_sync::SyncedTabDelegate* tab) const { 24 const browser_sync::SyncedTabDelegate* tab) const {
61 for (int i = 0; i < browser_->tab_strip_model()->count(); i++) { 25 for (int i = 0; i < browser_->tab_strip_model()->count(); i++) {
62 browser_sync::SyncedTabDelegate* current = GetTabAt(i); 26 browser_sync::SyncedTabDelegate* current = GetTabAt(i);
63 if (tab == current) 27 if (tab == current)
64 return browser_->tab_strip_model()->IsTabPinned(i); 28 return browser_->tab_strip_model()->IsTabPinned(i);
65 } 29 }
66 // The window and tab are not always updated atomically, so it's possible 30 // The window and tab are not always updated atomically, so it's possible
67 // one of the values was stale. We'll retry later, just ignore for now. 31 // one of the values was stale. We'll retry later, just ignore for now.
68 return false; 32 return false;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 72
109 bool BrowserSyncedWindowDelegate::IsSessionRestoreInProgress() const { 73 bool BrowserSyncedWindowDelegate::IsSessionRestoreInProgress() const {
110 return false; 74 return false;
111 } 75 }
112 76
113 bool BrowserSyncedWindowDelegate::ShouldSync() const { 77 bool BrowserSyncedWindowDelegate::ShouldSync() const {
114 if (IsApp()) 78 if (IsApp())
115 return false; 79 return false;
116 return IsTypeTabbed() || IsTypePopup(); 80 return IsTypeTabbed() || IsTypePopup();
117 } 81 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698