OLD | NEW |
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/android/tab_model/tab_model_list.h" | 5 #include "chrome/browser/ui/android/tab_model/tab_model_list.h" |
6 | 6 |
| 7 #include "chrome/browser/android/tab_android.h" |
7 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
8 #include "chrome/browser/ui/android/tab_model/tab_model.h" | 9 #include "chrome/browser/ui/android/tab_model/tab_model.h" |
| 10 #include "chrome/browser/ui/browser_navigator.h" |
9 | 11 |
10 namespace { | 12 namespace { |
11 | 13 |
12 // Maintains and gives access to a static list of TabModel instances. | 14 // Maintains and gives access to a static list of TabModel instances. |
13 static TabModelList::TabModelVector& tab_models() { | 15 static TabModelList::TabModelVector& tab_models() { |
14 CR_DEFINE_STATIC_LOCAL(TabModelList::TabModelVector, | 16 CR_DEFINE_STATIC_LOCAL(TabModelList::TabModelVector, |
15 tab_model_vector, ()); | 17 tab_model_vector, ()); |
16 return tab_model_vector; | 18 return tab_model_vector; |
17 } | 19 } |
18 | 20 |
19 } // namespace | 21 } // namespace |
20 | 22 |
21 void TabModelList::AddTabModel(TabModel* tab_model) { | 23 void TabModelList::AddTabModel(TabModel* tab_model) { |
22 DCHECK(tab_model); | 24 DCHECK(tab_model); |
23 tab_models().push_back(tab_model); | 25 tab_models().push_back(tab_model); |
24 } | 26 } |
25 | 27 |
26 void TabModelList::RemoveTabModel(TabModel* tab_model) { | 28 void TabModelList::RemoveTabModel(TabModel* tab_model) { |
27 DCHECK(tab_model); | 29 DCHECK(tab_model); |
28 TabModelList::iterator remove_tab_model = | 30 TabModelList::iterator remove_tab_model = |
29 std::find(tab_models().begin(), tab_models().end(), tab_model); | 31 std::find(tab_models().begin(), tab_models().end(), tab_model); |
30 | 32 |
31 if (remove_tab_model != tab_models().end()) | 33 if (remove_tab_model != tab_models().end()) |
32 tab_models().erase(remove_tab_model); | 34 tab_models().erase(remove_tab_model); |
33 } | 35 } |
34 | 36 |
| 37 void TabModelList::HandlePopupNavigation(chrome::NavigateParams* params) { |
| 38 TabAndroid* tab = TabAndroid::FromWebContents(params->source_contents); |
| 39 |
| 40 // NOTE: If this fails contact dtrainor@. |
| 41 DCHECK(tab); |
| 42 tab->HandlePopupNavigation(params); |
| 43 } |
| 44 |
| 45 |
35 TabModel* TabModelList::GetTabModelWithProfile( | 46 TabModel* TabModelList::GetTabModelWithProfile( |
36 Profile* profile) { | 47 Profile* profile) { |
37 if (!profile) | 48 if (!profile) |
38 return NULL; | 49 return NULL; |
39 | 50 |
40 for (TabModelList::const_iterator i = TabModelList::begin(); | 51 for (TabModelList::const_iterator i = TabModelList::begin(); |
41 i != TabModelList::end(); ++i) { | 52 i != TabModelList::end(); ++i) { |
42 if (profile->IsSameProfile((*i)->GetProfile())) | 53 if (profile->IsSameProfile((*i)->GetProfile())) |
43 return *i; | 54 return *i; |
44 } | 55 } |
(...skipping 30 matching lines...) Expand all Loading... |
75 return tab_models().end(); | 86 return tab_models().end(); |
76 } | 87 } |
77 | 88 |
78 bool TabModelList::empty() { | 89 bool TabModelList::empty() { |
79 return tab_models().empty(); | 90 return tab_models().empty(); |
80 } | 91 } |
81 | 92 |
82 size_t TabModelList::size() { | 93 size_t TabModelList::size() { |
83 return tab_models().size(); | 94 return tab_models().size(); |
84 } | 95 } |
OLD | NEW |