| Index: chrome/browser/ui/toolbar/toolbar_actions_bar.cc
|
| diff --git a/chrome/browser/ui/toolbar/toolbar_actions_bar.cc b/chrome/browser/ui/toolbar/toolbar_actions_bar.cc
|
| index 72f85cc804889a821b1695b5c2608ed721da1e22..8d06aa097e7459bcc6b7f63e005a30128c83c71f 100644
|
| --- a/chrome/browser/ui/toolbar/toolbar_actions_bar.cc
|
| +++ b/chrome/browser/ui/toolbar/toolbar_actions_bar.cc
|
| @@ -35,6 +35,7 @@
|
| #include "extensions/browser/runtime_data.h"
|
| #include "extensions/common/extension.h"
|
| #include "extensions/common/feature_switch.h"
|
| +#include "ui/base/material_design/material_design_controller.h"
|
| #include "ui/base/resource/resource_bundle.h"
|
| #include "ui/gfx/image/image_skia.h"
|
|
|
| @@ -43,6 +44,30 @@
|
| using WeakToolbarActions = std::vector<ToolbarActionViewController*>;
|
|
|
| enum DimensionType { WIDTH, HEIGHT };
|
| +
|
| +// Returns the width or height of the toolbar action icon size.
|
| +int GetIconDimension(DimensionType type) {
|
| +if (ui::MaterialDesignController::IsModeMaterial())
|
| +#if defined(OS_MACOSX)
|
| + // On the Mac, the spec is a 24x24 button in a 28x28 space.
|
| + return 24;
|
| +#else
|
| + return 28;
|
| +#endif
|
| +
|
| + static bool initialized = false;
|
| + static int icon_height = 0;
|
| + static int icon_width = 0;
|
| + if (!initialized) {
|
| + initialized = true;
|
| + gfx::ImageSkia* skia =
|
| + ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
|
| + IDR_BROWSER_ACTION);
|
| + icon_height = skia->height();
|
| + icon_width = skia->width();
|
| + }
|
| + return type == WIDTH ? icon_width : icon_height;
|
| +}
|
|
|
| // Takes a reference vector |reference| of length n, where n is less than or
|
| // equal to the length of |to_sort|, and rearranges |to_sort| so that
|
| @@ -130,18 +155,13 @@
|
|
|
| // static
|
| int ToolbarActionsBar::IconWidth(bool include_padding) {
|
| - return IconHeight() +
|
| + return GetIconDimension(WIDTH) +
|
| (include_padding ? GetLayoutConstant(TOOLBAR_STANDARD_SPACING) : 0);
|
| }
|
|
|
| // static
|
| int ToolbarActionsBar::IconHeight() {
|
| -#if defined(OS_MACOSX)
|
| - // On the Mac, the spec is a 24x24 button in a 28x28 space.
|
| - return 24;
|
| -#else
|
| - return 28;
|
| -#endif
|
| + return GetIconDimension(HEIGHT);
|
| }
|
|
|
| // static
|
|
|