[safe-browsing] Database full hash matches like prefix match.
[chromium-blink-merge.git] / chrome / browser / infobars / infobar_service.h
blob39cca9a8d945615d14a501c4b500e36204f198c7
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 <vector>
10 #include "base/memory/scoped_ptr.h"
11 #include "components/infobars/core/infobar_manager.h"
12 #include "content/public/browser/web_contents_observer.h"
13 #include "content/public/browser/web_contents_user_data.h"
15 namespace content {
16 struct LoadCommittedDetails;
17 class WebContents;
20 namespace infobars {
21 class InfoBar;
24 // Associates a Tab to a InfoBarManager and manages its lifetime.
25 // It manages the infobar notifications and responds to navigation events.
26 class InfoBarService : public infobars::InfoBarManager,
27 public content::WebContentsObserver,
28 public content::WebContentsUserData<InfoBarService> {
29 public:
30 static infobars::InfoBarDelegate::NavigationDetails
31 NavigationDetailsFromLoadCommittedDetails(
32 const content::LoadCommittedDetails& details);
34 // This function must only be called on infobars that are owned by an
35 // InfoBarService instance (or not owned at all, in which case this returns
36 // NULL).
37 static content::WebContents* WebContentsFromInfoBar(
38 infobars::InfoBar* infobar);
40 // Retrieve the WebContents for the tab this service is associated with.
41 content::WebContents* web_contents() {
42 return content::WebContentsObserver::web_contents();
45 private:
46 friend class content::WebContentsUserData<InfoBarService>;
48 explicit InfoBarService(content::WebContents* web_contents);
49 virtual ~InfoBarService();
51 // InfoBarManager:
52 virtual int GetActiveEntryID() OVERRIDE;
53 // TODO(droger): Remove these functions once infobar notifications are
54 // removed. See http://crbug.com/354380
55 virtual void NotifyInfoBarAdded(infobars::InfoBar* infobar) OVERRIDE;
56 virtual void NotifyInfoBarRemoved(infobars::InfoBar* infobar,
57 bool animate) OVERRIDE;
58 virtual void NotifyInfoBarReplaced(infobars::InfoBar* old_infobar,
59 infobars::InfoBar* new_infobar) OVERRIDE;
61 // content::WebContentsObserver:
62 virtual void RenderProcessGone(base::TerminationStatus status) OVERRIDE;
63 virtual void NavigationEntryCommitted(
64 const content::LoadCommittedDetails& load_details) OVERRIDE;
65 virtual void WebContentsDestroyed(
66 content::WebContents* web_contents) OVERRIDE;
67 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
69 // Message handlers.
70 void OnDidBlockDisplayingInsecureContent();
71 void OnDidBlockRunningInsecureContent();
74 DISALLOW_COPY_AND_ASSIGN(InfoBarService);
77 #endif // CHROME_BROWSER_INFOBARS_INFOBAR_SERVICE_H_