Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(205)

Side by Side Diff: chrome/browser/ui/cocoa/infobars/infobar_container_controller.h

Issue 23338005: Mac InfoBar: Use cross platform infobar classes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 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 #ifndef CHROME_BROWSER_UI_COCOA_INFOBARS_INFOBAR_CONTAINER_CONTROLLER_H_ 5 #ifndef CHROME_BROWSER_UI_COCOA_INFOBARS_INFOBAR_CONTAINER_CONTROLLER_H_
6 #define CHROME_BROWSER_UI_COCOA_INFOBARS_INFOBAR_CONTAINER_CONTROLLER_H_ 6 #define CHROME_BROWSER_UI_COCOA_INFOBARS_INFOBAR_CONTAINER_CONTROLLER_H_
7 7
8 #import <Cocoa/Cocoa.h> 8 #import <Cocoa/Cocoa.h>
9 9
10 #include "base/mac/scoped_nsobject.h" 10 #include "base/mac/scoped_nsobject.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #import "chrome/browser/ui/cocoa/view_resizer.h" 12 #import "chrome/browser/ui/cocoa/view_resizer.h"
13 #include "content/public/browser/notification_registrar.h"
14 13
15 @class BrowserWindowController; 14 @class BrowserWindowController;
16 @class InfoBarController; 15 @class InfoBarController;
17 class InfoBar; 16 class InfoBarCocoa;
18 class InfoBarDelegate; 17 class InfoBarDelegate;
19 class InfoBarNotificationObserver; 18 class InfoBarContainerCocoa;
Robert Sesek 2013/08/26 14:06:56 nit: sort
sail 2013/08/26 18:32:23 Done.
20 class TabStripModel; 19 class TabStripModel;
21 20
22 namespace content { 21 namespace content {
23 class WebContents; 22 class WebContents;
24 } 23 }
25 24
26 // Protocol for basic container methods, as needed by an InfoBarController. 25 // Protocol for basic container methods, as needed by an InfoBarController.
27 // This protocol exists to make mocking easier in unittests. 26 // This protocol exists to make mocking easier in unittests.
28 @protocol InfoBarContainer 27 @protocol InfoBarContainerControllerBase
Robert Sesek 2013/08/26 14:06:56 "Base" implies an inheritance relationship. Can yo
sail 2013/08/26 18:32:23 What do you think of InfoBarContainerControllerPro
29 - (void)willRemoveController:(InfoBarController*)controller;
30 - (void)removeController:(InfoBarController*)controller;
31 - (BrowserWindowController*)browserWindowController; 28 - (BrowserWindowController*)browserWindowController;
29 - (BOOL)shouldSuppressTopInfoBarTip;
30 - (CGFloat)infobarArrowX;
32 @end 31 @end
33 32
34
35 namespace infobars {
36
37 // The height of an infobar without the tip.
38 const CGFloat kBaseHeight = 36.0;
39
40 // The height of the infobar tip.
41 const CGFloat kTipHeight = 12.0;
42
43 }; // namespace infobars
44
45
46 // Controller for the infobar container view, which is the superview 33 // Controller for the infobar container view, which is the superview
47 // of all the infobar views. This class owns zero or more 34 // of all the infobar views. This class owns zero or more
48 // InfoBarControllers, which manage the infobar views. This class 35 // InfoBarControllers, which manage the infobar views. This class
49 // also receives tab strip model notifications and handles 36 // also receives tab strip model notifications and handles
50 // adding/removing infobars when needed. 37 // adding/removing infobars when needed.
51 @interface InfoBarContainerController : NSViewController <ViewResizer, 38 @interface InfoBarContainerController
52 InfoBarContainer> { 39 : NSViewController<InfoBarContainerControllerBase> {
53 @private 40 @private
54 // Needed to send resize messages when infobars are added or removed. 41 // Needed to send resize messages when infobars are added or removed.
55 id<ViewResizer> resizeDelegate_; // weak 42 id<ViewResizer> resizeDelegate_; // weak
56 43
57 // The WebContents we are currently showing infobars for. 44 // The WebContents we are currently showing infobars for.
58 content::WebContents* currentWebContents_; // weak 45 content::WebContents* currentWebContents_; // weak
59 46
60 // Holds the InfoBarControllers currently owned by this container. 47 // Holds the InfoBarControllers currently owned by this container.
61 base::scoped_nsobject<NSMutableArray> infobarControllers_; 48 base::scoped_nsobject<NSMutableArray> infobarControllers_;
62 49
63 // Holds InfoBarControllers when they are in the process of animating out. 50 scoped_ptr<InfoBarContainerCocoa> containerCocoa_;
64 base::scoped_nsobject<NSMutableSet> closingInfoBars_;
65
66 // Lets us registers for INFOBAR_ADDED/INFOBAR_REMOVED
67 // notifications. The actual notifications are sent to the
68 // InfoBarNotificationObserver object, which proxies them back to us.
69 content::NotificationRegistrar registrar_;
70 scoped_ptr<InfoBarNotificationObserver> infoBarObserver_;
71 51
72 // If YES then the first info bar doesn't draw a tip. 52 // If YES then the first info bar doesn't draw a tip.
73 BOOL shouldSuppressTopInfoBarTip_; 53 BOOL shouldSuppressTopInfoBarTip_;
54
55 BOOL isAnimating_;
56
57 BOOL oldOverlappingTipHeight_;
Robert Sesek 2013/08/26 14:06:56 What's this for (i.e. document)?
sail 2013/08/26 18:32:23 Done. (Also, big oops here. That should be a int n
74 } 58 }
75 59
76 @property(nonatomic, assign) BOOL shouldSuppressTopInfoBarTip; 60 @property(nonatomic, assign) BOOL shouldSuppressTopInfoBarTip;
77 61
78 - (id)initWithResizeDelegate:(id<ViewResizer>)resizeDelegate; 62 - (id)initWithResizeDelegate:(id<ViewResizer>)resizeDelegate;
79 63
80 // Informs the container that the |controller| is going to close. It adds the 64 // Modifies this container to display infobars for the given |contents|.
81 // controller to |closingInfoBars_|. Once the animation is complete, the
82 // controller calls |-removeController:| to finalize cleanup.
83 - (void)willRemoveController:(InfoBarController*)controller;
84
85 // Removes |controller| from the list of controllers in this container and
86 // removes its view from the view hierarchy. This method is safe to call while
87 // |controller| is still on the call stack.
88 - (void)removeController:(InfoBarController*)controller;
89
90 // Modifies this container to display infobars for the given
91 // |contents|. Registers for INFOBAR_ADDED and INFOBAR_REMOVED
92 // notifications for |contents|. If we are currently showing any
93 // infobars, removes them first and deregisters for any
94 // notifications. |contents| can be NULL, in which case no infobars
95 // are shown and no notifications are registered for.
96 - (void)changeWebContents:(content::WebContents*)contents; 65 - (void)changeWebContents:(content::WebContents*)contents;
97 66
98 // Stripped down version of TabStripModelObserverBridge:tabDetachedWithContents. 67 // Stripped down version of TabStripModelObserverBridge:tabDetachedWithContents.
99 // Forwarded by BWC. Removes all infobars and deregisters for any notifications 68 // Forwarded by BWC. Removes all infobars if |contents| is the current tab
100 // if |contents| is the current tab contents. 69 // contents.
101 - (void)tabDetachedWithContents:(content::WebContents*)contents; 70 - (void)tabDetachedWithContents:(content::WebContents*)contents;
102 71
103 // Returns the number of active infobars. This is 72 // Returns the amount of additional height the container view needs to draw the
104 // |infobarControllers_ - closingInfoBars_|. 73 // anti-spoofing tip. This is the total amount of overlap for all infobars.
105 - (NSUInteger)infobarCount; 74 - (CGFloat)overlappingTipHeight;
106 75
107 // Returns the amount of additional height the container view needs to draw the 76 // Adds the given infobar.
108 // anti-spoofing tip. This will return 0 if |-infobarCount| is 0. This is the 77 - (void)addInfoBar:(InfoBarCocoa*)infobar
109 // total amount of overlap for all infobars. 78 position:(NSUInteger)position;
110 - (CGFloat)overlappingTipHeight; 79
80 // Removes the given infobar.
81 - (void)removeInfoBar:(InfoBarCocoa*)infobar;
82
83 // Positions the infobar views in the container view and notifies
84 // |browser_controller_| that it needs to resize the container view.
85 - (void)positionInfoBarsAndRedraw:(BOOL)isAnimating;
111 86
112 @end 87 @end
113 88
114
115 @interface InfoBarContainerController (ForTheObserverAndTesting)
116
117 // Adds the given infobar. Takes ownership of |infobar|.
118 - (void)addInfoBar:(InfoBar*)infobar animate:(BOOL)animate;
119
120 // Closes all the infobar views for a given delegate, either immediately or by
121 // starting a close animation.
122 - (void)closeInfoBarsForDelegate:(InfoBarDelegate*)delegate
123 animate:(BOOL)animate;
124
125 // Positions the infobar views in the container view and notifies
126 // |browser_controller_| that it needs to resize the container view.
127 - (void)positionInfoBarsAndRedraw;
128
129 @end
130
131
132 @interface InfoBarContainerController (JustForTesting)
133
134 // Removes all infobar views. Infobars which were already closing will be
135 // completely closed (i.e. the InfoBarDelegate will be deleted and we'll get a
136 // callback to removeController). Other infobars will simply stop animating and
137 // disappear. Callers must call positionInfoBarsAndRedraw() after calling this
138 // method.
139 - (void)removeAllInfoBars;
140
141 @end
142
143 #endif // CHROME_BROWSER_UI_COCOA_INFOBARS_INFOBAR_CONTAINER_CONTROLLER_H_ 89 #endif // CHROME_BROWSER_UI_COCOA_INFOBARS_INFOBAR_CONTAINER_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698