| 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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| 11 #include "chrome/browser/infobars/infobar_service.h" | 11 #include "chrome/browser/infobars/infobar_service.h" |
| 12 #include "chrome/browser/ui/views/elevation_icon_setter.h" | 12 #include "chrome/browser/ui/views/elevation_icon_setter.h" |
| 13 #include "components/infobars/core/confirm_infobar_delegate.h" | 13 #include "components/infobars/core/confirm_infobar_delegate.h" |
| 14 #include "ui/base/material_design/material_design_controller.h" | 14 #include "ui/base/material_design/material_design_controller.h" |
| 15 #include "ui/base/window_open_disposition.h" | 15 #include "ui/base/window_open_disposition.h" |
| 16 #include "ui/native_theme/native_theme.h" | 16 #include "ui/native_theme/native_theme.h" |
| 17 #include "ui/views/controls/button/label_button.h" | 17 #include "ui/views/controls/button/label_button.h" |
| 18 #include "ui/views/controls/button/md_text_button.h" | 18 #include "ui/views/controls/button/md_text_button.h" |
| 19 #include "ui/views/controls/label.h" | 19 #include "ui/views/controls/label.h" |
| 20 #include "ui/views/controls/link.h" | 20 #include "ui/views/controls/link.h" |
| 21 #include "ui/views/layout/layout_constants.h" |
| 22 |
| 23 namespace { |
| 24 |
| 25 constexpr int kButtonButtonSpacing = views::kRelatedButtonHSpacing; |
| 26 constexpr int kEndOfLabelSpacing = views::kItemLabelSpacing; |
| 27 |
| 28 } // namespace |
| 21 | 29 |
| 22 // InfoBarService ------------------------------------------------------------- | 30 // InfoBarService ------------------------------------------------------------- |
| 23 | 31 |
| 24 std::unique_ptr<infobars::InfoBar> InfoBarService::CreateConfirmInfoBar( | 32 std::unique_ptr<infobars::InfoBar> InfoBarService::CreateConfirmInfoBar( |
| 25 std::unique_ptr<ConfirmInfoBarDelegate> delegate) { | 33 std::unique_ptr<ConfirmInfoBarDelegate> delegate) { |
| 26 return base::MakeUnique<ConfirmInfoBar>(std::move(delegate)); | 34 return base::MakeUnique<ConfirmInfoBar>(std::move(delegate)); |
| 27 } | 35 } |
| 28 | 36 |
| 29 | 37 |
| 30 // ConfirmInfoBar ------------------------------------------------------------- | 38 // ConfirmInfoBar ------------------------------------------------------------- |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 } | 153 } |
| 146 | 154 |
| 147 int ConfirmInfoBar::NonLabelWidth() const { | 155 int ConfirmInfoBar::NonLabelWidth() const { |
| 148 int width = (label_->text().empty() || (!ok_button_ && !cancel_button_)) ? | 156 int width = (label_->text().empty() || (!ok_button_ && !cancel_button_)) ? |
| 149 0 : kEndOfLabelSpacing; | 157 0 : kEndOfLabelSpacing; |
| 150 if (ok_button_) | 158 if (ok_button_) |
| 151 width += ok_button_->width() + (cancel_button_ ? kButtonButtonSpacing : 0); | 159 width += ok_button_->width() + (cancel_button_ ? kButtonButtonSpacing : 0); |
| 152 width += cancel_button_ ? cancel_button_->width() : 0; | 160 width += cancel_button_ ? cancel_button_->width() : 0; |
| 153 return width + ((link_->text().empty() || !width) ? 0 : kEndOfLabelSpacing); | 161 return width + ((link_->text().empty() || !width) ? 0 : kEndOfLabelSpacing); |
| 154 } | 162 } |
| OLD | NEW |