Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6827)

Unified Diff: chrome/browser/ui/views/infobars/confirm_infobar.cc

Issue 2812243007: Replace layout constants in chrome/browser/ui/views/infobars. (Closed)
Patch Set: Fix compile failure Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/views/infobars/confirm_infobar.cc
diff --git a/chrome/browser/ui/views/infobars/confirm_infobar.cc b/chrome/browser/ui/views/infobars/confirm_infobar.cc
index 593af479621f65e4bd9e805ff9a044955cb8fb9b..98fa81a912e1dca093db291c0026aae8047166ff 100644
--- a/chrome/browser/ui/views/infobars/confirm_infobar.cc
+++ b/chrome/browser/ui/views/infobars/confirm_infobar.cc
@@ -10,6 +10,7 @@
#include "base/memory/ptr_util.h"
#include "chrome/browser/infobars/infobar_service.h"
#include "chrome/browser/ui/views/elevation_icon_setter.h"
+#include "chrome/browser/ui/views/harmony/chrome_layout_provider.h"
#include "components/infobars/core/confirm_infobar_delegate.h"
#include "ui/base/material_design/material_design_controller.h"
#include "ui/base/window_open_disposition.h"
@@ -18,14 +19,6 @@
#include "ui/views/controls/button/md_text_button.h"
#include "ui/views/controls/label.h"
#include "ui/views/controls/link.h"
-#include "ui/views/layout/layout_constants.h"
-
-namespace {
-
-constexpr int kButtonButtonSpacing = views::kRelatedButtonHSpacing;
-constexpr int kEndOfLabelSpacing = views::kItemLabelSpacing;
-
-} // namespace
// InfoBarService -------------------------------------------------------------
@@ -64,11 +57,15 @@ void ConfirmInfoBar::Layout() {
label_->SetPosition(gfx::Point(x, OffsetY(label_)));
if (!label_->text().empty())
- x = label_->bounds().right() + kEndOfLabelSpacing;
+ x = label_->bounds().right() +
+ ChromeLayoutProvider::Get()->GetDistanceMetric(
Peter Kasting 2017/04/14 07:42:32 Nit: Pull layout provider out to a temp for reuse
ananta 2017/04/14 18:32:33 Done.
+ DISTANCE_RELATED_LABEL_HORIZONTAL);
if (ok_button_) {
ok_button_->SetPosition(gfx::Point(x, OffsetY(ok_button_)));
- x = ok_button_->bounds().right() + kButtonButtonSpacing;
+ x = ok_button_->bounds().right() +
+ ChromeLayoutProvider::Get()->GetDistanceMetric(
+ views::DISTANCE_RELATED_BUTTON_HORIZONTAL);
}
if (cancel_button_)
@@ -153,10 +150,20 @@ ConfirmInfoBarDelegate* ConfirmInfoBar::GetDelegate() {
}
int ConfirmInfoBar::NonLabelWidth() const {
- int width = (label_->text().empty() || (!ok_button_ && !cancel_button_)) ?
- 0 : kEndOfLabelSpacing;
+ int related_label_horizontal_spacing =
Peter Kasting 2017/04/14 07:42:32 Nit: Try for a shorter name if it's still readable
ananta 2017/04/14 18:32:33 Done.
+ ChromeLayoutProvider::Get()->GetDistanceMetric(
+ DISTANCE_RELATED_LABEL_HORIZONTAL);
+ int related_button_horizontal_spacing =
+ ChromeLayoutProvider::Get()->GetDistanceMetric(
+ views::DISTANCE_RELATED_BUTTON_HORIZONTAL);
+ int width = (label_->text().empty() || (!ok_button_ && !cancel_button_))
+ ? 0
+ : related_label_horizontal_spacing;
if (ok_button_)
- width += ok_button_->width() + (cancel_button_ ? kButtonButtonSpacing : 0);
+ width += ok_button_->width() +
+ (cancel_button_ ? related_button_horizontal_spacing : 0);
width += cancel_button_ ? cancel_button_->width() : 0;
- return width + ((link_->text().empty() || !width) ? 0 : kEndOfLabelSpacing);
+ return width + ((link_->text().empty() || !width)
+ ? 0
+ : related_label_horizontal_spacing);
}
« no previous file with comments | « no previous file | chrome/browser/ui/views/infobars/infobar_view.cc » ('j') | chrome/browser/ui/views/infobars/infobar_view.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698