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

Side by Side Diff: chrome/browser/ui/views/infobars/infobar_container.cc

Issue 6452011: Rework tree APIs to reflect Google style and more const-correctness.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 10 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
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.h" 5 #include "chrome/browser/ui/views/infobars/infobar_container.h"
6 6
7 #include "base/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 #include "chrome/browser/tab_contents/infobar_delegate.h" 8 #include "chrome/browser/tab_contents/infobar_delegate.h"
9 #include "chrome/browser/tab_contents/tab_contents.h" 9 #include "chrome/browser/tab_contents/tab_contents.h"
10 #include "chrome/browser/ui/view_ids.h" 10 #include "chrome/browser/ui/view_ids.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 delegate_->InfoBarContainerSizeChanged(!completed); 53 delegate_->InfoBarContainerSizeChanged(!completed);
54 } 54 }
55 55
56 void InfoBarContainer::RemoveDelegate(InfoBarDelegate* delegate) { 56 void InfoBarContainer::RemoveDelegate(InfoBarDelegate* delegate) {
57 tab_contents_->RemoveInfoBar(delegate); 57 tab_contents_->RemoveInfoBar(delegate);
58 } 58 }
59 59
60 void InfoBarContainer::PaintInfoBarArrows(gfx::Canvas* canvas, 60 void InfoBarContainer::PaintInfoBarArrows(gfx::Canvas* canvas,
61 View* outer_view, 61 View* outer_view,
62 int arrow_center_x) { 62 int arrow_center_x) {
63 for (int i = 0; i < GetChildViewCount(); ++i) { 63 for (int i = 0; i < child_count(); ++i) {
64 InfoBarView* infobar = static_cast<InfoBarView*>(GetChildViewAt(i)); 64 InfoBarView* infobar = static_cast<InfoBarView*>(GetChildViewAt(i));
65 infobar->PaintArrow(canvas, outer_view, arrow_center_x); 65 infobar->PaintArrow(canvas, outer_view, arrow_center_x);
66 } 66 }
67 } 67 }
68 68
69 gfx::Size InfoBarContainer::GetPreferredSize() { 69 gfx::Size InfoBarContainer::GetPreferredSize() {
70 // We do not have a preferred width (we will expand to fit the available width 70 // We do not have a preferred width (we will expand to fit the available width
71 // of the delegate). Our preferred height is the sum of the preferred heights 71 // of the delegate). Our preferred height is the sum of the preferred heights
72 // of the InfoBars contained within us. 72 // of the InfoBars contained within us.
73 int height = 0; 73 int height = 0;
74 for (int i = 0; i < GetChildViewCount(); ++i) 74 for (int i = 0; i < child_count(); ++i)
75 height += GetChildViewAt(i)->GetPreferredSize().height(); 75 height += GetChildViewAt(i)->GetPreferredSize().height();
76 return gfx::Size(0, height); 76 return gfx::Size(0, height);
77 } 77 }
78 78
79 void InfoBarContainer::Layout() { 79 void InfoBarContainer::Layout() {
80 int top = 0; 80 int top = 0;
81 for (int i = 0; i < GetChildViewCount(); ++i) { 81 for (int i = 0; i < child_count(); ++i) {
82 View* child = GetChildViewAt(i); 82 View* child = GetChildViewAt(i);
83 gfx::Size ps = child->GetPreferredSize(); 83 gfx::Size ps = child->GetPreferredSize();
84 child->SetBounds(0, top, width(), ps.height()); 84 child->SetBounds(0, top, width(), ps.height());
85 top += ps.height(); 85 top += ps.height();
86 } 86 }
87 } 87 }
88 88
89 AccessibilityTypes::Role InfoBarContainer::GetAccessibleRole() { 89 AccessibilityTypes::Role InfoBarContainer::GetAccessibleRole() {
90 return AccessibilityTypes::ROLE_GROUPING; 90 return AccessibilityTypes::ROLE_GROUPING;
91 } 91 }
92 92
93 void InfoBarContainer::ViewHierarchyChanged(bool is_add, 93 void InfoBarContainer::ViewHierarchyChanged(bool is_add,
94 View* parent, 94 View* parent,
95 View* child) { 95 View* child) {
96 if (parent == this && child->GetParent() == this) { 96 if (parent == this && child->parent() == this) {
97 if (delegate_) { 97 if (delegate_) {
98 // An InfoBar child was added or removed. Tell the delegate it needs to 98 // An InfoBar child was added or removed. Tell the delegate it needs to
99 // re-layout since our preferred size will have changed. 99 // re-layout since our preferred size will have changed.
100 delegate_->InfoBarContainerSizeChanged(false); 100 delegate_->InfoBarContainerSizeChanged(false);
101 } 101 }
102 } 102 }
103 } 103 }
104 104
105 void InfoBarContainer::Observe(NotificationType type, 105 void InfoBarContainer::Observe(NotificationType type,
106 const NotificationSource& source, 106 const NotificationSource& source,
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 infobar->Open(); 140 infobar->Open();
141 } 141 }
142 142
143 void InfoBarContainer::RemoveInfoBar(InfoBarDelegate* delegate, 143 void InfoBarContainer::RemoveInfoBar(InfoBarDelegate* delegate,
144 bool use_animation) { 144 bool use_animation) {
145 // Search for infobar associated with |delegate| among child views. 145 // Search for infobar associated with |delegate| among child views.
146 // We cannot search for |delegate| in tab_contents, because an infobar remains 146 // We cannot search for |delegate| in tab_contents, because an infobar remains
147 // a child view until its close animation completes, which can result in 147 // a child view until its close animation completes, which can result in
148 // different number of infobars in container and infobar delegates in tab 148 // different number of infobars in container and infobar delegates in tab
149 // contents. 149 // contents.
150 for (int i = 0; i < GetChildViewCount(); ++i) { 150 for (int i = 0; i < child_count(); ++i) {
151 InfoBarView* infobar = static_cast<InfoBarView*>(GetChildViewAt(i)); 151 InfoBarView* infobar = static_cast<InfoBarView*>(GetChildViewAt(i));
152 if (infobar->delegate() == delegate) { 152 if (infobar->delegate() == delegate) {
153 if (use_animation) { 153 if (use_animation) {
154 // The View will be removed once the Close animation completes. 154 // The View will be removed once the Close animation completes.
155 infobar->AnimateClose(); 155 infobar->AnimateClose();
156 } else { 156 } else {
157 infobar->Close(); 157 infobar->Close();
158 } 158 }
159 break; 159 break;
160 } 160 }
161 } 161 }
162 } 162 }
163 163
164 void InfoBarContainer::ReplaceInfoBar(InfoBarDelegate* old_delegate, 164 void InfoBarContainer::ReplaceInfoBar(InfoBarDelegate* old_delegate,
165 InfoBarDelegate* new_delegate) { 165 InfoBarDelegate* new_delegate) {
166 RemoveInfoBar(old_delegate, false); // no animation 166 RemoveInfoBar(old_delegate, false); // no animation
167 AddInfoBar(new_delegate, false); // no animation 167 AddInfoBar(new_delegate, false); // no animation
168 } 168 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/info_bubble.cc ('k') | chrome/browser/ui/views/infobars/infobar_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698