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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_UI_COCOA_NOTIFICATIONS_BALLOON_CONTROLLER_H_
6 #define CHROME_BROWSER_UI_COCOA_NOTIFICATIONS_BALLOON_CONTROLLER_H_
8 #import <Cocoa/Cocoa.h>
10 #include "base/mac/scoped_nsobject.h"
11 #include "base/memory/scoped_ptr.h"
14 @
class BalloonContentViewCocoa
;
15 @
class BalloonShelfViewCocoa
;
16 class BalloonViewHost
;
17 @
class HoverImageButton
;
18 @
class MenuController
;
19 class NotificationOptionsMenuModel
;
21 // The Balloon controller creates the view elements to display a
22 // notification balloon, resize it if the HTML contents of that
23 // balloon change, and move it when the collection of balloons is
25 @interface BalloonController
: NSWindowController
<NSWindowDelegate
> {
27 // The balloon which represents the contents of this view. Weak pointer
28 // owned by the browser's NotificationUIManager.
31 // The view that contains the contents of the notification
32 IBOutlet BalloonContentViewCocoa
* htmlContainer_
;
34 // The view that contains the controls of the notification
35 IBOutlet BalloonShelfViewCocoa
* shelf_
;
38 IBOutlet NSButton
* closeButton_
;
40 // Tracking region for the close button.
41 int closeButtonTrackingTag_
;
44 IBOutlet NSTextField
* originLabel_
;
46 // The options menu that appears when "options" is pressed.
47 IBOutlet HoverImageButton
* optionsButton_
;
48 scoped_ptr
<NotificationOptionsMenuModel
> menuModel_
;
49 base::scoped_nsobject
<MenuController
> menuController_
;
51 // The host for the renderer of the HTML contents.
52 scoped_ptr
<BalloonViewHost
> htmlContents_
;
54 // Variables to delay close requested by script while showing modal menu.
55 BOOL optionMenuIsActive_
;
59 // Initialize with a balloon object containing the notification data.
60 - (id
)initWithBalloon
:(Balloon
*)balloon
;
62 // Callback function for the close button.
63 - (IBAction
)closeButtonPressed
:(id
)sender
;
65 // Callback function for the options button.
66 - (IBAction
)optionsButtonPressed
:(id
)sender
;
68 // Callback function for the "revoke" option in the menu.
69 - (IBAction
)permissionRevoked
:(id
)sender
;
71 // Closes the balloon. Can be called by the bridge or by the close
73 - (void)closeBalloon
:(bool)byUser
;
75 // Update the contents of the balloon to match the notification.
76 - (void)updateContents
;
78 // Repositions the view to match the position and size of the balloon.
79 // Called by the bridge when the size changes.
80 - (void)repositionToBalloon
;
82 // The current size of the view, possibly subject to an animation completing.
83 - (int)desiredTotalWidth
;
84 - (int)desiredTotalHeight
;
87 - (BalloonViewHost
*)getHost
;
90 @interface
BalloonController (UnitTesting
)
91 - (void)initializeHost
;
94 #endif // CHROME_BROWSER_UI_COCOA_NOTIFICATIONS_BALLOON_CONTROLLER_H_