| 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" |
| 11 #include "chrome/browser/ui/views/event_utils.h" | 11 #include "chrome/browser/ui/views/event_utils.h" |
| 12 #include "chrome/browser/ui/views/infobars/infobar_container.h" | 12 #include "chrome/browser/ui/views/infobars/infobar_container.h" |
| 13 #include "chrome/browser/ui/views/infobars/infobar_text_button.h" | 13 #include "chrome/browser/ui/views/infobars/infobar_text_button.h" |
| 14 #include "gfx/canvas.h" | 14 #include "gfx/canvas.h" |
| 15 #include "grit/generated_resources.h" | 15 #include "grit/generated_resources.h" |
| 16 #include "grit/theme_resources.h" | 16 #include "grit/theme_resources.h" |
| 17 #include "ui/base/animation/slide_animation.h" | 17 #include "ui/base/animation/slide_animation.h" |
| 18 #include "views/background.h" | 18 #include "views/background.h" |
| 19 #include "views/controls/button/image_button.h" | 19 #include "views/controls/button/image_button.h" |
| 20 #include "views/controls/button/native_button.h" | 20 #include "views/controls/button/native_button.h" |
| 21 #include "views/controls/image_view.h" | 21 #include "views/controls/image_view.h" |
| 22 #include "views/controls/label.h" | 22 #include "views/controls/label.h" |
| 23 #include "views/focus/external_focus_tracker.h" | 23 #include "views/focus/external_focus_tracker.h" |
| 24 #include "views/widget/widget.h" | 24 #include "views/widget/widget.h" |
| 25 | 25 |
| 26 #if defined(OS_WIN) | 26 #if defined(OS_WIN) |
| 27 #include "app/win/hwnd_util.h" | 27 #include "ui/base/win/hwnd_util.h" |
| 28 #endif | 28 #endif |
| 29 | 29 |
| 30 // static | 30 // static |
| 31 const double InfoBar::kDefaultTargetHeight = 36.0; | 31 const double InfoBar::kDefaultTargetHeight = 36.0; |
| 32 const int InfoBar::kHorizontalPadding = 6; | 32 const int InfoBar::kHorizontalPadding = 6; |
| 33 const int InfoBar::kIconLabelSpacing = 6; | 33 const int InfoBar::kIconLabelSpacing = 6; |
| 34 const int InfoBar::kButtonButtonSpacing = 10; | 34 const int InfoBar::kButtonButtonSpacing = 10; |
| 35 const int InfoBar::kEndOfLabelSpacing = 16; | 35 const int InfoBar::kEndOfLabelSpacing = 16; |
| 36 const int InfoBar::kCloseButtonSpacing = 12; | 36 const int InfoBar::kCloseButtonSpacing = 12; |
| 37 const int InfoBar::kButtonInLabelSpacing = 5; | 37 const int InfoBar::kButtonInLabelSpacing = 5; |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 if (container_) | 240 if (container_) |
| 241 container_->InfoBarAnimated(false); | 241 container_->InfoBarAnimated(false); |
| 242 } | 242 } |
| 243 | 243 |
| 244 void InfoBar::AnimateClose() { | 244 void InfoBar::AnimateClose() { |
| 245 bool restore_focus = true; | 245 bool restore_focus = true; |
| 246 #if defined(OS_WIN) | 246 #if defined(OS_WIN) |
| 247 // Do not restore focus (and active state with it) on Windows if some other | 247 // Do not restore focus (and active state with it) on Windows if some other |
| 248 // top-level window became active. | 248 // top-level window became active. |
| 249 if (GetWidget() && | 249 if (GetWidget() && |
| 250 !app::win::DoesWindowBelongToActiveWindow(GetWidget()->GetNativeView())) { | 250 !ui::DoesWindowBelongToActiveWindow(GetWidget()->GetNativeView())) { |
| 251 restore_focus = false; | 251 restore_focus = false; |
| 252 } | 252 } |
| 253 #endif // defined(OS_WIN) | 253 #endif // defined(OS_WIN) |
| 254 DestroyFocusTracker(restore_focus); | 254 DestroyFocusTracker(restore_focus); |
| 255 animation_->Hide(); | 255 animation_->Hide(); |
| 256 } | 256 } |
| 257 | 257 |
| 258 void InfoBar::Close() { | 258 void InfoBar::Close() { |
| 259 GetParent()->RemoveChildView(this); | 259 GetParent()->RemoveChildView(this); |
| 260 // Note that we only tell the delegate we're closed here, and not when we're | 260 // Note that we only tell the delegate we're closed here, and not when we're |
| (...skipping 343 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 |