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

Unified 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: Updated file names, made requested changes. Created 8 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/android/tab_model/tab_model_list.cc
diff --git a/chrome/browser/ui/android/tab_model/tab_model_list.cc b/chrome/browser/ui/android/tab_model/tab_model_list.cc
new file mode 100644
index 0000000000000000000000000000000000000000..0665be0ddf35fda828f67123ed317eef4dea855d
--- /dev/null
+++ b/chrome/browser/ui/android/tab_model/tab_model_list.cc
@@ -0,0 +1,81 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/android/tab_model/tab_model_list.h"
+
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/android/tab_model/tab_model.h"
+
+namespace {
+
+// Maintains and gives access to a static list of TabModel instances.
+static TabModelList::TabModelVector& tab_models() {
+ CR_DEFINE_STATIC_LOCAL(TabModelList::TabModelVector,
+ tab_model_vector, ());
+ return tab_model_vector;
+}
+
+} // namespace
+
+void TabModelList::AddTabModel(TabModel* tab_model) {
+ DCHECK(tab_model);
+ tab_models().push_back(tab_model);
+}
+
+void TabModelList::RemoveTabModel(TabModel* tab_model) {
+ DCHECK(tab_model);
+ TabModelList::iterator remove_tab_model =
+ std::find(tab_models().begin(), tab_models().end(), tab_model);
+
+ if (remove_tab_model != tab_models().end())
+ tab_models().erase(remove_tab_model);
+}
+
+TabModel* TabModelList::GetTabModelWithProfile(
+ Profile* profile) {
+ for (TabModelList::const_iterator i = TabModelList::begin();
+ i != TabModelList::end(); ++i) {
+ if ((*i)->GetProfile()->IsSameProfile(profile))
+ return *i;
+ }
+
+ return NULL;
+}
+
+TabModel* TabModelList::FindTabModelWithId(
+ SessionID::id_type desired_id) {
+ for (TabModelList::const_iterator i = TabModelList::begin();
+ i != TabModelList::end(); i++) {
+ if ((*i)->GetSessionId() == desired_id)
+ return *i;
+ }
+
+ return NULL;
+}
+
+bool TabModelList::IsOffTheRecordSessionActive() {
+ for (TabModelList::const_iterator i = TabModelList::begin();
+ i != TabModelList::end(); i++) {
+ if ((*i)->GetProfile()->IsOffTheRecord())
+ return true;
+ }
+
+ return false;
+}
+
+TabModelList::const_iterator TabModelList::begin() {
+ return tab_models().begin();
+}
+
+TabModelList::const_iterator TabModelList::end() {
+ return tab_models().end();
+}
+
+bool TabModelList::empty() {
+ return tab_models().empty();
+}
+
+size_t TabModelList::size() {
+ return tab_models().size();
+}

Powered by Google App Engine
This is Rietveld 408576698