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

Side by Side Diff: chrome/browser/infobars/infobar_tab_helper.h

Issue 7810002: Move infobar handling to a tab helper. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: update Created 9 years, 3 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_INFOBARS_INFOBAR_TAB_HELPER_H_
6 #define CHROME_BROWSER_INFOBARS_INFOBAR_TAB_HELPER_H_
7 #pragma once
8
9 #include "base/basictypes.h"
10 #include "content/browser/tab_contents/tab_contents_observer.h"
11 #include "content/common/notification_registrar.h"
12
13 class InfoBarDelegate;
14 class TabContentsWrapper;
15
16 // Per-tab info bar manager.
17 class InfoBarTabHelper : public TabContentsObserver,
18 public NotificationObserver {
19 public:
20 explicit InfoBarTabHelper(TabContentsWrapper* tab_contents);
21 virtual ~InfoBarTabHelper();
22
23 // Adds an InfoBar for the specified |delegate|.
24 //
25 // If infobars are disabled for this tab or the tab already has a delegate
26 // which returns true for InfoBarDelegate::EqualsDelegate(delegate),
27 // |delegate| is closed immediately without being added.
28 void AddInfoBar(InfoBarDelegate* delegate);
29
30 // Removes the InfoBar for the specified |delegate|.
31 //
32 // If infobars are disabled for this tab, this will do nothing, on the
33 // assumption that the matching AddInfoBar() call will have already closed the
34 // delegate (see above).
35 void RemoveInfoBar(InfoBarDelegate* delegate);
36
37 // Replaces one infobar with another, without any animation in between.
38 //
39 // If infobars are disabled for this tab, |new_delegate| is closed immediately
40 // without being added, and nothing else happens.
41 //
42 // NOTE: This does not perform any EqualsDelegate() checks like AddInfoBar().
43 void ReplaceInfoBar(InfoBarDelegate* old_delegate,
44 InfoBarDelegate* new_delegate);
45
46 // Enumeration and access functions.
47 size_t infobar_count() const { return infobars_.size(); }
48 // WARNING: This does not sanity-check |index|!
49 InfoBarDelegate* GetInfoBarDelegateAt(size_t index);
50 void set_infobars_enabled(bool value) { infobars_enabled_ = value; }
51
52 // TabContentsObserver overrides:
53 virtual void RenderViewGone() OVERRIDE;
54 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
55
56 // NotificationObserver overrides:
57 virtual void Observe(int type,
58 const NotificationSource& source,
59 const NotificationDetails& details) OVERRIDE;
60
61 private:
62 void RemoveInfoBarInternal(InfoBarDelegate* delegate, bool animate);
63 void RemoveAllInfoBars(bool animate);
64
65 // Message handlers.
66 void OnDidBlockDisplayingInsecureContent();
67 void OnDidBlockRunningInsecureContent();
68
69 // Delegates for InfoBars associated with this InfoBarTabHelper.
70 std::vector<InfoBarDelegate*> infobars_;
71 bool infobars_enabled_;
72
73 NotificationRegistrar registrar_;
74
75 // Owning TabContentsWrapper.
76 TabContentsWrapper* tab_contents_wrapper_;
77
78 DISALLOW_COPY_AND_ASSIGN(InfoBarTabHelper);
79 };
80
81 #endif // CHROME_BROWSER_INFOBARS_INFOBAR_TAB_HELPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698