| OLD | NEW |
| 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/infobars.h" | 5 #include "chrome/browser/ui/views/infobars/infobars.h" |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "app/resource_bundle.h" | 8 #include "app/resource_bundle.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 close_button_(new views::ImageButton(this))), | 90 close_button_(new views::ImageButton(this))), |
| 91 ALLOW_THIS_IN_INITIALIZER_LIST(delete_factory_(this)), | 91 ALLOW_THIS_IN_INITIALIZER_LIST(delete_factory_(this)), |
| 92 target_height_(kDefaultTargetHeight) { | 92 target_height_(kDefaultTargetHeight) { |
| 93 // We delete ourselves when we're removed from the view hierarchy. | 93 // We delete ourselves when we're removed from the view hierarchy. |
| 94 set_parent_owned(false); | 94 set_parent_owned(false); |
| 95 | 95 |
| 96 set_background(new InfoBarBackground(delegate->GetInfoBarType())); | 96 set_background(new InfoBarBackground(delegate->GetInfoBarType())); |
| 97 | 97 |
| 98 switch (delegate->GetInfoBarType()) { | 98 switch (delegate->GetInfoBarType()) { |
| 99 case InfoBarDelegate::WARNING_TYPE: | 99 case InfoBarDelegate::WARNING_TYPE: |
| 100 SetAccessibleName(UTF16ToWide( | 100 SetAccessibleName( |
| 101 l10n_util::GetStringUTF16(IDS_ACCNAME_INFOBAR_WARNING))); | 101 l10n_util::GetStringUTF16(IDS_ACCNAME_INFOBAR_WARNING)); |
| 102 break; | 102 break; |
| 103 case InfoBarDelegate::PAGE_ACTION_TYPE: | 103 case InfoBarDelegate::PAGE_ACTION_TYPE: |
| 104 SetAccessibleName(UTF16ToWide( | 104 SetAccessibleName( |
| 105 l10n_util::GetStringUTF16(IDS_ACCNAME_INFOBAR_PAGE_ACTION))); | 105 l10n_util::GetStringUTF16(IDS_ACCNAME_INFOBAR_PAGE_ACTION)); |
| 106 break; | 106 break; |
| 107 default: | 107 default: |
| 108 NOTREACHED(); | 108 NOTREACHED(); |
| 109 break; | 109 break; |
| 110 } | 110 } |
| 111 | 111 |
| 112 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 112 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 113 close_button_->SetImage(views::CustomButton::BS_NORMAL, | 113 close_button_->SetImage(views::CustomButton::BS_NORMAL, |
| 114 rb.GetBitmapNamed(IDR_CLOSE_BAR)); | 114 rb.GetBitmapNamed(IDR_CLOSE_BAR)); |
| 115 close_button_->SetImage(views::CustomButton::BS_HOT, | 115 close_button_->SetImage(views::CustomButton::BS_HOT, |
| 116 rb.GetBitmapNamed(IDR_CLOSE_BAR_H)); | 116 rb.GetBitmapNamed(IDR_CLOSE_BAR_H)); |
| 117 close_button_->SetImage(views::CustomButton::BS_PUSHED, | 117 close_button_->SetImage(views::CustomButton::BS_PUSHED, |
| 118 rb.GetBitmapNamed(IDR_CLOSE_BAR_P)); | 118 rb.GetBitmapNamed(IDR_CLOSE_BAR_P)); |
| 119 close_button_->SetAccessibleName( | 119 close_button_->SetAccessibleName( |
| 120 UTF16ToWide(l10n_util::GetStringUTF16(IDS_ACCNAME_CLOSE))); | 120 l10n_util::GetStringUTF16(IDS_ACCNAME_CLOSE)); |
| 121 AddChildView(close_button_); | 121 AddChildView(close_button_); |
| 122 | 122 |
| 123 animation_.reset(new ui::SlideAnimation(this)); | 123 animation_.reset(new ui::SlideAnimation(this)); |
| 124 animation_->SetTweenType(ui::Tween::LINEAR); | 124 animation_->SetTweenType(ui::Tween::LINEAR); |
| 125 } | 125 } |
| 126 | 126 |
| 127 InfoBar::~InfoBar() { | 127 InfoBar::~InfoBar() { |
| 128 } | 128 } |
| 129 | 129 |
| 130 // InfoBar, views::View overrides: --------------------------------------------- | 130 // InfoBar, views::View overrides: --------------------------------------------- |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 465 // ConfirmInfoBar, public: ----------------------------------------------------- | 465 // ConfirmInfoBar, public: ----------------------------------------------------- |
| 466 | 466 |
| 467 ConfirmInfoBar::ConfirmInfoBar(ConfirmInfoBarDelegate* delegate) | 467 ConfirmInfoBar::ConfirmInfoBar(ConfirmInfoBarDelegate* delegate) |
| 468 : AlertInfoBar(delegate), | 468 : AlertInfoBar(delegate), |
| 469 ok_button_(NULL), | 469 ok_button_(NULL), |
| 470 cancel_button_(NULL), | 470 cancel_button_(NULL), |
| 471 link_(NULL), | 471 link_(NULL), |
| 472 initialized_(false) { | 472 initialized_(false) { |
| 473 ok_button_ = InfoBarTextButton::Create(this, | 473 ok_button_ = InfoBarTextButton::Create(this, |
| 474 delegate->GetButtonLabel(ConfirmInfoBarDelegate::BUTTON_OK)); | 474 delegate->GetButtonLabel(ConfirmInfoBarDelegate::BUTTON_OK)); |
| 475 ok_button_->SetAccessibleName(ok_button_->text()); | 475 ok_button_->SetAccessibleName(WideToUTF16Hack(ok_button_->text())); |
| 476 cancel_button_ = InfoBarTextButton::Create(this, | 476 cancel_button_ = InfoBarTextButton::Create(this, |
| 477 delegate->GetButtonLabel(ConfirmInfoBarDelegate::BUTTON_CANCEL)); | 477 delegate->GetButtonLabel(ConfirmInfoBarDelegate::BUTTON_CANCEL)); |
| 478 cancel_button_->SetAccessibleName(cancel_button_->text()); | 478 cancel_button_->SetAccessibleName(WideToUTF16Hack(cancel_button_->text())); |
| 479 | 479 |
| 480 // Set up the link. | 480 // Set up the link. |
| 481 link_ = new views::Link; | 481 link_ = new views::Link; |
| 482 link_->SetText(UTF16ToWideHack(delegate->GetLinkText())); | 482 link_->SetText(UTF16ToWideHack(delegate->GetLinkText())); |
| 483 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 483 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 484 link_->SetFont(rb.GetFont(ResourceBundle::MediumFont)); | 484 link_->SetFont(rb.GetFont(ResourceBundle::MediumFont)); |
| 485 link_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); | 485 link_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); |
| 486 link_->SetController(this); | 486 link_->SetController(this); |
| 487 link_->MakeReadableOverBackgroundColor(background()->get_color()); | 487 link_->MakeReadableOverBackgroundColor(background()->get_color()); |
| 488 } | 488 } |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 604 | 604 |
| 605 InfoBar* LinkInfoBarDelegate::CreateInfoBar() { | 605 InfoBar* LinkInfoBarDelegate::CreateInfoBar() { |
| 606 return new LinkInfoBar(this); | 606 return new LinkInfoBar(this); |
| 607 } | 607 } |
| 608 | 608 |
| 609 // ConfirmInfoBarDelegate, InfoBarDelegate overrides: -------------------------- | 609 // ConfirmInfoBarDelegate, InfoBarDelegate overrides: -------------------------- |
| 610 | 610 |
| 611 InfoBar* ConfirmInfoBarDelegate::CreateInfoBar() { | 611 InfoBar* ConfirmInfoBarDelegate::CreateInfoBar() { |
| 612 return new ConfirmInfoBar(this); | 612 return new ConfirmInfoBar(this); |
| 613 } | 613 } |
| OLD | NEW |