| OLD | NEW |
| 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/memory/scoped_nsobject.h" | 10 #include "base/memory/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" | 13 #include "content/public/browser/notification_registrar.h" |
| 14 | 14 |
| 15 @class BrowserWindowController; | 15 @class BrowserWindowController; |
| 16 @class InfoBarController; | 16 @class InfoBarController; |
| 17 class InfoBar; | 17 class InfoBar; |
| 18 class InfoBarDelegate; | 18 class InfoBarDelegate; |
| 19 class InfoBarNotificationObserver; | 19 class InfoBarNotificationObserver; |
| 20 class TabContents; | |
| 21 class TabStripModel; | 20 class TabStripModel; |
| 22 | 21 |
| 22 namespace content { |
| 23 class WebContents; |
| 24 } |
| 25 |
| 23 // Protocol for basic container methods, as needed by an InfoBarController. | 26 // Protocol for basic container methods, as needed by an InfoBarController. |
| 24 // This protocol exists to make mocking easier in unittests. | 27 // This protocol exists to make mocking easier in unittests. |
| 25 @protocol InfoBarContainer | 28 @protocol InfoBarContainer |
| 26 - (void)willRemoveController:(InfoBarController*)controller; | 29 - (void)willRemoveController:(InfoBarController*)controller; |
| 27 - (void)removeController:(InfoBarController*)controller; | 30 - (void)removeController:(InfoBarController*)controller; |
| 28 - (BrowserWindowController*)browserWindowController; | 31 - (BrowserWindowController*)browserWindowController; |
| 29 @end | 32 @end |
| 30 | 33 |
| 31 | 34 |
| 32 namespace infobars { | 35 namespace infobars { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 44 // of all the infobar views. This class owns zero or more | 47 // of all the infobar views. This class owns zero or more |
| 45 // InfoBarControllers, which manage the infobar views. This class | 48 // InfoBarControllers, which manage the infobar views. This class |
| 46 // also receives tab strip model notifications and handles | 49 // also receives tab strip model notifications and handles |
| 47 // adding/removing infobars when needed. | 50 // adding/removing infobars when needed. |
| 48 @interface InfoBarContainerController : NSViewController <ViewResizer, | 51 @interface InfoBarContainerController : NSViewController <ViewResizer, |
| 49 InfoBarContainer> { | 52 InfoBarContainer> { |
| 50 @private | 53 @private |
| 51 // Needed to send resize messages when infobars are added or removed. | 54 // Needed to send resize messages when infobars are added or removed. |
| 52 id<ViewResizer> resizeDelegate_; // weak | 55 id<ViewResizer> resizeDelegate_; // weak |
| 53 | 56 |
| 54 // The TabContents we are currently showing infobars for. | 57 // The WebContents we are currently showing infobars for. |
| 55 TabContents* currentTabContents_; // weak | 58 content::WebContents* currentWebContents_; // weak |
| 56 | 59 |
| 57 // Holds the InfoBarControllers currently owned by this container. | 60 // Holds the InfoBarControllers currently owned by this container. |
| 58 scoped_nsobject<NSMutableArray> infobarControllers_; | 61 scoped_nsobject<NSMutableArray> infobarControllers_; |
| 59 | 62 |
| 60 // Holds InfoBarControllers when they are in the process of animating out. | 63 // Holds InfoBarControllers when they are in the process of animating out. |
| 61 scoped_nsobject<NSMutableSet> closingInfoBars_; | 64 scoped_nsobject<NSMutableSet> closingInfoBars_; |
| 62 | 65 |
| 63 // Lets us registers for INFOBAR_ADDED/INFOBAR_REMOVED | 66 // Lets us registers for INFOBAR_ADDED/INFOBAR_REMOVED |
| 64 // notifications. The actual notifications are sent to the | 67 // notifications. The actual notifications are sent to the |
| 65 // InfoBarNotificationObserver object, which proxies them back to us. | 68 // InfoBarNotificationObserver object, which proxies them back to us. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 78 // removes its view from the view hierarchy. This method is safe to call while | 81 // removes its view from the view hierarchy. This method is safe to call while |
| 79 // |controller| is still on the call stack. | 82 // |controller| is still on the call stack. |
| 80 - (void)removeController:(InfoBarController*)controller; | 83 - (void)removeController:(InfoBarController*)controller; |
| 81 | 84 |
| 82 // Modifies this container to display infobars for the given | 85 // Modifies this container to display infobars for the given |
| 83 // |contents|. Registers for INFOBAR_ADDED and INFOBAR_REMOVED | 86 // |contents|. Registers for INFOBAR_ADDED and INFOBAR_REMOVED |
| 84 // notifications for |contents|. If we are currently showing any | 87 // notifications for |contents|. If we are currently showing any |
| 85 // infobars, removes them first and deregisters for any | 88 // infobars, removes them first and deregisters for any |
| 86 // notifications. |contents| can be NULL, in which case no infobars | 89 // notifications. |contents| can be NULL, in which case no infobars |
| 87 // are shown and no notifications are registered for. | 90 // are shown and no notifications are registered for. |
| 88 - (void)changeTabContents:(TabContents*)contents; | 91 - (void)changeWebContents:(content::WebContents*)contents; |
| 89 | 92 |
| 90 // Stripped down version of TabStripModelObserverBridge:tabDetachedWithContents. | 93 // Stripped down version of TabStripModelObserverBridge:tabDetachedWithContents. |
| 91 // Forwarded by BWC. Removes all infobars and deregisters for any notifications | 94 // Forwarded by BWC. Removes all infobars and deregisters for any notifications |
| 92 // if |contents| is the current tab contents. | 95 // if |contents| is the current tab contents. |
| 93 - (void)tabDetachedWithContents:(TabContents*)contents; | 96 - (void)tabDetachedWithContents:(content::WebContents*)contents; |
| 94 | 97 |
| 95 // Returns the number of active infobars. This is | 98 // Returns the number of active infobars. This is |
| 96 // |infobarControllers_ - closingInfoBars_|. | 99 // |infobarControllers_ - closingInfoBars_|. |
| 97 - (NSUInteger)infobarCount; | 100 - (NSUInteger)infobarCount; |
| 98 | 101 |
| 99 // Returns the amount of additional height the container view needs to draw the | 102 // Returns the amount of additional height the container view needs to draw the |
| 100 // anti-spoofing tip. This will return 0 if |-infobarCount| is 0. This is the | 103 // anti-spoofing tip. This will return 0 if |-infobarCount| is 0. This is the |
| 101 // total amount of overlap for all infobars. | 104 // total amount of overlap for all infobars. |
| 102 - (CGFloat)overlappingTipHeight; | 105 - (CGFloat)overlappingTipHeight; |
| 103 | 106 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 126 // Removes all infobar views. Infobars which were already closing will be | 129 // Removes all infobar views. Infobars which were already closing will be |
| 127 // completely closed (i.e. InfobarDelegate::InfoBarClosed() will be called and | 130 // completely closed (i.e. InfobarDelegate::InfoBarClosed() will be called and |
| 128 // we'll get a callback to removeController). Other infobars will simply stop | 131 // we'll get a callback to removeController). Other infobars will simply stop |
| 129 // animating and disappear. Callers must call positionInfoBarsAndRedraw() | 132 // animating and disappear. Callers must call positionInfoBarsAndRedraw() |
| 130 // after calling this method. | 133 // after calling this method. |
| 131 - (void)removeAllInfoBars; | 134 - (void)removeAllInfoBars; |
| 132 | 135 |
| 133 @end | 136 @end |
| 134 | 137 |
| 135 #endif // CHROME_BROWSER_UI_COCOA_INFOBARS_INFOBAR_CONTAINER_CONTROLLER_H_ | 138 #endif // CHROME_BROWSER_UI_COCOA_INFOBARS_INFOBAR_CONTAINER_CONTROLLER_H_ |
| OLD | NEW |