| Index: chrome/browser/ui/views/chrome_views_delegate.cc
|
| diff --git a/chrome/browser/ui/views/chrome_views_delegate.cc b/chrome/browser/ui/views/chrome_views_delegate.cc
|
| index 3116c947b718459f008d19d1a824f18a4ff17cb9..d469dfc209b0a17eeea7361c9b0bd8c78c54d89d 100644
|
| --- a/chrome/browser/ui/views/chrome_views_delegate.cc
|
| +++ b/chrome/browser/ui/views/chrome_views_delegate.cc
|
| @@ -198,6 +198,8 @@ void ProcessAcceleratorNow(const ui::Accelerator& accelerator) {
|
| }
|
| #endif // defined(USE_ASH)
|
|
|
| +ChromeViewsDelegate* views_delegate = nullptr;
|
| +
|
| } // namespace
|
|
|
|
|
| @@ -210,10 +212,19 @@ ChromeViewsDelegate::ChromeViewsDelegate()
|
| #else
|
| ChromeViewsDelegate::ChromeViewsDelegate() {
|
| #endif
|
| + DCHECK(!views_delegate);
|
| + views_delegate = this;
|
| }
|
|
|
| ChromeViewsDelegate::~ChromeViewsDelegate() {
|
| DCHECK_EQ(0u, ref_count_);
|
| +
|
| + DCHECK_EQ(this, views_delegate);
|
| + views_delegate = nullptr;
|
| +}
|
| +
|
| +ChromeViewsDelegate* ChromeViewsDelegate::GetInstance() {
|
| + return views_delegate;
|
| }
|
|
|
| void ChromeViewsDelegate::SaveWindowPlacement(const views::Widget* window,
|
| @@ -549,58 +560,56 @@ ChromeViewsDelegate::GetBlockingPoolTaskRunner() {
|
| return content::BrowserThread::GetBlockingPool();
|
| }
|
|
|
| -gfx::Insets ChromeViewsDelegate::GetDialogButtonInsets() const {
|
| - const LayoutDelegate* layout_delegate = LayoutDelegate::Get();
|
| - const int top = layout_delegate->GetMetric(
|
| - LayoutDelegate::Metric::DIALOG_BUTTON_TOP_SPACING);
|
| - const int margin = layout_delegate->GetMetric(
|
| - LayoutDelegate::Metric::DIALOG_BUTTON_MARGIN);
|
| - return gfx::Insets(top, margin, margin, margin);
|
| -}
|
| -
|
| -int ChromeViewsDelegate::GetDialogCloseButtonMargin() const {
|
| - return LayoutDelegate::Get()->GetMetric(
|
| - LayoutDelegate::Metric::DIALOG_CLOSE_BUTTON_MARGIN);
|
| -}
|
| -
|
| -int ChromeViewsDelegate::GetDialogRelatedButtonHorizontalSpacing() const {
|
| - return LayoutDelegate::Get()->GetMetric(
|
| - LayoutDelegate::Metric::RELATED_BUTTON_HORIZONTAL_SPACING);
|
| -}
|
| -
|
| -int ChromeViewsDelegate::GetDialogRelatedControlVerticalSpacing() const {
|
| - return LayoutDelegate::Get()->GetMetric(
|
| - LayoutDelegate::Metric::RELATED_CONTROL_VERTICAL_SPACING);
|
| -}
|
| -
|
| -gfx::Insets ChromeViewsDelegate::GetDialogFrameViewInsets() const {
|
| +gfx::Insets ChromeViewsDelegate::GetInsetsMetric(
|
| + views::InsetsMetric metric) const {
|
| const LayoutDelegate* layout_delegate = LayoutDelegate::Get();
|
| - const int top = layout_delegate->GetMetric(
|
| - LayoutDelegate::Metric::PANEL_CONTENT_MARGIN);
|
| - const int side = layout_delegate->GetMetric(
|
| - LayoutDelegate::Metric::DIALOG_BUTTON_MARGIN);
|
| - // Titles are inset at the top and sides, but not at the bottom.
|
| - return gfx::Insets(top, side, 0, side);
|
| -}
|
| -
|
| -gfx::Insets ChromeViewsDelegate::GetBubbleDialogMargins() const {
|
| - return gfx::Insets(LayoutDelegate::Get()->GetMetric(
|
| - LayoutDelegate::Metric::PANEL_CONTENT_MARGIN));
|
| -}
|
| -
|
| -int ChromeViewsDelegate::GetButtonMinimumWidth() const {
|
| - return LayoutDelegate::Get()->GetMetric(
|
| - LayoutDelegate::Metric::BUTTON_MINIMUM_WIDTH);
|
| -}
|
| -
|
| -int ChromeViewsDelegate::GetDialogButtonMinimumWidth() const {
|
| - return LayoutDelegate::Get()->GetMetric(
|
| - LayoutDelegate::Metric::DIALOG_BUTTON_MINIMUM_WIDTH);
|
| -}
|
| -
|
| -int ChromeViewsDelegate::GetButtonHorizontalPadding() const {
|
| - return LayoutDelegate::Get()->GetMetric(
|
| - LayoutDelegate::Metric::BUTTON_HORIZONTAL_PADDING);
|
| + switch (metric) {
|
| + case views::InsetsMetric::DIALOG_BUTTON: {
|
| + const int top = layout_delegate->GetMetric(
|
| + LayoutDelegate::Metric::DIALOG_BUTTON_TOP_SPACING);
|
| + const int margin = layout_delegate->GetMetric(
|
| + LayoutDelegate::Metric::DIALOG_BUTTON_MARGIN);
|
| + return gfx::Insets(top, margin, margin, margin);
|
| + }
|
| + case views::InsetsMetric::DIALOG_FRAME_VIEW: {
|
| + const int top = layout_delegate->GetMetric(
|
| + LayoutDelegate::Metric::PANEL_CONTENT_MARGIN);
|
| + const int side = layout_delegate->GetMetric(
|
| + LayoutDelegate::Metric::DIALOG_BUTTON_MARGIN);
|
| + // Titles are inset at the top and sides, but not at the bottom.
|
| + return gfx::Insets(top, side, 0, side);
|
| + }
|
| + case views::InsetsMetric::BUBBLE_DIALOG:
|
| + return gfx::Insets(layout_delegate->GetMetric(
|
| + LayoutDelegate::Metric::PANEL_CONTENT_MARGIN));
|
| + }
|
| + NOTREACHED();
|
| + return gfx::Insets();
|
| +}
|
| +
|
| +int ChromeViewsDelegate::GetSpacingMetric(views::SpacingMetric metric) const {
|
| + switch (metric) {
|
| + case views::SpacingMetric::CLOSE_BUTTON_MARGIN:
|
| + return LayoutDelegate::Get()->GetMetric(
|
| + LayoutDelegate::Metric::DIALOG_CLOSE_BUTTON_MARGIN);
|
| + case views::SpacingMetric::RELATED_HORIZONTAL_BUTTON:
|
| + return LayoutDelegate::Get()->GetMetric(
|
| + LayoutDelegate::Metric::RELATED_BUTTON_HORIZONTAL_SPACING);
|
| + case views::SpacingMetric::RELATED_VERTICAL_CONTROL:
|
| + return LayoutDelegate::Get()->GetMetric(
|
| + LayoutDelegate::Metric::RELATED_CONTROL_VERTICAL_SPACING);
|
| + case views::SpacingMetric::ICON_TO_TEXT:
|
| + return LayoutDelegate::Get()->GetMetric(
|
| + LayoutDelegate::Metric::ICON_TEXT_SPACING);
|
| + case views::SpacingMetric::DIALOG_BUTTON_MINIMUM_WIDTH:
|
| + return LayoutDelegate::Get()->GetMetric(
|
| + LayoutDelegate::Metric::DIALOG_BUTTON_MINIMUM_WIDTH);
|
| + case views::SpacingMetric::BUTTON_HORIZONTAL_PADDING:
|
| + return LayoutDelegate::Get()->GetMetric(
|
| + LayoutDelegate::Metric::BUTTON_HORIZONTAL_PADDING);
|
| + }
|
| + NOTREACHED();
|
| + return 0;
|
| }
|
|
|
| #if !defined(USE_ASH)
|
|
|