| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/views/infobars/infobars.h" | 5 #include "chrome/browser/views/infobars/infobars.h" |
| 6 | 6 |
| 7 #include "app/gfx/canvas.h" | 7 #include "app/gfx/canvas.h" |
| 8 #include "app/l10n_util.h" | 8 #include "app/l10n_util.h" |
| 9 #include "app/resource_bundle.h" | 9 #include "app/resource_bundle.h" |
| 10 #include "app/slide_animation.h" | 10 #include "app/slide_animation.h" |
| 11 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
| 12 #include "chrome/browser/views/event_utils.h" | 12 #include "chrome/browser/views/event_utils.h" |
| 13 #include "chrome/browser/views/infobars/infobar_container.h" | 13 #include "chrome/browser/views/infobars/infobar_container.h" |
| 14 #include "grit/generated_resources.h" | 14 #include "grit/generated_resources.h" |
| 15 #include "grit/theme_resources.h" | 15 #include "grit/theme_resources.h" |
| 16 #include "views/background.h" | 16 #include "views/background.h" |
| 17 #include "views/controls/button/image_button.h" | 17 #include "views/controls/button/image_button.h" |
| 18 #include "views/controls/button/native_button.h" | 18 #include "views/controls/button/native_button.h" |
| 19 #include "views/controls/image_view.h" | 19 #include "views/controls/image_view.h" |
| 20 #include "views/controls/label.h" | 20 #include "views/controls/label.h" |
| 21 #include "views/focus/external_focus_tracker.h" | 21 #include "views/focus/external_focus_tracker.h" |
| 22 #include "views/widget/widget.h" | 22 #include "views/widget/widget.h" |
| 23 | 23 |
| 24 // static | 24 // static |
| 25 const double InfoBar::kTargetHeight = 37.0; | 25 const double InfoBar::kTargetHeight = 37.0; |
| 26 | 26 |
| 27 static const int kVerticalPadding = 3; | 27 static const int kVerticalPadding = 3; |
| 28 static const int kHorizontalPadding = 3; | 28 static const int kHorizontalPadding = 3; |
| 29 static const int kIconLabelSpacing = 5; | 29 static const int kIconLabelSpacing = 5; |
| 30 static const int kButtonSpacing = 5; | 30 static const int kButtonSpacing = 5; |
| 31 static const int kWordSpacing = 2; | |
| 32 | 31 |
| 33 static const SkColor kInfoBackgroundColorTop = SkColorSetRGB(170, 214, 112); | 32 static const SkColor kInfoBackgroundColorTop = SkColorSetRGB(170, 214, 112); |
| 34 static const SkColor kInfoBackgroundColorBottom = SkColorSetRGB(146, 205, 114); | 33 static const SkColor kInfoBackgroundColorBottom = SkColorSetRGB(146, 205, 114); |
| 35 | 34 |
| 36 static const SkColor kWarningBackgroundColorTop = SkColorSetRGB(255, 242, 183); | 35 static const SkColor kWarningBackgroundColorTop = SkColorSetRGB(255, 242, 183); |
| 37 static const SkColor kWarningBackgroundColorBottom = | 36 static const SkColor kWarningBackgroundColorBottom = |
| 38 SkColorSetRGB(250, 230, 145); | 37 SkColorSetRGB(250, 230, 145); |
| 39 | 38 |
| 40 static const SkColor kErrorBackgroundColorTop = kWarningBackgroundColorTop; | 39 static const SkColor kErrorBackgroundColorTop = kWarningBackgroundColorTop; |
| 41 static const SkColor kErrorBackgroundColorBottom = | 40 static const SkColor kErrorBackgroundColorBottom = |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 // Layout the left label. | 378 // Layout the left label. |
| 380 gfx::Size label_1_ps = label_1_->GetPreferredSize(); | 379 gfx::Size label_1_ps = label_1_->GetPreferredSize(); |
| 381 label_1_->SetBounds(label_1_x, OffsetY(this, label_1_ps), label_1_ps.width(), | 380 label_1_->SetBounds(label_1_x, OffsetY(this, label_1_ps), label_1_ps.width(), |
| 382 label_1_ps.height()); | 381 label_1_ps.height()); |
| 383 | 382 |
| 384 // Layout the link. | 383 // Layout the link. |
| 385 gfx::Size link_ps = link_->GetPreferredSize(); | 384 gfx::Size link_ps = link_->GetPreferredSize(); |
| 386 bool has_second_label = !label_2_->GetText().empty(); | 385 bool has_second_label = !label_2_->GetText().empty(); |
| 387 if (has_second_label) { | 386 if (has_second_label) { |
| 388 // Embed the link in the text string between the two labels. | 387 // Embed the link in the text string between the two labels. |
| 389 link_->SetBounds(label_1_->bounds().right() + kWordSpacing, | 388 link_->SetBounds(label_1_->bounds().right(), |
| 390 OffsetY(this, link_ps), link_ps.width(), link_ps.height()); | 389 OffsetY(this, link_ps), link_ps.width(), link_ps.height()); |
| 391 } else { | 390 } else { |
| 392 // Right-align the link toward the edge of the InfoBar. | 391 // Right-align the link toward the edge of the InfoBar. |
| 393 link_->SetBounds(label_1_x + available_width - link_ps.width(), | 392 link_->SetBounds(label_1_x + available_width - link_ps.width(), |
| 394 OffsetY(this, link_ps), link_ps.width(), link_ps.height()); | 393 OffsetY(this, link_ps), link_ps.width(), link_ps.height()); |
| 395 } | 394 } |
| 396 | 395 |
| 397 // Layout the right label (we do this regardless of whether or not it has | 396 // Layout the right label (we do this regardless of whether or not it has |
| 398 // text). | 397 // text). |
| 399 gfx::Size label_2_ps = label_2_->GetPreferredSize(); | 398 gfx::Size label_2_ps = label_2_->GetPreferredSize(); |
| 400 label_2_->SetBounds(link_->bounds().right() + kWordSpacing, | 399 label_2_->SetBounds(link_->bounds().right(), |
| 401 OffsetY(this, label_2_ps), label_2_ps.width(), | 400 OffsetY(this, label_2_ps), label_2_ps.width(), |
| 402 label_2_ps.height()); | 401 label_2_ps.height()); |
| 403 } | 402 } |
| 404 | 403 |
| 405 // LinkInfoBar, private: ------------------------------------------------------- | 404 // LinkInfoBar, private: ------------------------------------------------------- |
| 406 | 405 |
| 407 LinkInfoBarDelegate* LinkInfoBar::GetDelegate() { | 406 LinkInfoBarDelegate* LinkInfoBar::GetDelegate() { |
| 408 return delegate()->AsLinkInfoBarDelegate(); | 407 return delegate()->AsLinkInfoBarDelegate(); |
| 409 } | 408 } |
| 410 | 409 |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 511 | 510 |
| 512 InfoBar* LinkInfoBarDelegate::CreateInfoBar() { | 511 InfoBar* LinkInfoBarDelegate::CreateInfoBar() { |
| 513 return new LinkInfoBar(this); | 512 return new LinkInfoBar(this); |
| 514 } | 513 } |
| 515 | 514 |
| 516 // ConfirmInfoBarDelegate, InfoBarDelegate overrides: -------------------------- | 515 // ConfirmInfoBarDelegate, InfoBarDelegate overrides: -------------------------- |
| 517 | 516 |
| 518 InfoBar* ConfirmInfoBarDelegate::CreateInfoBar() { | 517 InfoBar* ConfirmInfoBarDelegate::CreateInfoBar() { |
| 519 return new ConfirmInfoBar(this); | 518 return new ConfirmInfoBar(this); |
| 520 } | 519 } |
| OLD | NEW |