15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2011 The Chromium Authors. All rights reserved. 25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file. 45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef CHROME_BROWSER_UI_COCOA_INFOBARS_INFOBAR_CONTAINER_CONTROLLER_H_ 65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define CHROME_BROWSER_UI_COCOA_INFOBARS_INFOBAR_CONTAINER_CONTROLLER_H_ 75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#import <Cocoa/Cocoa.h> 95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 10eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch#include "base/mac/scoped_nsobject.h" 115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/memory/scoped_ptr.h" 125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#import "chrome/browser/ui/cocoa/view_resizer.h" 135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)@class BrowserWindowController; 155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)@class InfoBarController; 16424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)class InfoBarCocoa; 17424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)class InfoBarContainerCocoa; 185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class TabStripModel; 195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace content { 215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class WebContents; 225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 240529e5d033099cbfc42635f6f6183833b09dff6eBen Murdochnamespace infobars { 250529e5d033099cbfc42635f6f6183833b09dff6eBen Murdochclass InfoBarDelegate; 260529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch} 270529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch 285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Protocol for basic container methods, as needed by an InfoBarController. 295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// This protocol exists to make mocking easier in unittests. 30424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)@protocol InfoBarContainerControllerBase 315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)- (BrowserWindowController*)browserWindowController; 32424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)- (BOOL)shouldSuppressTopInfoBarTip; 33424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)- (CGFloat)infobarArrowX; 345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)@end 355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Controller for the infobar container view, which is the superview 375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// of all the infobar views. This class owns zero or more 385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// InfoBarControllers, which manage the infobar views. This class 395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// also receives tab strip model notifications and handles 405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// adding/removing infobars when needed. 41424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)@interface InfoBarContainerController 42424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) : NSViewController<InfoBarContainerControllerBase> { 435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) @private 445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Needed to send resize messages when infobars are added or removed. 455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) id<ViewResizer> resizeDelegate_; // weak 465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The WebContents we are currently showing infobars for. 485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) content::WebContents* currentWebContents_; // weak 495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Holds the InfoBarControllers currently owned by this container. 51eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch base::scoped_nsobject<NSMutableArray> infobarControllers_; 525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 53424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) // The C++ instance that bridges to the cross platform code. 54424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) scoped_ptr<InfoBarContainerCocoa> containerCocoa_; 5590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 5690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // If YES then the first info bar doesn't draw a tip. 5790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) BOOL shouldSuppressTopInfoBarTip_; 58424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) 59424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) // If YES then an infobar animation is in progress. 60424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) BOOL isAnimating_; 615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)@property(nonatomic, assign) BOOL shouldSuppressTopInfoBarTip; 6490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)- (id)initWithResizeDelegate:(id<ViewResizer>)resizeDelegate; 665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 67424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)// Modifies this container to display infobars for the given |contents|. 685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)- (void)changeWebContents:(content::WebContents*)contents; 695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Stripped down version of TabStripModelObserverBridge:tabDetachedWithContents. 71424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)// Forwarded by BWC. Removes all infobars if |contents| is the current tab 72424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)// contents. 735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)- (void)tabDetachedWithContents:(content::WebContents*)contents; 745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Returns the amount of additional height the container view needs to draw the 76424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)// anti-spoofing tip. This is the total amount of overlap for all infobars. 775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)- (CGFloat)overlappingTipHeight; 785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 79424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)// Adds the given infobar. 80424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)- (void)addInfoBar:(InfoBarCocoa*)infobar 81424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) position:(NSUInteger)position; 825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 83424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)// Removes the given infobar. 84424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)- (void)removeInfoBar:(InfoBarCocoa*)infobar; 855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Positions the infobar views in the container view and notifies 875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// |browser_controller_| that it needs to resize the container view. 88424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)- (void)positionInfoBarsAndRedraw:(BOOL)isAnimating; 895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 901320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci// Set the max arrow height of the top infobar. 911320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci- (void)setMaxTopArrowHeight:(NSInteger)height; 921320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci 931320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci// The height of all the info bars. Does not include the top arrow. 941320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci- (CGFloat)heightOfInfoBars; 951320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci 965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)@end 975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif // CHROME_BROWSER_UI_COCOA_INFOBARS_INFOBAR_CONTAINER_CONTROLLER_H_ 99