| OLD | NEW |
| 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/browser/avatar_button_controller.h" | 5 #import "chrome/browser/ui/cocoa/browser/avatar_button_controller.h" |
| 6 | 6 |
| 7 #include "base/sys_string_conversions.h" | 7 #include "base/sys_string_conversions.h" |
| 8 #include "chrome/app/chrome_command_ids.h" | 8 #include "chrome/app/chrome_command_ids.h" |
| 9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
| 10 #include "chrome/browser/command_updater.h" | 10 #include "chrome/browser/command_updater.h" |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 [self.buttonView setImage:image]; | 154 [self.buttonView setImage:image]; |
| 155 } | 155 } |
| 156 | 156 |
| 157 - (void)showAvatarBubble { | 157 - (void)showAvatarBubble { |
| 158 if (menuController_) | 158 if (menuController_) |
| 159 return; | 159 return; |
| 160 | 160 |
| 161 DCHECK(browser_->command_updater()->IsCommandEnabled(IDC_SHOW_AVATAR_MENU)); | 161 DCHECK(browser_->command_updater()->IsCommandEnabled(IDC_SHOW_AVATAR_MENU)); |
| 162 | 162 |
| 163 NSWindowController* wc = | 163 NSWindowController* wc = |
| 164 [browser_->window()->GetNativeHandle() windowController]; | 164 [browser_->window()->GetNativeWindow() windowController]; |
| 165 if ([wc isKindOfClass:[BrowserWindowController class]]) { | 165 if ([wc isKindOfClass:[BrowserWindowController class]]) { |
| 166 [static_cast<BrowserWindowController*>(wc) | 166 [static_cast<BrowserWindowController*>(wc) |
| 167 lockBarVisibilityForOwner:self withAnimation:NO delay:NO]; | 167 lockBarVisibilityForOwner:self withAnimation:NO delay:NO]; |
| 168 } | 168 } |
| 169 | 169 |
| 170 NSView* view = self.view; | 170 NSView* view = self.view; |
| 171 NSPoint point = NSMakePoint(NSMidX([view bounds]), | 171 NSPoint point = NSMakePoint(NSMidX([view bounds]), |
| 172 NSMaxY([view bounds]) - kMenuYOffsetAdjust); | 172 NSMaxY([view bounds]) - kMenuYOffsetAdjust); |
| 173 point = [view convertPoint:point toView:nil]; | 173 point = [view convertPoint:point toView:nil]; |
| 174 point = [[view window] convertBaseToScreen:point]; | 174 point = [[view window] convertBaseToScreen:point]; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 196 DCHECK_EQ(self.buttonView, sender); | 196 DCHECK_EQ(self.buttonView, sender); |
| 197 if (ManagedMode::IsInManagedMode()) { | 197 if (ManagedMode::IsInManagedMode()) { |
| 198 ManagedMode::LeaveManagedMode(); | 198 ManagedMode::LeaveManagedMode(); |
| 199 } else { | 199 } else { |
| 200 [self showAvatarBubble]; | 200 [self showAvatarBubble]; |
| 201 } | 201 } |
| 202 } | 202 } |
| 203 | 203 |
| 204 - (void)bubbleWillClose:(NSNotification*)notif { | 204 - (void)bubbleWillClose:(NSNotification*)notif { |
| 205 NSWindowController* wc = | 205 NSWindowController* wc = |
| 206 [browser_->window()->GetNativeHandle() windowController]; | 206 [browser_->window()->GetNativeWindow() windowController]; |
| 207 if ([wc isKindOfClass:[BrowserWindowController class]]) { | 207 if ([wc isKindOfClass:[BrowserWindowController class]]) { |
| 208 [static_cast<BrowserWindowController*>(wc) | 208 [static_cast<BrowserWindowController*>(wc) |
| 209 releaseBarVisibilityForOwner:self withAnimation:YES delay:NO]; | 209 releaseBarVisibilityForOwner:self withAnimation:YES delay:NO]; |
| 210 } | 210 } |
| 211 menuController_ = nil; | 211 menuController_ = nil; |
| 212 } | 212 } |
| 213 | 213 |
| 214 // This will take in an original image and redraw it with a shadow. | 214 // This will take in an original image and redraw it with a shadow. |
| 215 - (NSImage*)compositeImageWithShadow:(NSImage*)image { | 215 - (NSImage*)compositeImageWithShadow:(NSImage*)image { |
| 216 gfx::ScopedNSGraphicsContextSaveGState scopedGState; | 216 gfx::ScopedNSGraphicsContextSaveGState scopedGState; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 forAttribute:NSAccessibilityValueAttribute]; | 272 forAttribute:NSAccessibilityValueAttribute]; |
| 273 } | 273 } |
| 274 | 274 |
| 275 // If the second-to-last profile was removed or a second profile was added, | 275 // If the second-to-last profile was removed or a second profile was added, |
| 276 // show or hide the avatar button from the window frame. | 276 // show or hide the avatar button from the window frame. |
| 277 - (void)addOrRemoveButtonIfNecessary { | 277 - (void)addOrRemoveButtonIfNecessary { |
| 278 if (browser_->profile()->IsOffTheRecord()) | 278 if (browser_->profile()->IsOffTheRecord()) |
| 279 return; | 279 return; |
| 280 | 280 |
| 281 NSWindowController* wc = | 281 NSWindowController* wc = |
| 282 [browser_->window()->GetNativeHandle() windowController]; | 282 [browser_->window()->GetNativeWindow() windowController]; |
| 283 if (![wc isKindOfClass:[BrowserWindowController class]]) | 283 if (![wc isKindOfClass:[BrowserWindowController class]]) |
| 284 return; | 284 return; |
| 285 | 285 |
| 286 size_t count = g_browser_process->profile_manager()->GetNumberOfProfiles(); | 286 size_t count = g_browser_process->profile_manager()->GetNumberOfProfiles(); |
| 287 [self.view setHidden:count < 2]; | 287 [self.view setHidden:count < 2]; |
| 288 | 288 |
| 289 [static_cast<BrowserWindowController*>(wc) layoutSubviews]; | 289 [static_cast<BrowserWindowController*>(wc) layoutSubviews]; |
| 290 } | 290 } |
| 291 | 291 |
| 292 // Testing ///////////////////////////////////////////////////////////////////// | 292 // Testing ///////////////////////////////////////////////////////////////////// |
| 293 | 293 |
| 294 - (AvatarMenuBubbleController*)menuController { | 294 - (AvatarMenuBubbleController*)menuController { |
| 295 return menuController_; | 295 return menuController_; |
| 296 } | 296 } |
| 297 | 297 |
| 298 @end | 298 @end |
| OLD | NEW |