blob: a9ee57fc20421d2ea147d2c6f44977ea2a8cc543 [file] [log] [blame]
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef IOS_CHROME_BROWSER_UPGRADE_UPGRADE_CENTER_H_
#define IOS_CHROME_BROWSER_UPGRADE_UPGRADE_CENTER_H_
#import <UIKit/UIKit.h>
#include "ios/chrome/browser/upgrade/upgrade_recommended_details.h"
@class UpgradeCenter;
namespace infobars {
class InfoBarManager;
}
@protocol UpgradeCenterClientProtocol
// This is expected to call -addInfoBarToHelper:forTabId: for each tab to place
// the infobars in the UI. The client must not unregister itself while in this
// method.
- (void)showUpgrade:(UpgradeCenter*)center;
@end
@interface UpgradeCenter : NSObject
// Returns the singleton instance of the class.
+ (UpgradeCenter*)sharedInstance;
// Registers a client for the UpgradeCenter. The clients are not retained,
// unregisterClient: must be called before the object goes away.
- (void)registerClient:(id<UpgradeCenterClientProtocol>)client;
// Unregisters a client.
- (void)unregisterClient:(id<UpgradeCenterClientProtocol>)client;
// Clients should call this method when -showUpgrade: is called or when a new
// tab is created. The infobar will not be created if it already exists or if
// there is no need to do so.
- (void)addInfoBarToManager:(infobars::InfoBarManager*)infoBarManager
forTabId:(NSString*)tabId;
// For the UpgradeCenter to make the distinction between an infobar closed by
// the user directly and an infobar dismissed because the Tab it is on is
// removed.
- (void)tabWillClose:(NSString*)tabId;
// Called when a notification is received from one of the upgrade mechanism.
- (void)upgradeNotificationDidOccur:(const UpgradeRecommendedDetails&)details;
@end
@interface UpgradeCenter (UsedForTests)
// Reset everything (forget clients, remove the infobar everywhere...)
- (void)resetForTests;
// Simulate the minimum display interval having elapsed.
- (void)setLastDisplayToPast;
@end
#endif // IOS_CHROME_BROWSER_UPGRADE_UPGRADE_CENTER_H_