Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(259)

Side by Side Diff: chrome/browser/api/infobars/infobar_service.h

Issue 11644059: Change infobar creation to use a public static Create() method on the infobar delegate classes. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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_API_INFOBARS_INFOBAR_SERVICE_H_ 5 #ifndef CHROME_BROWSER_API_INFOBARS_INFOBAR_SERVICE_H_
6 #define CHROME_BROWSER_API_INFOBARS_INFOBAR_SERVICE_H_ 6 #define CHROME_BROWSER_API_INFOBARS_INFOBAR_SERVICE_H_
7 7
8 #include <cstddef> 8 #include "base/memory/scoped_ptr.h"
9 9
10 namespace content { 10 namespace content {
11 class WebContents; 11 class WebContents;
12 } 12 }
13 13
14 class InfoBarDelegate; 14 class InfoBarDelegate;
15 15
16 // Provides access to creating, removing and enumerating info bars 16 // Provides access to creating, removing and enumerating info bars
17 // attached to a tab. 17 // attached to a tab.
18 class InfoBarService { 18 class InfoBarService {
19 public: 19 public:
20 // Passthrough functions to the implementing subclass. The subclass .cc file 20 // Passthrough functions to the implementing subclass. The subclass .cc file
21 // should define these. 21 // should define these.
22 static void CreateForWebContents(content::WebContents* web_contents); 22 static void CreateForWebContents(content::WebContents* web_contents);
23 static InfoBarService* FromWebContents(content::WebContents* web_contents); 23 static InfoBarService* FromWebContents(content::WebContents* web_contents);
24 static const InfoBarService* 24 static const InfoBarService*
25 FromWebContents(const content::WebContents* web_contents); 25 FromWebContents(const content::WebContents* web_contents);
26 26
27 virtual ~InfoBarService(); 27 virtual ~InfoBarService();
28 28
29 // Changes whether infobars are enabled. The default is true. 29 // Changes whether infobars are enabled. The default is true.
30 virtual void SetInfoBarsEnabled(bool enabled) = 0; 30 virtual void SetInfoBarsEnabled(bool enabled) = 0;
31 31
32 // Adds an InfoBar for the specified |delegate|. 32 // Adds an InfoBar for the specified |delegate|.
33 // 33 //
34 // If infobars are disabled for this tab or the tab already has a delegate 34 // If infobars are disabled for this tab or the tab already has a delegate
35 // which returns true for InfoBarDelegate::EqualsDelegate(delegate), 35 // which returns true for InfoBarDelegate::EqualsDelegate(delegate),
36 // |delegate| is closed immediately without being added. 36 // |delegate| is closed immediately without being added.
37 // 37 //
38 // Returns whether |delegate| was successfully added. 38 // Returns the delegate if it was successfully added.
39 virtual bool AddInfoBar(InfoBarDelegate* delegate) = 0; 39 virtual InfoBarDelegate* AddInfoBar(scoped_ptr<InfoBarDelegate> delegate) = 0;
40 40
41 // Removes the InfoBar for the specified |delegate|. 41 // Removes the InfoBar for the specified |delegate|.
42 // 42 //
43 // If infobars are disabled for this tab, this will do nothing, on the 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 44 // assumption that the matching AddInfoBar() call will have already closed the
45 // delegate (see above). 45 // delegate (see above).
46 virtual void RemoveInfoBar(InfoBarDelegate* delegate) = 0; 46 virtual void RemoveInfoBar(InfoBarDelegate* delegate) = 0;
47 47
48 // Replaces one infobar with another, without any animation in between. 48 // Replaces one infobar with another, without any animation in between.
49 // 49 //
50 // If infobars are disabled for this tab, |new_delegate| is closed immediately 50 // If infobars are disabled for this tab, |new_delegate| is closed immediately
51 // without being added, and nothing else happens. 51 // without being added, and nothing else happens.
52 // 52 //
53 // Returns whether |new_delegate| was successfully added. 53 // Returns the new delegate if it was successfully added.
54 // 54 //
55 // NOTE: This does not perform any EqualsDelegate() checks like AddInfoBar(). 55 // NOTE: This does not perform any EqualsDelegate() checks like AddInfoBar().
56 virtual bool ReplaceInfoBar(InfoBarDelegate* old_delegate, 56 virtual InfoBarDelegate* ReplaceInfoBar(
57 InfoBarDelegate* new_delegate) = 0; 57 InfoBarDelegate* old_delegate,
58 scoped_ptr<InfoBarDelegate> new_delegate) = 0;
58 59
59 // Returns the number of infobars for this tab. 60 // Returns the number of infobars for this tab.
60 virtual size_t GetInfoBarCount() const = 0; 61 virtual size_t GetInfoBarCount() const = 0;
61 62
62 // Returns the infobar at the given |index|. 63 // Returns the infobar delegate at the given |index|. The InfoBarService
64 // retains ownership.
63 // 65 //
64 // Warning: Does not sanity check |index|. 66 // Warning: Does not sanity check |index|.
65 virtual InfoBarDelegate* GetInfoBarDelegateAt(size_t index) = 0; 67 virtual InfoBarDelegate* GetInfoBarDelegateAt(size_t index) = 0;
66 68
67 // Retrieve the WebContents for the tab this service is associated with. 69 // Retrieve the WebContents for the tab this service is associated with.
68 virtual content::WebContents* GetWebContents() = 0; 70 virtual content::WebContents* GetWebContents() = 0;
69 }; 71 };
70 72
71 #endif // CHROME_BROWSER_API_INFOBARS_INFOBAR_SERVICE_H_ 73 #endif // CHROME_BROWSER_API_INFOBARS_INFOBAR_SERVICE_H_
OLDNEW
« no previous file with comments | « chrome/browser/api/infobars/infobar_delegate.cc ('k') | chrome/browser/api/infobars/simple_alert_infobar_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698