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
3 // found in the LICENSE file.
5 #include "chrome/browser/ui/views/infobars/infobar_container_view.h"
7 #include "chrome/browser/ui/view_ids.h"
8 #include "chrome/browser/ui/views/infobars/infobar_view.h"
9 #include "chrome/grit/generated_resources.h"
10 #include "ui/accessibility/ax_view_state.h"
11 #include "ui/base/l10n/l10n_util.h"
14 const char InfoBarContainerView::kViewClassName
[] = "InfoBarContainerView";
16 InfoBarContainerView::InfoBarContainerView(Delegate
* delegate
)
17 : infobars::InfoBarContainer(delegate
) {
18 set_id(VIEW_ID_INFO_BAR_CONTAINER
);
21 InfoBarContainerView::~InfoBarContainerView() {
22 RemoveAllInfoBarsForDestruction();
25 gfx::Size
InfoBarContainerView::GetPreferredSize() const {
27 GetVerticalOverlap(&total_height
);
28 gfx::Size
size(0, total_height
);
29 for (int i
= 0; i
< child_count(); ++i
)
30 size
.SetToMax(gfx::Size(child_at(i
)->GetPreferredSize().width(), 0));
34 const char* InfoBarContainerView::GetClassName() const {
35 return kViewClassName
;
38 void InfoBarContainerView::Layout() {
39 int top
= GetVerticalOverlap(NULL
);
41 for (int i
= 0; i
< child_count(); ++i
) {
42 InfoBarView
* child
= static_cast<InfoBarView
*>(child_at(i
));
43 top
-= child
->arrow_height();
44 int child_height
= child
->total_height();
45 child
->SetBounds(0, top
, width(), child_height
);
50 void InfoBarContainerView::GetAccessibleState(ui::AXViewState
* state
) {
51 state
->role
= ui::AX_ROLE_GROUP
;
52 state
->name
= l10n_util::GetStringUTF16(IDS_ACCNAME_INFOBAR_CONTAINER
);
55 void InfoBarContainerView::PlatformSpecificAddInfoBar(
56 infobars::InfoBar
* infobar
,
58 AddChildViewAt(static_cast<InfoBarView
*>(infobar
),
59 static_cast<int>(position
));
62 void InfoBarContainerView::PlatformSpecificRemoveInfoBar(
63 infobars::InfoBar
* infobar
) {
64 RemoveChildView(static_cast<InfoBarView
*>(infobar
));