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

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

Issue 8356028: Add shortcut to show avatar menu (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address review comments Created 9 years, 2 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/browser/browser_process.h" 8 #include "chrome/browser/browser_process.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/profiles/profile_info_cache.h" 10 #include "chrome/browser/profiles/profile_info_cache.h"
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 } 141 }
142 142
143 // Private ///////////////////////////////////////////////////////////////////// 143 // Private /////////////////////////////////////////////////////////////////////
144 144
145 - (void)setOpenMenuOnClick:(BOOL)flag { 145 - (void)setOpenMenuOnClick:(BOOL)flag {
146 [self.buttonView setEnabled:flag]; 146 [self.buttonView setEnabled:flag];
147 } 147 }
148 148
149 - (IBAction)buttonClicked:(id)sender { 149 - (IBAction)buttonClicked:(id)sender {
150 DCHECK_EQ(self.buttonView, sender); 150 DCHECK_EQ(self.buttonView, sender);
151 [self showAvatarBubble];
152 }
153
154 - (void)showAvatarBubble {
Robert Sesek 2011/10/20 20:49:21 This shouldn't be in the private section. Move thi
sail 2011/10/20 21:08:23 Done.
151 if (menuController_) 155 if (menuController_)
152 return; 156 return;
153 157
158 NSWindowController* wc =
159 [browser_->window()->GetNativeHandle() windowController];
160 if ([wc isKindOfClass:[BrowserWindowController class]]) {
161 [static_cast<BrowserWindowController*>(wc)
162 lockBarVisibilityForOwner:self withAnimation:NO delay:NO];
163 }
164
154 NSView* view = self.view; 165 NSView* view = self.view;
155 NSPoint point = NSMakePoint(NSMidX([view bounds]), 166 NSPoint point = NSMakePoint(NSMidX([view bounds]),
156 NSMaxY([view bounds]) - kMenuYOffsetAdjust); 167 NSMaxY([view bounds]) - kMenuYOffsetAdjust);
157 point = [view convertPoint:point toView:nil]; 168 point = [view convertPoint:point toView:nil];
158 point = [[view window] convertBaseToScreen:point]; 169 point = [[view window] convertBaseToScreen:point];
159 170
160 // |menu| will automatically release itself on close. 171 // |menu| will automatically release itself on close.
161 menuController_ = [[AvatarMenuBubbleController alloc] initWithBrowser:browser_ 172 menuController_ = [[AvatarMenuBubbleController alloc] initWithBrowser:browser_
162 anchoredAt:point]; 173 anchoredAt:point];
163 [[NSNotificationCenter defaultCenter] 174 [[NSNotificationCenter defaultCenter]
164 addObserver:self 175 addObserver:self
165 selector:@selector(bubbleWillClose:) 176 selector:@selector(bubbleWillClose:)
166 name:NSWindowWillCloseNotification 177 name:NSWindowWillCloseNotification
167 object:[menuController_ window]]; 178 object:[menuController_ window]];
168 [menuController_ showWindow:self]; 179 [menuController_ showWindow:self];
169 } 180 }
170 181
171 - (void)bubbleWillClose:(NSNotification*)notif { 182 - (void)bubbleWillClose:(NSNotification*)notif {
183 NSWindowController* wc =
184 [browser_->window()->GetNativeHandle() windowController];
185 if ([wc isKindOfClass:[BrowserWindowController class]]) {
186 [static_cast<BrowserWindowController*>(wc)
187 releaseBarVisibilityForOwner:self withAnimation:YES delay:NO];
188 }
172 menuController_ = nil; 189 menuController_ = nil;
173 } 190 }
174 191
175 // This will take in an original image and redraw it with a shadow. 192 // This will take in an original image and redraw it with a shadow.
176 - (NSImage*)compositeImageWithShadow:(NSImage*)image { 193 - (NSImage*)compositeImageWithShadow:(NSImage*)image {
177 gfx::ScopedNSGraphicsContextSaveGState scopedGState; 194 gfx::ScopedNSGraphicsContextSaveGState scopedGState;
178 195
179 scoped_nsobject<NSImage> destination( 196 scoped_nsobject<NSImage> destination(
180 [[NSImage alloc] initWithSize:[image size]]); 197 [[NSImage alloc] initWithSize:[image size]]);
181 198
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 [static_cast<BrowserWindowController*>(wc) layoutSubviews]; 254 [static_cast<BrowserWindowController*>(wc) layoutSubviews];
238 } 255 }
239 256
240 // Testing ///////////////////////////////////////////////////////////////////// 257 // Testing /////////////////////////////////////////////////////////////////////
241 258
242 - (AvatarMenuBubbleController*)menuController { 259 - (AvatarMenuBubbleController*)menuController {
243 return menuController_; 260 return menuController_;
244 } 261 }
245 262
246 @end 263 @end
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/browser/avatar_button_controller.h ('k') | chrome/browser/ui/cocoa/browser_window_cocoa.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698