| 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 fef73a45e373c2e634787a05d2ac5e7af25fff53..87bce2ed8f49013731633eda9ad61a30127b83e3 100644
|
| --- a/chrome/browser/ui/views/chrome_views_delegate.cc
|
| +++ b/chrome/browser/ui/views/chrome_views_delegate.cc
|
| @@ -57,19 +57,33 @@ PrefService* GetPrefsForWindow(const views::Widget* window) {
|
| return profile->GetPrefs();
|
| }
|
|
|
| +#if !defined(OS_WIN)
|
| +ChromeViewsDelegate* views_delegate = nullptr;
|
| +#endif
|
| +
|
| } // namespace
|
|
|
|
|
| // ChromeViewsDelegate --------------------------------------------------------
|
|
|
| #if !defined(OS_WIN)
|
| -ChromeViewsDelegate::ChromeViewsDelegate() {}
|
| -#endif
|
| +ChromeViewsDelegate::ChromeViewsDelegate() {
|
| + 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;
|
| +}
|
| +#endif
|
| +
|
| void ChromeViewsDelegate::SaveWindowPlacement(const views::Widget* window,
|
| const std::string& window_name,
|
| const gfx::Rect& bounds,
|
| @@ -196,58 +210,61 @@ 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);
|
| + 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::GetDialogButtonMinimumWidth() const {
|
| - return LayoutDelegate::Get()->GetMetric(
|
| - LayoutDelegate::Metric::DIALOG_BUTTON_MINIMUM_WIDTH);
|
| +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::ICON_TO_TEXT:
|
| + return LayoutDelegate::Get()->GetMetric(
|
| + LayoutDelegate::Metric::ICON_TEXT_SPACING);
|
| + 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::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;
|
| }
|
|
|
| -int ChromeViewsDelegate::GetButtonHorizontalPadding() const {
|
| - return LayoutDelegate::Get()->GetMetric(
|
| - LayoutDelegate::Metric::BUTTON_HORIZONTAL_PADDING);
|
| +int ChromeViewsDelegate::GetDefaultSpacingMetric(
|
| + views::SpacingMetric metric) const {
|
| + return views::ViewsDelegate::GetSpacingMetric(metric);
|
| }
|
|
|
| #if !defined(OS_CHROMEOS)
|
|
|