OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/views/infobars/infobar_container_view.h" | 5 #include "chrome/browser/ui/views/infobars/infobar_container_view.h" |
6 | 6 |
7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
8 #include "chrome/browser/ui/view_ids.h" | 8 #include "chrome/browser/ui/view_ids.h" |
9 #include "chrome/browser/ui/views/infobars/infobar_view.h" | 9 #include "chrome/browser/ui/views/infobars/infobar_view.h" |
10 #include "grit/generated_resources.h" | 10 #include "grit/generated_resources.h" |
11 #include "ui/base/accessibility/accessible_view_state.h" | 11 #include "ui/base/accessibility/accessible_view_state.h" |
12 #include "ui/base/l10n/l10n_util.h" | 12 #include "ui/base/l10n/l10n_util.h" |
13 | 13 |
| 14 // static |
| 15 const char InfoBarContainerView::kViewClassName[] = "InfoBarContainerView"; |
| 16 |
14 InfoBarContainerView::InfoBarContainerView( | 17 InfoBarContainerView::InfoBarContainerView( |
15 Delegate* delegate, | 18 Delegate* delegate, |
16 chrome::search::SearchModel* search_model) | 19 chrome::search::SearchModel* search_model) |
17 : InfoBarContainer(delegate, search_model) { | 20 : InfoBarContainer(delegate, search_model) { |
18 set_id(VIEW_ID_INFO_BAR_CONTAINER); | 21 set_id(VIEW_ID_INFO_BAR_CONTAINER); |
19 } | 22 } |
20 | 23 |
21 InfoBarContainerView::~InfoBarContainerView() { | 24 InfoBarContainerView::~InfoBarContainerView() { |
22 RemoveAllInfoBarsForDestruction(); | 25 RemoveAllInfoBarsForDestruction(); |
23 } | 26 } |
24 | 27 |
25 gfx::Size InfoBarContainerView::GetPreferredSize() { | 28 gfx::Size InfoBarContainerView::GetPreferredSize() { |
26 // We do not have a preferred width (we will expand to fit the available width | 29 // We do not have a preferred width (we will expand to fit the available width |
27 // of the delegate). | 30 // of the delegate). |
28 int total_height; | 31 int total_height; |
29 GetVerticalOverlap(&total_height); | 32 GetVerticalOverlap(&total_height); |
30 return gfx::Size(0, total_height); | 33 return gfx::Size(0, total_height); |
31 } | 34 } |
32 | 35 |
| 36 std::string InfoBarContainerView::GetClassName() const { |
| 37 return kViewClassName; |
| 38 } |
| 39 |
33 void InfoBarContainerView::Layout() { | 40 void InfoBarContainerView::Layout() { |
34 int top = GetVerticalOverlap(NULL); | 41 int top = GetVerticalOverlap(NULL); |
35 | 42 |
36 for (int i = 0; i < child_count(); ++i) { | 43 for (int i = 0; i < child_count(); ++i) { |
37 InfoBarView* child = static_cast<InfoBarView*>(child_at(i)); | 44 InfoBarView* child = static_cast<InfoBarView*>(child_at(i)); |
38 top -= child->arrow_height(); | 45 top -= child->arrow_height(); |
39 int child_height = child->total_height(); | 46 int child_height = child->total_height(); |
40 child->SetBounds(0, top, width(), child_height); | 47 child->SetBounds(0, top, width(), child_height); |
41 top += child_height; | 48 top += child_height; |
42 } | 49 } |
43 } | 50 } |
44 | 51 |
45 void InfoBarContainerView::GetAccessibleState(ui::AccessibleViewState* state) { | 52 void InfoBarContainerView::GetAccessibleState(ui::AccessibleViewState* state) { |
46 state->role = ui::AccessibilityTypes::ROLE_GROUPING; | 53 state->role = ui::AccessibilityTypes::ROLE_GROUPING; |
47 state->name = l10n_util::GetStringUTF16(IDS_ACCNAME_INFOBAR_CONTAINER); | 54 state->name = l10n_util::GetStringUTF16(IDS_ACCNAME_INFOBAR_CONTAINER); |
48 } | 55 } |
49 | 56 |
50 void InfoBarContainerView::PlatformSpecificAddInfoBar(InfoBar* infobar, | 57 void InfoBarContainerView::PlatformSpecificAddInfoBar(InfoBar* infobar, |
51 size_t position) { | 58 size_t position) { |
52 AddChildViewAt(static_cast<InfoBarView*>(infobar), | 59 AddChildViewAt(static_cast<InfoBarView*>(infobar), |
53 static_cast<int>(position)); | 60 static_cast<int>(position)); |
54 } | 61 } |
55 | 62 |
56 void InfoBarContainerView::PlatformSpecificRemoveInfoBar(InfoBar* infobar) { | 63 void InfoBarContainerView::PlatformSpecificRemoveInfoBar(InfoBar* infobar) { |
57 RemoveChildView(static_cast<InfoBarView*>(infobar)); | 64 RemoveChildView(static_cast<InfoBarView*>(infobar)); |
58 MessageLoop::current()->DeleteSoon(FROM_HERE, infobar); | 65 MessageLoop::current()->DeleteSoon(FROM_HERE, infobar); |
59 } | 66 } |
OLD | NEW |