[Metrics] Make MetricsStateManager take a callback param to check if UMA is enabled.
[chromium-blink-merge.git] / chrome / browser / ui / cocoa / website_settings / website_settings_utils_cocoa.mm
blobe1c566c90efb5b8ae95fb07bde43001c4e64c735
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/ui/cocoa/website_settings/website_settings_utils_cocoa.h"
7 namespace {
8 // The amount of horizontal space between the button's title and its arrow icon.
9 const CGFloat kButtonTitleRightPadding = 4.0f;
12 // Determine the size of a popup button with the given title.
13 NSSize SizeForWebsiteSettingsButtonTitle(NSPopUpButton* button,
14                                          NSString* title) {
15   NSDictionary* textAttributes =
16       [[button attributedTitle] attributesAtIndex:0 effectiveRange:NULL];
17   NSSize titleSize = [title sizeWithAttributes:textAttributes];
19   NSRect frame = [button frame];
20   NSRect titleRect = [[button cell] titleRectForBounds:frame];
21   CGFloat width = titleSize.width + NSWidth(frame) - NSWidth(titleRect);
23   return NSMakeSize(width + kButtonTitleRightPadding, NSHeight(frame));