| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 #include "ui/message_center/cocoa/tray_controller.h" | 5 #include "ui/message_center/cocoa/tray_controller.h" |
| 6 | 6 |
| 7 #include "ui/base/cocoa/window_size_constants.h" | 7 #include "ui/base/cocoa/window_size_constants.h" |
| 8 #include "ui/base/resource/resource_bundle.h" | 8 #include "ui/base/resource/resource_bundle.h" |
| 9 #import "ui/message_center/cocoa/popup_collection.h" | 9 #import "ui/message_center/cocoa/popup_collection.h" |
| 10 #import "ui/message_center/cocoa/tray_view_controller.h" | 10 #import "ui/message_center/cocoa/tray_view_controller.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 | 45 |
| 46 viewController_.reset([[MCTrayViewController alloc] initWithMessageCenter: | 46 viewController_.reset([[MCTrayViewController alloc] initWithMessageCenter: |
| 47 tray_->message_center()]); | 47 tray_->message_center()]); |
| 48 NSView* contentView = [viewController_ view]; | 48 NSView* contentView = [viewController_ view]; |
| 49 [window setFrame:[contentView frame] display:NO]; | 49 [window setFrame:[contentView frame] display:NO]; |
| 50 [window setContentView:contentView]; | 50 [window setContentView:contentView]; |
| 51 | 51 |
| 52 // The global event monitor will close the tray in response to events | 52 // The global event monitor will close the tray in response to events |
| 53 // delivered to other applications, and -windowDidResignKey: will catch | 53 // delivered to other applications, and -windowDidResignKey: will catch |
| 54 // events within the application. | 54 // events within the application. |
| 55 __block typeof(self) weakSelf = self; | 55 __block MCTrayController* weakSelf = self; |
| 56 clickEventMonitor_ = | 56 clickEventMonitor_ = |
| 57 [NSEvent addGlobalMonitorForEventsMatchingMask:NSLeftMouseDownMask | | 57 [NSEvent addGlobalMonitorForEventsMatchingMask:NSLeftMouseDownMask | |
| 58 NSRightMouseDownMask | | 58 NSRightMouseDownMask | |
| 59 NSOtherMouseDownMask | 59 NSOtherMouseDownMask |
| 60 handler:^(NSEvent* event) { | 60 handler:^(NSEvent* event) { |
| 61 [weakSelf windowDidResignKey:nil]; | 61 [weakSelf windowDidResignKey:nil]; |
| 62 }]; | 62 }]; |
| 63 } | 63 } |
| 64 return self; | 64 return self; |
| 65 } | 65 } |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 - (void)windowDidResignKey:(NSNotification*)notification { | 104 - (void)windowDidResignKey:(NSNotification*)notification { |
| 105 // The settings bubble data structures assume that the settings dialog is | 105 // The settings bubble data structures assume that the settings dialog is |
| 106 // visible only for short periods of time: There's a fixed list of permissions | 106 // visible only for short periods of time: There's a fixed list of permissions |
| 107 // for example. | 107 // for example. |
| 108 [viewController_ cleanupSettings]; | 108 [viewController_ cleanupSettings]; |
| 109 | 109 |
| 110 tray_->HideMessageCenterBubble(); | 110 tray_->HideMessageCenterBubble(); |
| 111 } | 111 } |
| 112 | 112 |
| 113 @end | 113 @end |
| OLD | NEW |