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/confirm_infobar.h" | 5 #include "chrome/browser/ui/views/infobars/confirm_infobar.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "chrome/browser/ui/views/elevation_icon_setter.h" | 8 #include "chrome/browser/ui/views/elevation_icon_setter.h" |
9 #include "components/infobars/core/confirm_infobar_delegate.h" | 9 #include "components/infobars/core/confirm_infobar_delegate.h" |
10 #include "ui/base/window_open_disposition.h" | 10 #include "ui/base/window_open_disposition.h" |
11 #include "ui/views/controls/button/label_button.h" | 11 #include "ui/views/controls/button/label_button.h" |
12 #include "ui/views/controls/label.h" | 12 #include "ui/views/controls/label.h" |
13 #include "ui/views/controls/link.h" | 13 #include "ui/views/controls/link.h" |
14 | 14 |
15 | 15 |
16 // ConfirmInfoBarDelegate ----------------------------------------------------- | 16 // ConfirmInfoBarDelegate ----------------------------------------------------- |
17 | 17 |
18 // static | 18 // static |
19 scoped_ptr<infobars::InfoBar> ConfirmInfoBarDelegate::CreateInfoBar( | 19 scoped_ptr<infobars::InfoBar> ConfirmInfoBarDelegate::CreateInfoBar( |
20 scoped_ptr<ConfirmInfoBarDelegate> delegate) { | 20 scoped_ptr<ConfirmInfoBarDelegate> delegate) { |
21 return scoped_ptr<infobars::InfoBar>(new ConfirmInfoBar(delegate.Pass())); | 21 return make_scoped_ptr(new ConfirmInfoBar(delegate.Pass())); |
22 } | 22 } |
23 | 23 |
24 | 24 |
25 // ConfirmInfoBar ------------------------------------------------------------- | 25 // ConfirmInfoBar ------------------------------------------------------------- |
26 | 26 |
27 ConfirmInfoBar::ConfirmInfoBar(scoped_ptr<ConfirmInfoBarDelegate> delegate) | 27 ConfirmInfoBar::ConfirmInfoBar(scoped_ptr<ConfirmInfoBarDelegate> delegate) |
28 : InfoBarView(delegate.PassAs<infobars::InfoBarDelegate>()), | 28 : InfoBarView(delegate.Pass()), |
29 label_(NULL), | 29 label_(NULL), |
30 ok_button_(NULL), | 30 ok_button_(NULL), |
31 cancel_button_(NULL), | 31 cancel_button_(NULL), |
32 link_(NULL) { | 32 link_(NULL) { |
33 } | 33 } |
34 | 34 |
35 ConfirmInfoBar::~ConfirmInfoBar() { | 35 ConfirmInfoBar::~ConfirmInfoBar() { |
36 // Ensure |elevation_icon_setter_| is destroyed before |ok_button_|. | 36 // Ensure |elevation_icon_setter_| is destroyed before |ok_button_|. |
37 elevation_icon_setter_.reset(); | 37 elevation_icon_setter_.reset(); |
38 } | 38 } |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 } | 127 } |
128 | 128 |
129 int ConfirmInfoBar::NonLabelWidth() const { | 129 int ConfirmInfoBar::NonLabelWidth() const { |
130 int width = (label_->text().empty() || (!ok_button_ && !cancel_button_)) ? | 130 int width = (label_->text().empty() || (!ok_button_ && !cancel_button_)) ? |
131 0 : kEndOfLabelSpacing; | 131 0 : kEndOfLabelSpacing; |
132 if (ok_button_) | 132 if (ok_button_) |
133 width += ok_button_->width() + (cancel_button_ ? kButtonButtonSpacing : 0); | 133 width += ok_button_->width() + (cancel_button_ ? kButtonButtonSpacing : 0); |
134 width += (cancel_button_ ? cancel_button_->width() : 0); | 134 width += (cancel_button_ ? cancel_button_->width() : 0); |
135 return width + ((link_->text().empty() || !width) ? 0 : kEndOfLabelSpacing); | 135 return width + ((link_->text().empty() || !width) ? 0 : kEndOfLabelSpacing); |
136 } | 136 } |
OLD | NEW |