| 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 "base/message_loop.h" | 7 #include "base/message_loop.h" |
| 8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #include "chrome/browser/ui/views/event_utils.h" | 9 #include "chrome/browser/ui/views/event_utils.h" |
| 10 #include "chrome/browser/ui/views/infobars/infobar_container.h" | 10 #include "chrome/browser/ui/views/infobars/infobar_container.h" |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 focus_tracker_.reset(NULL); | 309 focus_tracker_.reset(NULL); |
| 310 } | 310 } |
| 311 } | 311 } |
| 312 | 312 |
| 313 void InfoBar::DeleteSelf() { | 313 void InfoBar::DeleteSelf() { |
| 314 delete this; | 314 delete this; |
| 315 } | 315 } |
| 316 | 316 |
| 317 // AlertInfoBar, public: ------------------------------------------------------- | 317 // AlertInfoBar, public: ------------------------------------------------------- |
| 318 | 318 |
| 319 AlertInfoBar::AlertInfoBar(AlertInfoBarDelegate* delegate) | 319 AlertInfoBar::AlertInfoBar(ConfirmInfoBarDelegate* delegate) |
| 320 : InfoBar(delegate) { | 320 : InfoBar(delegate) { |
| 321 label_ = new views::Label( | 321 label_ = new views::Label( |
| 322 UTF16ToWideHack(delegate->GetMessageText()), | 322 UTF16ToWideHack(delegate->GetMessageText()), |
| 323 ResourceBundle::GetSharedInstance().GetFont(ResourceBundle::MediumFont)); | 323 ResourceBundle::GetSharedInstance().GetFont(ResourceBundle::MediumFont)); |
| 324 label_->SetColor(SK_ColorBLACK); | 324 label_->SetColor(SK_ColorBLACK); |
| 325 label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); | 325 label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); |
| 326 AddChildView(label_); | 326 AddChildView(label_); |
| 327 | 327 |
| 328 icon_ = new views::ImageView; | 328 icon_ = new views::ImageView; |
| 329 if (delegate->GetIcon()) | 329 if (delegate->GetIcon()) |
| (...skipping 16 matching lines...) Expand all Loading... |
| 346 icon_ps.height()); | 346 icon_ps.height()); |
| 347 | 347 |
| 348 gfx::Size text_ps = label_->GetPreferredSize(); | 348 gfx::Size text_ps = label_->GetPreferredSize(); |
| 349 int text_width = std::min( | 349 int text_width = std::min( |
| 350 text_ps.width(), | 350 text_ps.width(), |
| 351 GetAvailableWidth() - icon_->bounds().right() - kIconLabelSpacing); | 351 GetAvailableWidth() - icon_->bounds().right() - kIconLabelSpacing); |
| 352 label_->SetBounds(icon_->bounds().right() + kIconLabelSpacing, | 352 label_->SetBounds(icon_->bounds().right() + kIconLabelSpacing, |
| 353 OffsetY(this, text_ps), text_width, text_ps.height()); | 353 OffsetY(this, text_ps), text_width, text_ps.height()); |
| 354 } | 354 } |
| 355 | 355 |
| 356 // AlertInfoBar, private: ------------------------------------------------------ | |
| 357 | |
| 358 AlertInfoBarDelegate* AlertInfoBar::GetDelegate() { | |
| 359 return delegate()->AsAlertInfoBarDelegate(); | |
| 360 } | |
| 361 | |
| 362 // LinkInfoBar, public: -------------------------------------------------------- | 356 // LinkInfoBar, public: -------------------------------------------------------- |
| 363 | 357 |
| 364 LinkInfoBar::LinkInfoBar(LinkInfoBarDelegate* delegate) | 358 LinkInfoBar::LinkInfoBar(LinkInfoBarDelegate* delegate) |
| 365 : InfoBar(delegate), | 359 : InfoBar(delegate), |
| 366 icon_(new views::ImageView), | 360 icon_(new views::ImageView), |
| 367 label_1_(new views::Label), | 361 label_1_(new views::Label), |
| 368 label_2_(new views::Label), | 362 label_2_(new views::Label), |
| 369 link_(new views::Link) { | 363 link_(new views::Link) { |
| 370 // Set up the icon. | 364 // Set up the icon. |
| 371 if (delegate->GetIcon()) | 365 if (delegate->GetIcon()) |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 591 ConfirmInfoBarDelegate* ConfirmInfoBar::GetDelegate() { | 585 ConfirmInfoBarDelegate* ConfirmInfoBar::GetDelegate() { |
| 592 return delegate()->AsConfirmInfoBarDelegate(); | 586 return delegate()->AsConfirmInfoBarDelegate(); |
| 593 } | 587 } |
| 594 | 588 |
| 595 void ConfirmInfoBar::Init() { | 589 void ConfirmInfoBar::Init() { |
| 596 AddChildView(ok_button_); | 590 AddChildView(ok_button_); |
| 597 AddChildView(cancel_button_); | 591 AddChildView(cancel_button_); |
| 598 AddChildView(link_); | 592 AddChildView(link_); |
| 599 } | 593 } |
| 600 | 594 |
| 601 // AlertInfoBarDelegate, InfoBarDelegate overrides: ---------------------------- | |
| 602 | |
| 603 InfoBar* AlertInfoBarDelegate::CreateInfoBar() { | |
| 604 return new AlertInfoBar(this); | |
| 605 } | |
| 606 | |
| 607 // LinkInfoBarDelegate, InfoBarDelegate overrides: ----------------------------- | 595 // LinkInfoBarDelegate, InfoBarDelegate overrides: ----------------------------- |
| 608 | 596 |
| 609 InfoBar* LinkInfoBarDelegate::CreateInfoBar() { | 597 InfoBar* LinkInfoBarDelegate::CreateInfoBar() { |
| 610 return new LinkInfoBar(this); | 598 return new LinkInfoBar(this); |
| 611 } | 599 } |
| 612 | 600 |
| 613 // ConfirmInfoBarDelegate, InfoBarDelegate overrides: -------------------------- | 601 // ConfirmInfoBarDelegate, InfoBarDelegate overrides: -------------------------- |
| 614 | 602 |
| 615 InfoBar* ConfirmInfoBarDelegate::CreateInfoBar() { | 603 InfoBar* ConfirmInfoBarDelegate::CreateInfoBar() { |
| 616 return new ConfirmInfoBar(this); | 604 return new ConfirmInfoBar(this); |
| 617 } | 605 } |
| OLD | NEW |