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

Side by Side Diff: chrome/browser/ui/cocoa/profiles/avatar_button_controller.mm

Issue 555923002: [Mac] Set the avatar button auth error before initially drawing the button. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 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/profiles/avatar_button_controller.h" 5 #import "chrome/browser/ui/cocoa/profiles/avatar_button_controller.h"
6 6
7 #include "base/mac/foundation_util.h" 7 #include "base/mac/foundation_util.h"
8 #include "base/strings/sys_string_conversions.h" 8 #include "base/strings/sys_string_conversions.h"
9 #include "chrome/browser/profiles/profiles_state.h" 9 #include "chrome/browser/profiles/profiles_state.h"
10 #include "chrome/browser/themes/theme_service.h" 10 #include "chrome/browser/themes/theme_service.h"
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 [hoverButton setPressedImage:GetImageFromResourceID( 175 [hoverButton setPressedImage:GetImageFromResourceID(
176 IDR_AVATAR_MAC_BUTTON_DROPARROW_PRESSED)]; 176 IDR_AVATAR_MAC_BUTTON_DROPARROW_PRESSED)];
177 177
178 button_.reset(hoverButton); 178 button_.reset(hoverButton);
179 base::scoped_nsobject<CustomThemeButtonCell> cell( 179 base::scoped_nsobject<CustomThemeButtonCell> cell(
180 [[CustomThemeButtonCell alloc] initWithThemedWindow:isThemedWindow_]); 180 [[CustomThemeButtonCell alloc] initWithThemedWindow:isThemedWindow_]);
181 SigninErrorController* errorController = 181 SigninErrorController* errorController =
182 profiles::GetSigninErrorController(browser->profile()); 182 profiles::GetSigninErrorController(browser->profile());
183 183
184 [button_ setCell:cell.get()]; 184 [button_ setCell:cell.get()];
185
186 if (errorController)
187 [cell setHasError:errorController->HasError() withTitle:[button_ title]];
188
185 [self setView:button_]; 189 [self setView:button_];
186 190
187 [button_ setBezelStyle:NSShadowlessSquareBezelStyle]; 191 [button_ setBezelStyle:NSShadowlessSquareBezelStyle];
188 [button_ setButtonType:NSMomentaryChangeButton]; 192 [button_ setButtonType:NSMomentaryChangeButton];
189 [button_ setBordered:YES]; 193 [button_ setBordered:YES];
190 // This is a workaround for an issue in the HoverImageButton where the 194 // This is a workaround for an issue in the HoverImageButton where the
191 // button is initially sized incorrectly unless a default image is provided. 195 // button is initially sized incorrectly unless a default image is provided.
192 [button_ setImage:GetImageFromResourceID(IDR_AVATAR_MAC_BUTTON_DROPARROW)]; 196 [button_ setImage:GetImageFromResourceID(IDR_AVATAR_MAC_BUTTON_DROPARROW)];
193 [button_ setImagePosition:NSImageRight]; 197 [button_ setImagePosition:NSImageRight];
194 [button_ setAutoresizingMask:NSViewMinXMargin | NSViewMinYMargin]; 198 [button_ setAutoresizingMask:NSViewMinXMargin | NSViewMinYMargin];
195 [button_ setTarget:self]; 199 [button_ setTarget:self];
196 [button_ setAction:@selector(buttonClicked:)]; 200 [button_ setAction:@selector(buttonClicked:)];
197 201
198 [self updateAvatarButtonAndLayoutParent:NO]; 202 [self updateAvatarButtonAndLayoutParent:NO];
199 if (errorController)
200 [cell setHasError:errorController->HasError() withTitle:[button_ title]];
201 203
202 NSNotificationCenter* center = [NSNotificationCenter defaultCenter]; 204 NSNotificationCenter* center = [NSNotificationCenter defaultCenter];
203 [center addObserver:self 205 [center addObserver:self
204 selector:@selector(themeDidChangeNotification:) 206 selector:@selector(themeDidChangeNotification:)
205 name:kBrowserThemeDidChangeNotification 207 name:kBrowserThemeDidChangeNotification
206 object:nil]; 208 object:nil];
207 } 209 }
208 return self; 210 return self;
209 } 211 }
210 212
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 layoutSubviews]; 271 layoutSubviews];
270 } 272 }
271 } 273 }
272 274
273 - (void)updateErrorStatus:(BOOL)hasError { 275 - (void)updateErrorStatus:(BOOL)hasError {
274 [[button_ cell] setHasError:hasError withTitle:[button_ title]]; 276 [[button_ cell] setHasError:hasError withTitle:[button_ title]];
275 [self updateAvatarButtonAndLayoutParent:YES]; 277 [self updateAvatarButtonAndLayoutParent:YES];
276 } 278 }
277 279
278 @end 280 @end
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698