| 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 } | 62 } |
| 63 | 63 |
| 64 void ConfirmInfoBar::ViewHierarchyChanged( | 64 void ConfirmInfoBar::ViewHierarchyChanged( |
| 65 const ViewHierarchyChangedDetails& details) { | 65 const ViewHierarchyChangedDetails& details) { |
| 66 if (details.is_add && details.child == this && (label_ == NULL)) { | 66 if (details.is_add && details.child == this && (label_ == NULL)) { |
| 67 ConfirmInfoBarDelegate* delegate = GetDelegate(); | 67 ConfirmInfoBarDelegate* delegate = GetDelegate(); |
| 68 label_ = CreateLabel(delegate->GetMessageText()); | 68 label_ = CreateLabel(delegate->GetMessageText()); |
| 69 AddChildView(label_); | 69 AddChildView(label_); |
| 70 | 70 |
| 71 if (delegate->GetButtons() & ConfirmInfoBarDelegate::BUTTON_OK) { | 71 if (delegate->GetButtons() & ConfirmInfoBarDelegate::BUTTON_OK) { |
| 72 ok_button_ = CreateLabelButton( | 72 if (delegate->OKButtonTriggersUACPrompt()) { |
| 73 this, delegate->GetButtonLabel(ConfirmInfoBarDelegate::BUTTON_OK)); | 73 // Use a label button even in MD mode as MD buttons don't support icons. |
| 74 if (delegate->OKButtonTriggersUACPrompt()) | 74 views::LabelButton* ok_button = CreateLabelButton( |
| 75 this, delegate->GetButtonLabel(ConfirmInfoBarDelegate::BUTTON_OK)); |
| 75 elevation_icon_setter_.reset(new ElevationIconSetter( | 76 elevation_icon_setter_.reset(new ElevationIconSetter( |
| 76 ok_button_, | 77 ok_button, |
| 77 base::Bind(&ConfirmInfoBar::Layout, base::Unretained(this)))); | 78 base::Bind(&ConfirmInfoBar::Layout, base::Unretained(this)))); |
| 79 ok_button_ = ok_button; |
| 80 } else { |
| 81 ok_button_ = CreateTextButton( |
| 82 this, delegate->GetButtonLabel(ConfirmInfoBarDelegate::BUTTON_OK)); |
| 83 } |
| 78 AddChildView(ok_button_); | 84 AddChildView(ok_button_); |
| 79 ok_button_->SizeToPreferredSize(); | 85 ok_button_->SizeToPreferredSize(); |
| 80 } | 86 } |
| 81 | 87 |
| 82 if (delegate->GetButtons() & ConfirmInfoBarDelegate::BUTTON_CANCEL) { | 88 if (delegate->GetButtons() & ConfirmInfoBarDelegate::BUTTON_CANCEL) { |
| 83 cancel_button_ = CreateLabelButton( | 89 cancel_button_ = CreateTextButton( |
| 84 this, | 90 this, |
| 85 delegate->GetButtonLabel(ConfirmInfoBarDelegate::BUTTON_CANCEL)); | 91 delegate->GetButtonLabel(ConfirmInfoBarDelegate::BUTTON_CANCEL)); |
| 86 AddChildView(cancel_button_); | 92 AddChildView(cancel_button_); |
| 87 cancel_button_->SizeToPreferredSize(); | 93 cancel_button_->SizeToPreferredSize(); |
| 88 } | 94 } |
| 89 | 95 |
| 90 base::string16 link_text(delegate->GetLinkText()); | 96 base::string16 link_text(delegate->GetLinkText()); |
| 91 link_ = CreateLink(link_text, this); | 97 link_ = CreateLink(link_text, this); |
| 92 AddChildView(link_); | 98 AddChildView(link_); |
| 93 } | 99 } |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 } | 137 } |
| 132 | 138 |
| 133 int ConfirmInfoBar::NonLabelWidth() const { | 139 int ConfirmInfoBar::NonLabelWidth() const { |
| 134 int width = (label_->text().empty() || (!ok_button_ && !cancel_button_)) ? | 140 int width = (label_->text().empty() || (!ok_button_ && !cancel_button_)) ? |
| 135 0 : kEndOfLabelSpacing; | 141 0 : kEndOfLabelSpacing; |
| 136 if (ok_button_) | 142 if (ok_button_) |
| 137 width += ok_button_->width() + (cancel_button_ ? kButtonButtonSpacing : 0); | 143 width += ok_button_->width() + (cancel_button_ ? kButtonButtonSpacing : 0); |
| 138 width += cancel_button_ ? cancel_button_->width() : 0; | 144 width += cancel_button_ ? cancel_button_->width() : 0; |
| 139 return width + ((link_->text().empty() || !width) ? 0 : kEndOfLabelSpacing); | 145 return width + ((link_->text().empty() || !width) ? 0 : kEndOfLabelSpacing); |
| 140 } | 146 } |
| OLD | NEW |