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 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
8 #include <shellapi.h> | 8 #include <shellapi.h> |
9 #endif | 9 #endif |
10 | 10 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 const int InfoBar::kDefaultArrowTargetHeight = 9; | 47 const int InfoBar::kDefaultArrowTargetHeight = 9; |
48 const int InfoBar::kMaximumArrowTargetHeight = 24; | 48 const int InfoBar::kMaximumArrowTargetHeight = 24; |
49 const int InfoBar::kDefaultArrowTargetHalfWidth = kDefaultArrowTargetHeight; | 49 const int InfoBar::kDefaultArrowTargetHalfWidth = kDefaultArrowTargetHeight; |
50 const int InfoBar::kMaximumArrowTargetHalfWidth = 14; | 50 const int InfoBar::kMaximumArrowTargetHalfWidth = 14; |
51 const int InfoBar::kDefaultBarTargetHeight = 36; | 51 const int InfoBar::kDefaultBarTargetHeight = 36; |
52 | 52 |
53 const int InfoBarView::kButtonButtonSpacing = 10; | 53 const int InfoBarView::kButtonButtonSpacing = 10; |
54 const int InfoBarView::kEndOfLabelSpacing = 16; | 54 const int InfoBarView::kEndOfLabelSpacing = 16; |
55 const int InfoBarView::kHorizontalPadding = 6; | 55 const int InfoBarView::kHorizontalPadding = 6; |
56 | 56 |
57 InfoBarView::InfoBarView(scoped_ptr<InfoBarDelegate> delegate) | 57 InfoBarView::InfoBarView(InfoBarService* owner, InfoBarDelegate* delegate) |
58 : InfoBar(delegate.Pass()), | 58 : InfoBar(owner, delegate), |
59 views::ExternalFocusTracker(this, NULL), | 59 views::ExternalFocusTracker(this, NULL), |
60 icon_(NULL), | 60 icon_(NULL), |
61 close_button_(NULL) { | 61 close_button_(NULL) { |
62 set_owned_by_client(); // InfoBar deletes itself at the appropriate time. | 62 set_owned_by_client(); // InfoBar deletes itself at the appropriate time. |
63 set_background(new InfoBarBackground(InfoBar::delegate()->GetInfoBarType())); | 63 set_background(new InfoBarBackground(InfoBar::delegate()->GetInfoBarType())); |
64 } | 64 } |
65 | 65 |
66 InfoBarView::~InfoBarView() { | 66 InfoBarView::~InfoBarView() { |
67 // We should have closed any open menus in PlatformSpecificHide(), then | 67 // We should have closed any open menus in PlatformSpecificHide(), then |
68 // subclasses' RunMenu() functions should have prevented opening any new ones | 68 // subclasses' RunMenu() functions should have prevented opening any new ones |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 FocusLastFocusedExternalView(); | 369 FocusLastFocusedExternalView(); |
370 } | 370 } |
371 | 371 |
372 void InfoBarView::PlatformSpecificOnHeightsRecalculated() { | 372 void InfoBarView::PlatformSpecificOnHeightsRecalculated() { |
373 // Ensure that notifying our container of our size change will result in a | 373 // Ensure that notifying our container of our size change will result in a |
374 // re-layout. | 374 // re-layout. |
375 InvalidateLayout(); | 375 InvalidateLayout(); |
376 } | 376 } |
377 | 377 |
378 void InfoBarView::GetAccessibleState(ui::AccessibleViewState* state) { | 378 void InfoBarView::GetAccessibleState(ui::AccessibleViewState* state) { |
379 state->name = l10n_util::GetStringUTF16( | 379 if (delegate()) { |
380 (delegate()->GetInfoBarType() == InfoBarDelegate::WARNING_TYPE) ? | 380 state->name = l10n_util::GetStringUTF16( |
381 IDS_ACCNAME_INFOBAR_WARNING : IDS_ACCNAME_INFOBAR_PAGE_ACTION); | 381 (delegate()->GetInfoBarType() == InfoBarDelegate::WARNING_TYPE) ? |
| 382 IDS_ACCNAME_INFOBAR_WARNING : IDS_ACCNAME_INFOBAR_PAGE_ACTION); |
| 383 } |
382 state->role = ui::AccessibilityTypes::ROLE_ALERT; | 384 state->role = ui::AccessibilityTypes::ROLE_ALERT; |
383 } | 385 } |
384 | 386 |
385 gfx::Size InfoBarView::GetPreferredSize() { | 387 gfx::Size InfoBarView::GetPreferredSize() { |
386 return gfx::Size(0, total_height()); | 388 return gfx::Size(0, total_height()); |
387 } | 389 } |
388 | 390 |
389 void InfoBarView::OnWillChangeFocus(View* focused_before, View* focused_now) { | 391 void InfoBarView::OnWillChangeFocus(View* focused_before, View* focused_now) { |
390 views::ExternalFocusTracker::OnWillChangeFocus(focused_before, focused_now); | 392 views::ExternalFocusTracker::OnWillChangeFocus(focused_before, focused_now); |
391 | 393 |
392 // This will trigger some screen readers to read the entire contents of this | 394 // This will trigger some screen readers to read the entire contents of this |
393 // infobar. | 395 // infobar. |
394 if (focused_before && focused_now && !Contains(focused_before) && | 396 if (focused_before && focused_now && !Contains(focused_before) && |
395 Contains(focused_now)) { | 397 Contains(focused_now)) { |
396 NotifyAccessibilityEvent(ui::AccessibilityTypes::EVENT_ALERT, true); | 398 NotifyAccessibilityEvent(ui::AccessibilityTypes::EVENT_ALERT, true); |
397 } | 399 } |
398 } | 400 } |
OLD | NEW |