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(InfoBarService* owner, InfoBarDelegate* delegate) | 57 InfoBarView::InfoBarView(scoped_ptr<InfoBarDelegate> delegate) |
58 : InfoBar(owner, delegate), | 58 : InfoBar(delegate.Pass()), |
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 if (delegate()) { | 379 state->name = l10n_util::GetStringUTF16( |
380 state->name = l10n_util::GetStringUTF16( | 380 (delegate()->GetInfoBarType() == InfoBarDelegate::WARNING_TYPE) ? |
381 (delegate()->GetInfoBarType() == InfoBarDelegate::WARNING_TYPE) ? | 381 IDS_ACCNAME_INFOBAR_WARNING : IDS_ACCNAME_INFOBAR_PAGE_ACTION); |
382 IDS_ACCNAME_INFOBAR_WARNING : IDS_ACCNAME_INFOBAR_PAGE_ACTION); | |
383 } | |
384 state->role = ui::AccessibilityTypes::ROLE_ALERT; | 382 state->role = ui::AccessibilityTypes::ROLE_ALERT; |
385 } | 383 } |
386 | 384 |
387 gfx::Size InfoBarView::GetPreferredSize() { | 385 gfx::Size InfoBarView::GetPreferredSize() { |
388 return gfx::Size(0, total_height()); | 386 return gfx::Size(0, total_height()); |
389 } | 387 } |
390 | 388 |
391 void InfoBarView::OnWillChangeFocus(View* focused_before, View* focused_now) { | 389 void InfoBarView::OnWillChangeFocus(View* focused_before, View* focused_now) { |
392 views::ExternalFocusTracker::OnWillChangeFocus(focused_before, focused_now); | 390 views::ExternalFocusTracker::OnWillChangeFocus(focused_before, focused_now); |
393 | 391 |
394 // This will trigger some screen readers to read the entire contents of this | 392 // This will trigger some screen readers to read the entire contents of this |
395 // infobar. | 393 // infobar. |
396 if (focused_before && focused_now && !Contains(focused_before) && | 394 if (focused_before && focused_now && !Contains(focused_before) && |
397 Contains(focused_now)) { | 395 Contains(focused_now)) { |
398 NotifyAccessibilityEvent(ui::AccessibilityTypes::EVENT_ALERT, true); | 396 NotifyAccessibilityEvent(ui::AccessibilityTypes::EVENT_ALERT, true); |
399 } | 397 } |
400 } | 398 } |
OLD | NEW |