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