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/infobar_service.h" | 8 #include "chrome/browser/infobars/infobar_service.h" |
9 #include "chrome/browser/ui/views/elevation_icon_setter.h" | 9 #include "chrome/browser/ui/views/elevation_icon_setter.h" |
10 #include "components/infobars/core/confirm_infobar_delegate.h" | 10 #include "components/infobars/core/confirm_infobar_delegate.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
64 const ViewHierarchyChangedDetails& details) { | 64 const ViewHierarchyChangedDetails& details) { |
65 if (details.is_add && details.child == this && (label_ == NULL)) { | 65 if (details.is_add && details.child == this && (label_ == NULL)) { |
66 ConfirmInfoBarDelegate* delegate = GetDelegate(); | 66 ConfirmInfoBarDelegate* delegate = GetDelegate(); |
67 label_ = CreateLabel(delegate->GetMessageText()); | 67 label_ = CreateLabel(delegate->GetMessageText()); |
68 AddChildView(label_); | 68 AddChildView(label_); |
69 | 69 |
70 if (delegate->GetButtons() & ConfirmInfoBarDelegate::BUTTON_OK) { | 70 if (delegate->GetButtons() & ConfirmInfoBarDelegate::BUTTON_OK) { |
71 ok_button_ = CreateLabelButton( | 71 ok_button_ = CreateLabelButton( |
72 this, delegate->GetButtonLabel(ConfirmInfoBarDelegate::BUTTON_OK)); | 72 this, delegate->GetButtonLabel(ConfirmInfoBarDelegate::BUTTON_OK)); |
73 if (delegate->OKButtonTriggersUACPrompt()) | 73 if (delegate->OKButtonTriggersUACPrompt()) |
74 elevation_icon_setter_.reset(new ElevationIconSetter(ok_button_)); | 74 elevation_icon_setter_.reset(new ElevationIconSetter( |
75 ok_button_, | |
76 base::Bind(&ConfirmInfoBar::InvalidateLayout, AsWeakPtr()))); | |
Peter Kasting
2015/02/23 21:26:48
I would bind to Layout() rather than InvalidateLay
xiaoling
2015/02/23 21:50:04
Done.
| |
75 AddChildView(ok_button_); | 77 AddChildView(ok_button_); |
76 } | 78 } |
77 | 79 |
78 if (delegate->GetButtons() & ConfirmInfoBarDelegate::BUTTON_CANCEL) { | 80 if (delegate->GetButtons() & ConfirmInfoBarDelegate::BUTTON_CANCEL) { |
79 cancel_button_ = CreateLabelButton( | 81 cancel_button_ = CreateLabelButton( |
80 this, | 82 this, |
81 delegate->GetButtonLabel(ConfirmInfoBarDelegate::BUTTON_CANCEL)); | 83 delegate->GetButtonLabel(ConfirmInfoBarDelegate::BUTTON_CANCEL)); |
82 AddChildView(cancel_button_); | 84 AddChildView(cancel_button_); |
83 } | 85 } |
84 | 86 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
126 } | 128 } |
127 | 129 |
128 int ConfirmInfoBar::NonLabelWidth() const { | 130 int ConfirmInfoBar::NonLabelWidth() const { |
129 int width = (label_->text().empty() || (!ok_button_ && !cancel_button_)) ? | 131 int width = (label_->text().empty() || (!ok_button_ && !cancel_button_)) ? |
130 0 : kEndOfLabelSpacing; | 132 0 : kEndOfLabelSpacing; |
131 if (ok_button_) | 133 if (ok_button_) |
132 width += ok_button_->width() + (cancel_button_ ? kButtonButtonSpacing : 0); | 134 width += ok_button_->width() + (cancel_button_ ? kButtonButtonSpacing : 0); |
133 width += (cancel_button_ ? cancel_button_->width() : 0); | 135 width += (cancel_button_ ? cancel_button_->width() : 0); |
134 return width + ((link_->text().empty() || !width) ? 0 : kEndOfLabelSpacing); | 136 return width + ((link_->text().empty() || !width) ? 0 : kEndOfLabelSpacing); |
135 } | 137 } |
OLD | NEW |