summaryrefslogtreecommitdiffstats
path: root/chrome/browser/cocoa/notifications/balloon_controller.mm
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/cocoa/notifications/balloon_controller.mm')
-rw-r--r--chrome/browser/cocoa/notifications/balloon_controller.mm38
1 files changed, 37 insertions, 1 deletions
diff --git a/chrome/browser/cocoa/notifications/balloon_controller.mm b/chrome/browser/cocoa/notifications/balloon_controller.mm
index 55ee041..3f8a8b0 100644
--- a/chrome/browser/cocoa/notifications/balloon_controller.mm
+++ b/chrome/browser/cocoa/notifications/balloon_controller.mm
@@ -11,7 +11,9 @@
#include "base/nsimage_cache_mac.h"
#import "base/scoped_nsobject.h"
#include "base/utf_string_conversions.h"
+#import "chrome/browser/cocoa/hover_image_button.h"
#import "chrome/browser/cocoa/menu_controller.h"
+#import "chrome/browser/cocoa/notifications/balloon_view.h"
#include "chrome/browser/cocoa/notifications/balloon_view_host_mac.h"
#include "chrome/browser/notifications/balloon.h"
#include "chrome/browser/notifications/desktop_notification_service.h"
@@ -110,12 +112,45 @@ const int kRightMargin = 2;
assumeInside:NO];
}
+- (BOOL)handleEvent:(NSEvent*)event {
+ BOOL eventHandled = NO;
+ if ([event type] == NSLeftMouseDown) {
+ NSPoint mouse = [shelf_ convertPoint:[event locationInWindow]
+ fromView:nil];
+ if (NSPointInRect(mouse, [closeButton_ frame])) {
+ [closeButton_ mouseDown:event];
+
+ // Bring back the front process that is deactivated when we click the
+ // close button.
+ if (frontProcessNum_.highLongOfPSN || frontProcessNum_.lowLongOfPSN) {
+ SetFrontProcessWithOptions(&frontProcessNum_,
+ kSetFrontProcessFrontWindowOnly);
+ frontProcessNum_.highLongOfPSN = 0;
+ frontProcessNum_.lowLongOfPSN = 0;
+ }
+
+ eventHandled = YES;
+ } else if (NSPointInRect(mouse, [optionsButton_ frame])) {
+ [optionsButton_ mouseDown:event];
+ eventHandled = YES;
+ }
+ }
+ return eventHandled;
+}
+
- (void) mouseEntered:(NSEvent*)event {
[[closeButton_ cell] setHighlighted:YES];
+
+ // Remember the current front process so that we can bring it back later.
+ if (!frontProcessNum_.highLongOfPSN && !frontProcessNum_.lowLongOfPSN)
+ GetFrontProcess(&frontProcessNum_);
}
- (void) mouseExited:(NSEvent*)event {
[[closeButton_ cell] setHighlighted:NO];
+
+ frontProcessNum_.highLongOfPSN = 0;
+ frontProcessNum_.lowLongOfPSN = 0;
}
- (IBAction)optionsButtonPressed:(id)sender {
@@ -143,7 +178,8 @@ const int kRightMargin = 2;
}
- (void)closeBalloon:(bool)byUser {
- DCHECK(balloon_);
+ if (!balloon_)
+ return;
[self close];
if (htmlContents_.get())
htmlContents_->Shutdown();