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

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

Issue 228293004: InfoBarService inherits from InfoBarManager (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: whitespace Created 6 years, 8 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_INFOBARS_INFOBAR_SERVICE_H_ 5 #ifndef CHROME_BROWSER_INFOBARS_INFOBAR_SERVICE_H_
6 #define CHROME_BROWSER_INFOBARS_INFOBAR_SERVICE_H_ 6 #define CHROME_BROWSER_INFOBARS_INFOBAR_SERVICE_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "chrome/browser/infobars/infobar_manager.h" 11 #include "chrome/browser/infobars/infobar_manager.h"
12 #include "content/public/browser/web_contents_observer.h" 12 #include "content/public/browser/web_contents_observer.h"
13 #include "content/public/browser/web_contents_user_data.h" 13 #include "content/public/browser/web_contents_user_data.h"
14 14
15 namespace content { 15 namespace content {
16 struct LoadCommittedDetails; 16 struct LoadCommittedDetails;
17 class WebContents; 17 class WebContents;
18 } 18 }
19 19
20 class InfoBar; 20 class InfoBar;
21 21
22 // Associates a Tab to a InfoBarManager and manages its lifetime. 22 // Associates a Tab to a InfoBarManager and manages its lifetime.
23 // It manages the infobar notifications and responds to navigation events. 23 // It manages the infobar notifications and responds to navigation events.
24 class InfoBarService : public content::WebContentsObserver, 24 class InfoBarService : public InfoBarManager,
25 public content::WebContentsUserData<InfoBarService>, 25 public content::WebContentsObserver,
26 public InfoBarManager::Observer { 26 public content::WebContentsUserData<InfoBarService> {
27 public: 27 public:
28 // Helper function to get the InfoBarManager attached to |web_contents|.
29 static InfoBarManager* InfoBarManagerFromWebContents(
30 content::WebContents* web_contents);
31
32 static InfoBarDelegate::NavigationDetails 28 static InfoBarDelegate::NavigationDetails
33 NavigationDetailsFromLoadCommittedDetails( 29 NavigationDetailsFromLoadCommittedDetails(
34 const content::LoadCommittedDetails& details); 30 const content::LoadCommittedDetails& details);
35 31
36 // These methods are simple pass-throughs to InfoBarManager, and are here to 32 // This function must only be called on infobars that are owned by an
37 // prepare for the componentization of Infobars, see http://crbug.com/354379. 33 // InfoBarService instance (or not owned at all, in which case this returns
38 InfoBar* AddInfoBar(scoped_ptr<InfoBar> infobar); 34 // NULL).
39 InfoBar* ReplaceInfoBar(InfoBar* old_infobar, 35 static content::WebContents* WebContentsFromInfoBar(InfoBar* infobar);
40 scoped_ptr<InfoBar> new_infobar);
41 36
42 // Retrieve the WebContents for the tab this service is associated with. 37 // Retrieve the WebContents for the tab this service is associated with.
43 content::WebContents* web_contents() { 38 content::WebContents* web_contents() {
44 return content::WebContentsObserver::web_contents(); 39 return content::WebContentsObserver::web_contents();
45 } 40 }
46 41
47 InfoBarManager* infobar_manager() { return &infobar_manager_; }
48
49 private: 42 private:
50 friend class content::WebContentsUserData<InfoBarService>; 43 friend class content::WebContentsUserData<InfoBarService>;
51 44
52 explicit InfoBarService(content::WebContents* web_contents); 45 explicit InfoBarService(content::WebContents* web_contents);
53 virtual ~InfoBarService(); 46 virtual ~InfoBarService();
54 47
48 // InfoBarManager:
49 // TODO(droger): Remove these functions once infobar notifications are
50 // removed. See http://crbug.com/354380
51 virtual void NotifyInfoBarAdded(InfoBar* infobar) OVERRIDE;
52 virtual void NotifyInfoBarRemoved(InfoBar* infobar, bool animate) OVERRIDE;
53 virtual void NotifyInfoBarReplaced(InfoBar* old_infobar,
54 InfoBar* new_infobar) OVERRIDE;
55
55 // content::WebContentsObserver: 56 // content::WebContentsObserver:
56 virtual void RenderProcessGone(base::TerminationStatus status) OVERRIDE; 57 virtual void RenderProcessGone(base::TerminationStatus status) OVERRIDE;
57 virtual void NavigationEntryCommitted( 58 virtual void NavigationEntryCommitted(
58 const content::LoadCommittedDetails& load_details) OVERRIDE; 59 const content::LoadCommittedDetails& load_details) OVERRIDE;
59 virtual void WebContentsDestroyed( 60 virtual void WebContentsDestroyed(
60 content::WebContents* web_contents) OVERRIDE; 61 content::WebContents* web_contents) OVERRIDE;
61 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 62 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
62 63
63 // InfoBarManager::Observer:
64 virtual void OnInfoBarAdded(InfoBar* infobar) OVERRIDE;
65 virtual void OnInfoBarReplaced(InfoBar* old_infobar,
66 InfoBar* new_infobar) OVERRIDE;
67 virtual void OnInfoBarRemoved(InfoBar* infobar, bool animate) OVERRIDE;
68 virtual void OnManagerShuttingDown(InfoBarManager* manager) OVERRIDE;
69
70 // Message handlers. 64 // Message handlers.
71 void OnDidBlockDisplayingInsecureContent(); 65 void OnDidBlockDisplayingInsecureContent();
72 void OnDidBlockRunningInsecureContent(); 66 void OnDidBlockRunningInsecureContent();
73 67
74 InfoBarManager infobar_manager_;
75 68
76 DISALLOW_COPY_AND_ASSIGN(InfoBarService); 69 DISALLOW_COPY_AND_ASSIGN(InfoBarService);
77 }; 70 };
78 71
79 #endif // CHROME_BROWSER_INFOBARS_INFOBAR_SERVICE_H_ 72 #endif // CHROME_BROWSER_INFOBARS_INFOBAR_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698