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/views/infobars/infobar_view.h" | 5 #include "chrome/browser/ui/views/infobars/infobar_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 #include "ui/resources/grit/ui_resources.h" | 32 #include "ui/resources/grit/ui_resources.h" |
33 #include "ui/views/controls/button/image_button.h" | 33 #include "ui/views/controls/button/image_button.h" |
34 #include "ui/views/controls/button/label_button.h" | 34 #include "ui/views/controls/button/label_button.h" |
35 #include "ui/views/controls/button/label_button_border.h" | 35 #include "ui/views/controls/button/label_button_border.h" |
36 #include "ui/views/controls/button/menu_button.h" | 36 #include "ui/views/controls/button/menu_button.h" |
37 #include "ui/views/controls/image_view.h" | 37 #include "ui/views/controls/image_view.h" |
38 #include "ui/views/controls/label.h" | 38 #include "ui/views/controls/label.h" |
39 #include "ui/views/controls/link.h" | 39 #include "ui/views/controls/link.h" |
40 #include "ui/views/controls/menu/menu_runner.h" | 40 #include "ui/views/controls/menu/menu_runner.h" |
41 #include "ui/views/layout/layout_constants.h" | 41 #include "ui/views/layout/layout_constants.h" |
| 42 #include "ui/views/style/platform_style.h" |
42 #include "ui/views/widget/widget.h" | 43 #include "ui/views/widget/widget.h" |
43 #include "ui/views/window/non_client_view.h" | 44 #include "ui/views/window/non_client_view.h" |
44 | 45 |
45 | 46 |
46 // Helpers -------------------------------------------------------------------- | 47 // Helpers -------------------------------------------------------------------- |
47 | 48 |
48 namespace { | 49 namespace { |
49 | 50 |
50 const int kEdgeItemPadding = views::kRelatedControlHorizontalSpacing; | 51 const int kEdgeItemPadding = views::kRelatedControlHorizontalSpacing; |
51 const int kIconToLabelSpacing = views::kRelatedControlHorizontalSpacing; | 52 const int kIconToLabelSpacing = views::kRelatedControlHorizontalSpacing; |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 button_border->SetPainter( | 156 button_border->SetPainter( |
156 false, views::Button::STATE_PRESSED, | 157 false, views::Button::STATE_PRESSED, |
157 views::Painter::CreateImageGridPainter(kPressedImageSet)); | 158 views::Painter::CreateImageGridPainter(kPressedImageSet)); |
158 | 159 |
159 button->SetBorder(std::move(button_border)); | 160 button->SetBorder(std::move(button_border)); |
160 button->set_animate_on_state_change(false); | 161 button->set_animate_on_state_change(false); |
161 button->SetTextColor(views::Button::STATE_NORMAL, GetInfobarTextColor()); | 162 button->SetTextColor(views::Button::STATE_NORMAL, GetInfobarTextColor()); |
162 button->SetTextColor(views::Button::STATE_HOVERED, GetInfobarTextColor()); | 163 button->SetTextColor(views::Button::STATE_HOVERED, GetInfobarTextColor()); |
163 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 164 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
164 button->SetFontList(rb.GetFontList(ui::ResourceBundle::MediumFont)); | 165 button->SetFontList(rb.GetFontList(ui::ResourceBundle::MediumFont)); |
165 button->SetFocusable(true); | 166 views::PlatformStyle::SetControlStyleFocus(button); |
166 return button; | 167 return button; |
167 } | 168 } |
168 | 169 |
169 // static | 170 // static |
170 void InfoBarView::AssignWidths(Labels* labels, int available_width) { | 171 void InfoBarView::AssignWidths(Labels* labels, int available_width) { |
171 std::sort(labels->begin(), labels->end(), SortLabelsByDecreasingWidth); | 172 std::sort(labels->begin(), labels->end(), SortLabelsByDecreasingWidth); |
172 AssignWidthsSorted(labels, available_width); | 173 AssignWidthsSorted(labels, available_width); |
173 } | 174 } |
174 | 175 |
175 void InfoBarView::Layout() { | 176 void InfoBarView::Layout() { |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 close_button_->SetImage(views::CustomButton::STATE_NORMAL, | 267 close_button_->SetImage(views::CustomButton::STATE_NORMAL, |
267 rb.GetImageNamed(IDR_CLOSE_1).ToImageSkia()); | 268 rb.GetImageNamed(IDR_CLOSE_1).ToImageSkia()); |
268 close_button_->SetImage(views::CustomButton::STATE_HOVERED, | 269 close_button_->SetImage(views::CustomButton::STATE_HOVERED, |
269 rb.GetImageNamed(IDR_CLOSE_1_H).ToImageSkia()); | 270 rb.GetImageNamed(IDR_CLOSE_1_H).ToImageSkia()); |
270 close_button_->SetImage(views::CustomButton::STATE_PRESSED, | 271 close_button_->SetImage(views::CustomButton::STATE_PRESSED, |
271 rb.GetImageNamed(IDR_CLOSE_1_P).ToImageSkia()); | 272 rb.GetImageNamed(IDR_CLOSE_1_P).ToImageSkia()); |
272 } | 273 } |
273 close_button_->SizeToPreferredSize(); | 274 close_button_->SizeToPreferredSize(); |
274 close_button_->SetAccessibleName( | 275 close_button_->SetAccessibleName( |
275 l10n_util::GetStringUTF16(IDS_ACCNAME_CLOSE)); | 276 l10n_util::GetStringUTF16(IDS_ACCNAME_CLOSE)); |
276 close_button_->SetFocusable(true); | 277 views::PlatformStyle::SetControlStyleFocus(close_button_); |
277 child_container_->AddChildView(close_button_); | 278 child_container_->AddChildView(close_button_); |
278 } else if ((close_button_ != NULL) && (details.parent == this) && | 279 } else if ((close_button_ != NULL) && (details.parent == this) && |
279 (details.child != close_button_) && (close_button_->parent() == this) && | 280 (details.child != close_button_) && (close_button_->parent() == this) && |
280 (child_at(child_count() - 1) != close_button_)) { | 281 (child_at(child_count() - 1) != close_button_)) { |
281 // For accessibility, ensure the close button is the last child view. | 282 // For accessibility, ensure the close button is the last child view. |
282 RemoveChildView(close_button_); | 283 RemoveChildView(close_button_); |
283 child_container_->AddChildView(close_button_); | 284 child_container_->AddChildView(close_button_); |
284 } | 285 } |
285 | 286 |
286 // Ensure the infobar is tall enough to display its contents. | 287 // Ensure the infobar is tall enough to display its contents. |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
421 void InfoBarView::OnWillChangeFocus(View* focused_before, View* focused_now) { | 422 void InfoBarView::OnWillChangeFocus(View* focused_before, View* focused_now) { |
422 views::ExternalFocusTracker::OnWillChangeFocus(focused_before, focused_now); | 423 views::ExternalFocusTracker::OnWillChangeFocus(focused_before, focused_now); |
423 | 424 |
424 // This will trigger some screen readers to read the entire contents of this | 425 // This will trigger some screen readers to read the entire contents of this |
425 // infobar. | 426 // infobar. |
426 if (focused_before && focused_now && !Contains(focused_before) && | 427 if (focused_before && focused_now && !Contains(focused_before) && |
427 Contains(focused_now)) { | 428 Contains(focused_now)) { |
428 NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, true); | 429 NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, true); |
429 } | 430 } |
430 } | 431 } |
OLD | NEW |