Fix build break
[chromium-blink-merge.git] / chrome / browser / infobars / infobar_service.h
blobcab8149f07d5387f780774d1603953fca48ccdb6
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_INFOBARS_INFOBAR_SERVICE_H_
6 #define CHROME_BROWSER_INFOBARS_INFOBAR_SERVICE_H_
8 #include "base/memory/scoped_ptr.h"
10 namespace content {
11 class WebContents;
14 class InfoBarDelegate;
16 // Provides access to creating, removing and enumerating info bars
17 // attached to a tab.
18 class InfoBarService {
19 public:
20 // Passthrough functions to the implementing subclass. The subclass .cc file
21 // should define these.
22 static void CreateForWebContents(content::WebContents* web_contents);
23 static InfoBarService* FromWebContents(content::WebContents* web_contents);
24 static const InfoBarService*
25 FromWebContents(const content::WebContents* web_contents);
27 virtual ~InfoBarService();
29 // Changes whether infobars are enabled. The default is true.
30 virtual void SetInfoBarsEnabled(bool enabled) = 0;
32 // Adds an InfoBar for the specified |delegate|.
34 // If infobars are disabled for this tab or the tab already has a delegate
35 // which returns true for InfoBarDelegate::EqualsDelegate(delegate),
36 // |delegate| is closed immediately without being added.
38 // Returns the delegate if it was successfully added.
39 virtual InfoBarDelegate* AddInfoBar(scoped_ptr<InfoBarDelegate> delegate) = 0;
41 // Removes the InfoBar for the specified |delegate|.
43 // If infobars are disabled for this tab, this will do nothing, on the
44 // assumption that the matching AddInfoBar() call will have already closed the
45 // delegate (see above).
46 virtual void RemoveInfoBar(InfoBarDelegate* delegate) = 0;
48 // Replaces one infobar with another, without any animation in between.
50 // If infobars are disabled for this tab, |new_delegate| is closed immediately
51 // without being added, and nothing else happens.
53 // Returns the new delegate if it was successfully added.
55 // NOTE: This does not perform any EqualsDelegate() checks like AddInfoBar().
56 virtual InfoBarDelegate* ReplaceInfoBar(
57 InfoBarDelegate* old_delegate,
58 scoped_ptr<InfoBarDelegate> new_delegate) = 0;
60 // Returns the number of infobars for this tab.
61 virtual size_t GetInfoBarCount() const = 0;
63 // Returns the infobar delegate at the given |index|. The InfoBarService
64 // retains ownership.
66 // Warning: Does not sanity check |index|.
67 virtual InfoBarDelegate* GetInfoBarDelegateAt(size_t index) = 0;
69 // Retrieve the WebContents for the tab this service is associated with.
70 virtual content::WebContents* GetWebContents() = 0;
73 #endif // CHROME_BROWSER_INFOBARS_INFOBAR_SERVICE_H_