[Metrics] Make MetricsStateManager take a callback param to check if UMA is enabled.
[chromium-blink-merge.git] / chrome / browser / ui / cocoa / download / download_show_all_button.mm
blob196a7ff4035f51ce55f51c327d2beb65b23aab81
1 // Copyright (c) 2012 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 #import "chrome/browser/ui/cocoa/download/download_show_all_button.h"
7 #include "base/logging.h"
8 #import "chrome/browser/ui/cocoa/download/download_show_all_cell.h"
9 #import "chrome/browser/ui/cocoa/nsview_additions.h"
10 #import "chrome/browser/ui/cocoa/view_id_util.h"
11 #include "grit/generated_resources.h"
12 #include "grit/theme_resources.h"
13 #include "ui/base/resource/resource_bundle.h"
14 #include "ui/gfx/image/image.h"
16 @implementation DownloadShowAllButton
18 - (void)awakeFromNib {
19   DCHECK([[self cell] isKindOfClass:[DownloadShowAllCell class]]);
20   ResourceBundle& rb = ResourceBundle::GetSharedInstance();
21   NSImage* favicon = rb.GetNativeImageNamed(IDR_DOWNLOADS_FAVICON).ToNSImage();
22   [self setImage:favicon];
25 // GTM's layout tweaker calls sizeToFit to receive the desired width of views.
26 // By default, buttons will be only 14px high, but the Show All button needs to
27 // be higher.
28 - (void)sizeToFit {
29   NSRect oldRect = [self frame];
30   [super sizeToFit];
31   NSRect newRect = [self frame];
33   // Keep old height.
34   newRect.origin.y = oldRect.origin.y;
35   newRect.size.height = oldRect.size.height;
37   [self setFrame:newRect];
40 - (BOOL)isOpaque {
41   // Make this control opaque so that sub-pixel anti-aliasing works when
42   // CoreAnimation is enabled.
43   return YES;
46 - (void)drawRect:(NSRect)rect {
47   NSView* downloadShelfView = [self ancestorWithViewID:VIEW_ID_DOWNLOAD_SHELF];
48   [self cr_drawUsingAncestor:downloadShelfView inRect:rect];
49   [super drawRect:rect];
52 @end