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..e80e7afd6ee1df6098305f9e2173a33a9ecee54a 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::GetDistanceMetric(views::DistanceMetric metric) const { |
+ switch (metric) { |
+ case views::DistanceMetric::CLOSE_BUTTON_MARGIN: |
+ return LayoutDelegate::Get()->GetMetric( |
+ LayoutDelegate::Metric::DIALOG_CLOSE_BUTTON_MARGIN); |
+ case views::DistanceMetric::RELATED_BUTTON_HORIZONTAL: |
+ return LayoutDelegate::Get()->GetMetric( |
+ LayoutDelegate::Metric::RELATED_BUTTON_HORIZONTAL_SPACING); |
+ case views::DistanceMetric::RELATED_CONTROL_HORIZONTAL: |
+ return LayoutDelegate::Get()->GetMetric( |
+ LayoutDelegate::Metric::RELATED_CONTROL_HORIZONTAL_SPACING); |
+ case views::DistanceMetric::RELATED_CONTROL_VERTICAL: |
+ return LayoutDelegate::Get()->GetMetric( |
+ LayoutDelegate::Metric::RELATED_CONTROL_VERTICAL_SPACING); |
+ case views::DistanceMetric::DIALOG_BUTTON_MINIMUM_WIDTH: |
+ return LayoutDelegate::Get()->GetMetric( |
+ LayoutDelegate::Metric::DIALOG_BUTTON_MINIMUM_WIDTH); |
+ case views::DistanceMetric::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::GetDefaultDistanceMetric( |
+ views::DistanceMetric metric) const { |
+ return views::ViewsDelegate::GetDistanceMetric(metric); |
} |
#if !defined(OS_CHROMEOS) |