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

Side by Side Diff: chrome/browser/ui/cocoa/infobars/infobar_controller.mm

Issue 1885903003: [Mac] Increase infobar height under Material Design. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months 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 unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/ui/cocoa/infobars/infobar_gradient_view.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import "chrome/browser/ui/cocoa/infobars/infobar_controller.h" 5 #import "chrome/browser/ui/cocoa/infobars/infobar_controller.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/mac/bundle_locations.h" 8 #include "base/mac/bundle_locations.h"
9 #include "chrome/browser/infobars/infobar_service.h" 9 #include "chrome/browser/infobars/infobar_service.h"
10 #import "chrome/browser/ui/cocoa/animatable_view.h" 10 #import "chrome/browser/ui/cocoa/animatable_view.h"
11 #import "chrome/browser/ui/cocoa/browser_window_controller.h" 11 #import "chrome/browser/ui/cocoa/browser_window_controller.h"
12 #import "chrome/browser/ui/cocoa/image_button_cell.h" 12 #import "chrome/browser/ui/cocoa/image_button_cell.h"
13 #include "chrome/browser/ui/cocoa/infobars/infobar_cocoa.h" 13 #include "chrome/browser/ui/cocoa/infobars/infobar_cocoa.h"
14 #import "chrome/browser/ui/cocoa/infobars/infobar_container_cocoa.h" 14 #import "chrome/browser/ui/cocoa/infobars/infobar_container_cocoa.h"
15 #import "chrome/browser/ui/cocoa/infobars/infobar_container_controller.h" 15 #import "chrome/browser/ui/cocoa/infobars/infobar_container_controller.h"
16 #import "chrome/browser/ui/cocoa/infobars/infobar_gradient_view.h" 16 #import "chrome/browser/ui/cocoa/infobars/infobar_gradient_view.h"
17 #import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h" 17 #import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h"
18 #include "grit/components_strings.h" 18 #include "grit/components_strings.h"
19 #include "grit/generated_resources.h" 19 #include "grit/generated_resources.h"
20 #include "grit/theme_resources.h" 20 #include "grit/theme_resources.h"
21 #import "ui/base/cocoa/controls/hyperlink_text_view.h" 21 #import "ui/base/cocoa/controls/hyperlink_text_view.h"
22 #include "ui/base/l10n/l10n_util_mac.h" 22 #include "ui/base/l10n/l10n_util_mac.h"
23 #include "ui/base/material_design/material_design_controller.h"
23 #include "ui/gfx/image/image.h" 24 #include "ui/gfx/image/image.h"
24 #include "ui/resources/grit/ui_resources.h" 25 #include "ui/resources/grit/ui_resources.h"
25 26
26 @interface InfoBarController () 27 @interface InfoBarController ()
27 // Sets |label_| based on |labelPlaceholder_|, sets |labelPlaceholder_| to nil. 28 // Sets |label_| based on |labelPlaceholder_|, sets |labelPlaceholder_| to nil.
28 - (void)initializeLabel; 29 - (void)initializeLabel;
29 @end 30 @end
30 31
31 @implementation InfoBarController 32 @implementation InfoBarController
32 33
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 labelFrame.size.width += NSMinX(imageFrame) - NSMinX(labelFrame); 66 labelFrame.size.width += NSMinX(imageFrame) - NSMinX(labelFrame);
66 labelFrame.origin.x = imageFrame.origin.x; 67 labelFrame.origin.x = imageFrame.origin.x;
67 [image_ removeFromSuperview]; 68 [image_ removeFromSuperview];
68 image_ = nil; 69 image_ = nil;
69 [labelPlaceholder_ setFrame:labelFrame]; 70 [labelPlaceholder_ setFrame:labelFrame];
70 } 71 }
71 [self initializeLabel]; 72 [self initializeLabel];
72 73
73 [self addAdditionalControls]; 74 [self addAdditionalControls];
74 75
76 // With Material Design infobars are drawn a little taller, so have to move
77 // its controls to keep them centered.
78 if (ui::MaterialDesignController::IsModeMaterial()) {
79 CGFloat heightDelta = InfoBarContainerDelegate::kDefaultBarTargetHeightMd -
80 InfoBarContainerDelegate::kDefaultBarTargetHeight;
81 for (NSView* nextSubview in [infoBarView_ subviews]) {
82 NSRect frame = [nextSubview frame];
83 frame.origin.y += heightDelta / 2;
84 [nextSubview setFrame:frame];
85 }
86 }
Avi (use Gerrit) 2016/04/13 21:35:00 Joy... It's a race now between the switch to MD a
87
75 [infoBarView_ setInfobarType:[self delegate]->GetInfoBarType()]; 88 [infoBarView_ setInfobarType:[self delegate]->GetInfoBarType()];
76 [infoBarView_ setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable]; 89 [infoBarView_ setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
77 } 90 }
78 91
79 - (void)dealloc { 92 - (void)dealloc {
80 [okButton_ setTarget:nil]; 93 [okButton_ setTarget:nil];
81 [cancelButton_ setTarget:nil]; 94 [cancelButton_ setTarget:nil];
82 [closeButton_ setTarget:nil]; 95 [closeButton_ setTarget:nil];
83 [super dealloc]; 96 [super dealloc];
84 } 97 }
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 [newLabel setAutoresizingMask:[labelPlaceholder_ autoresizingMask]]; 195 [newLabel setAutoresizingMask:[labelPlaceholder_ autoresizingMask]];
183 [[labelPlaceholder_ superview] 196 [[labelPlaceholder_ superview]
184 replaceSubview:labelPlaceholder_ with:newLabel]; 197 replaceSubview:labelPlaceholder_ with:newLabel];
185 labelPlaceholder_ = nil; // Now released. 198 labelPlaceholder_ = nil; // Now released.
186 [newLabel setDelegate:self]; 199 [newLabel setDelegate:self];
187 200
188 label_.reset(newLabel.release()); 201 label_.reset(newLabel.release());
189 } 202 }
190 203
191 @end 204 @end
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/cocoa/infobars/infobar_gradient_view.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698