OLD | NEW |
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_base_controller.h" | 5 #import "chrome/browser/ui/cocoa/profiles/avatar_base_controller.h" |
6 | 6 |
7 #include "base/mac/foundation_util.h" | 7 #include "base/mac/foundation_util.h" |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "chrome/app/chrome_command_ids.h" | 9 #include "chrome/app/chrome_command_ids.h" |
10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
11 #include "chrome/browser/profiles/profile_attributes_storage.h" | 11 #include "chrome/browser/profiles/profile_attributes_storage.h" |
12 #include "chrome/browser/profiles/profile_avatar_icon_util.h" | 12 #include "chrome/browser/profiles/profile_avatar_icon_util.h" |
13 #include "chrome/browser/profiles/profile_manager.h" | 13 #include "chrome/browser/profiles/profile_manager.h" |
14 #include "chrome/browser/profiles/profile_metrics.h" | 14 #include "chrome/browser/profiles/profile_metrics.h" |
15 #include "chrome/browser/profiles/profile_window.h" | 15 #include "chrome/browser/profiles/profile_window.h" |
16 #include "chrome/browser/profiles/profiles_state.h" | 16 #include "chrome/browser/profiles/profiles_state.h" |
17 #include "chrome/browser/signin/chrome_signin_helper.h" | 17 #include "chrome/browser/signin/chrome_signin_helper.h" |
18 #include "chrome/browser/ui/browser.h" | 18 #include "chrome/browser/ui/browser.h" |
19 #include "chrome/browser/ui/browser_commands.h" | 19 #include "chrome/browser/ui/browser_commands.h" |
20 #include "chrome/browser/ui/browser_window.h" | 20 #include "chrome/browser/ui/browser_window.h" |
21 #import "chrome/browser/ui/cocoa/base_bubble_controller.h" | 21 #import "chrome/browser/ui/cocoa/base_bubble_controller.h" |
22 #import "chrome/browser/ui/cocoa/browser_window_controller.h" | 22 #import "chrome/browser/ui/cocoa/browser_window_controller.h" |
23 #import "chrome/browser/ui/cocoa/profiles/avatar_menu_bubble_controller.h" | 23 #import "chrome/browser/ui/cocoa/profiles/avatar_menu_bubble_controller.h" |
24 #import "chrome/browser/ui/cocoa/profiles/profile_chooser_controller.h" | 24 #import "chrome/browser/ui/cocoa/profiles/profile_chooser_controller.h" |
25 #include "components/signin/core/browser/signin_error_controller.h" | 25 #include "components/signin/core/browser/signin_error_controller.h" |
26 #include "components/signin/core/common/profile_management_switches.h" | 26 #include "components/signin/core/common/profile_management_switches.h" |
27 #include "ui/base/cocoa/cocoa_base_utils.h" | 27 #include "ui/base/cocoa/cocoa_base_utils.h" |
28 | 28 |
| 29 #import "base/mac/bundle_locations.h" |
| 30 #import "chrome/browser/ui/cocoa/notifications/notification_delivery.h" |
| 31 |
29 // Space between the avatar icon and the avatar menu bubble. | 32 // Space between the avatar icon and the avatar menu bubble. |
30 const CGFloat kMenuYOffsetAdjust = 1.0; | 33 const CGFloat kMenuYOffsetAdjust = 1.0; |
31 // Offset needed to align the edge of the avatar bubble with the edge of the | 34 // Offset needed to align the edge of the avatar bubble with the edge of the |
32 // avatar button. | 35 // avatar button. |
33 const CGFloat kMenuXOffsetAdjust = 2.0; | 36 const CGFloat kMenuXOffsetAdjust = 2.0; |
34 | 37 |
35 @interface AvatarBaseController (Private) | 38 @interface AvatarBaseController (Private) |
36 // Shows the avatar bubble. | 39 // Shows the avatar bubble. |
37 - (IBAction)buttonClicked:(id)sender; | 40 - (IBAction)buttonClicked:(id)sender; |
38 - (IBAction)buttonRightClicked:(id)sender; | 41 - (IBAction)buttonRightClicked:(id)sender; |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 [menuController_ showWindow:self]; | 214 [menuController_ showWindow:self]; |
212 | 215 |
213 ProfileMetrics::LogProfileOpenMethod(ProfileMetrics::ICON_AVATAR_BUBBLE); | 216 ProfileMetrics::LogProfileOpenMethod(ProfileMetrics::ICON_AVATAR_BUBBLE); |
214 } | 217 } |
215 | 218 |
216 - (BOOL)isCtrlPressed { | 219 - (BOOL)isCtrlPressed { |
217 return [NSEvent modifierFlags] & NSControlKeyMask ? YES : NO; | 220 return [NSEvent modifierFlags] & NSControlKeyMask ? YES : NO; |
218 } | 221 } |
219 | 222 |
220 - (IBAction)buttonClicked:(id)sender { | 223 - (IBAction)buttonClicked:(id)sender { |
| 224 { |
| 225 NSLog(@"attempting to start NSXPCS"); |
| 226 NSXPCConnection* conn = [[NSXPCConnection alloc] |
| 227 initWithServiceName: |
| 228 [NSString |
| 229 stringWithFormat:@"%@.BannerNotificationService", |
| 230 [base::mac::OuterBundle() bundleIdentifier]]]; |
| 231 conn.remoteObjectInterface = |
| 232 [NSXPCInterface interfaceWithProtocol:@protocol(NotificationDelivery)]; |
| 233 conn.interruptionHandler = ^{ |
| 234 NSLog(@"conn interruptionHandler: %@", conn); |
| 235 }; |
| 236 conn.invalidationHandler = ^{ |
| 237 NSLog(@"conn invalidationHandler %@", conn); |
| 238 }; |
| 239 [conn resume]; |
| 240 |
| 241 NSDictionary* dict = @{ @"title" : @"hello world" }; |
| 242 [[conn remoteObjectProxy] deliverNotification:dict]; |
| 243 |
| 244 //[conn invalidate]; |
| 245 //[conn release]; |
| 246 } |
| 247 |
221 BrowserWindow::AvatarBubbleMode mode = | 248 BrowserWindow::AvatarBubbleMode mode = |
222 BrowserWindow::AVATAR_BUBBLE_MODE_DEFAULT; | 249 BrowserWindow::AVATAR_BUBBLE_MODE_DEFAULT; |
223 if ([self isCtrlPressed]) | 250 if ([self isCtrlPressed]) |
224 mode = BrowserWindow::AVATAR_BUBBLE_MODE_FAST_USER_SWITCH; | 251 mode = BrowserWindow::AVATAR_BUBBLE_MODE_FAST_USER_SWITCH; |
225 | 252 |
226 [self showAvatarBubbleAnchoredAt:button_ | 253 [self showAvatarBubbleAnchoredAt:button_ |
227 withMode:mode | 254 withMode:mode |
228 withServiceType:signin::GAIA_SERVICE_TYPE_NONE | 255 withServiceType:signin::GAIA_SERVICE_TYPE_NONE |
229 fromAccessPoint:signin_metrics::AccessPoint:: | 256 fromAccessPoint:signin_metrics::AccessPoint:: |
230 ACCESS_POINT_AVATAR_BUBBLE_SIGN_IN]; | 257 ACCESS_POINT_AVATAR_BUBBLE_SIGN_IN]; |
(...skipping 25 matching lines...) Expand all Loading... |
256 } | 283 } |
257 | 284 |
258 - (void)updateErrorStatus:(BOOL)hasError { | 285 - (void)updateErrorStatus:(BOOL)hasError { |
259 } | 286 } |
260 | 287 |
261 - (BaseBubbleController*)menuController { | 288 - (BaseBubbleController*)menuController { |
262 return menuController_; | 289 return menuController_; |
263 } | 290 } |
264 | 291 |
265 @end | 292 @end |
OLD | NEW |