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

Unified Diff: chrome/browser/ui/toolbar/toolbar_actions_bar.cc

Issue 2464063002: Revert of Some more pre-material cleanups (Closed)
Patch Set: Created 4 years, 1 month 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
« no previous file with comments | « chrome/browser/ui/layout_constants.cc ('k') | chrome/browser/ui/views/infobars/infobar_view.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « chrome/browser/ui/layout_constants.cc ('k') | chrome/browser/ui/views/infobars/infobar_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698