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/infobars/confirm_infobar_delegate.h" | 8 #include "chrome/browser/infobars/confirm_infobar_delegate.h" |
9 #include "chrome/browser/ui/views/elevation_icon_setter.h" | 9 #include "chrome/browser/ui/views/elevation_icon_setter.h" |
10 #include "ui/base/window_open_disposition.h" | 10 #include "ui/base/window_open_disposition.h" |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 if (delegate->Accept()) | 102 if (delegate->Accept()) |
103 RemoveSelf(); | 103 RemoveSelf(); |
104 } else if ((cancel_button_ != NULL) && (sender == cancel_button_)) { | 104 } else if ((cancel_button_ != NULL) && (sender == cancel_button_)) { |
105 if (delegate->Cancel()) | 105 if (delegate->Cancel()) |
106 RemoveSelf(); | 106 RemoveSelf(); |
107 } else { | 107 } else { |
108 InfoBarView::ButtonPressed(sender, event); | 108 InfoBarView::ButtonPressed(sender, event); |
109 } | 109 } |
110 } | 110 } |
111 | 111 |
112 int ConfirmInfoBar::ContentMinimumWidth() { | 112 int ConfirmInfoBar::ContentMinimumWidth() const { |
113 return label_->GetMinimumSize().width() + link_->GetMinimumSize().width() + | 113 return label_->GetMinimumSize().width() + link_->GetMinimumSize().width() + |
114 NonLabelWidth(); | 114 NonLabelWidth(); |
115 } | 115 } |
116 | 116 |
117 void ConfirmInfoBar::LinkClicked(views::Link* source, int event_flags) { | 117 void ConfirmInfoBar::LinkClicked(views::Link* source, int event_flags) { |
118 if (!owner()) | 118 if (!owner()) |
119 return; // We're closing; don't call anything, it might access the owner. | 119 return; // We're closing; don't call anything, it might access the owner. |
120 DCHECK_EQ(link_, source); | 120 DCHECK_EQ(link_, source); |
121 if (GetDelegate()->LinkClicked(ui::DispositionFromEventFlags(event_flags))) | 121 if (GetDelegate()->LinkClicked(ui::DispositionFromEventFlags(event_flags))) |
122 RemoveSelf(); | 122 RemoveSelf(); |
123 } | 123 } |
124 | 124 |
125 ConfirmInfoBarDelegate* ConfirmInfoBar::GetDelegate() { | 125 ConfirmInfoBarDelegate* ConfirmInfoBar::GetDelegate() { |
126 return delegate()->AsConfirmInfoBarDelegate(); | 126 return delegate()->AsConfirmInfoBarDelegate(); |
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 |