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