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

Side by Side Diff: chrome/browser/ui/android/tab_model/tab_model_list.cc

Issue 10701030: Refactor SyncedWindowDelegateAndroid into TabModel (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Nit fixes Created 8 years, 4 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 | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/ui/android/tab_model/tab_model_list.h"
6
7 #include "chrome/browser/profiles/profile.h"
8 #include "chrome/browser/ui/android/tab_model/tab_model.h"
9
10 namespace {
11
12 // Maintains and gives access to a static list of TabModel instances.
13 static TabModelList::TabModelVector& tab_models() {
14 CR_DEFINE_STATIC_LOCAL(TabModelList::TabModelVector,
15 tab_model_vector, ());
16 return tab_model_vector;
17 }
18
19 } // namespace
20
21 void TabModelList::AddTabModel(TabModel* tab_model) {
22 DCHECK(tab_model);
23 tab_models().push_back(tab_model);
24 }
25
26 void TabModelList::RemoveTabModel(TabModel* tab_model) {
27 DCHECK(tab_model);
28 TabModelList::iterator remove_tab_model =
29 std::find(tab_models().begin(), tab_models().end(), tab_model);
30
31 if (remove_tab_model != tab_models().end())
32 tab_models().erase(remove_tab_model);
33 }
34
35 TabModel* TabModelList::GetTabModelWithProfile(
36 Profile* profile) {
37 for (TabModelList::const_iterator i = TabModelList::begin();
38 i != TabModelList::end(); ++i) {
39 if ((*i)->GetProfile()->IsSameProfile(profile))
40 return *i;
41 }
42
43 return NULL;
44 }
45
46 TabModel* TabModelList::FindTabModelWithId(
47 SessionID::id_type desired_id) {
48 for (TabModelList::const_iterator i = TabModelList::begin();
49 i != TabModelList::end(); i++) {
50 if ((*i)->GetSessionId() == desired_id)
51 return *i;
52 }
53
54 return NULL;
55 }
56
57 bool TabModelList::IsOffTheRecordSessionActive() {
58 for (TabModelList::const_iterator i = TabModelList::begin();
59 i != TabModelList::end(); i++) {
60 if ((*i)->GetProfile()->IsOffTheRecord())
61 return true;
62 }
63
64 return false;
65 }
66
67 TabModelList::const_iterator TabModelList::begin() {
68 return tab_models().begin();
69 }
70
71 TabModelList::const_iterator TabModelList::end() {
72 return tab_models().end();
73 }
74
75 bool TabModelList::empty() {
76 return tab_models().empty();
77 }
78
79 size_t TabModelList::size() {
80 return tab_models().size();
81 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/android/tab_model/tab_model_list.h ('k') | chrome/browser/ui/browser_otr_state.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698