BookmarkManager: Fix 'new folder text field size changes on clicking it' issue.
[chromium-blink-merge.git] / chrome / browser / infobars / infobar_service.h
blobdc4ceb36a935e0e7ba5ae77503520ad20f54fced
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 // Makes it so the next reload is ignored. That is, if the next commit is a
41 // reload then it is treated as if nothing happened and no infobars are
42 // attempted to be closed.
43 // This is useful for non-user triggered reloads that should not dismiss
44 // infobars. For example, instant may trigger a reload when the google URL
45 // changes.
46 void set_ignore_next_reload() { ignore_next_reload_ = true; }
48 // InfoBarManager:
49 // TODO(sdefresne): Change clients to invoke this on infobars::InfoBarManager
50 // and turn the method override private.
51 scoped_ptr<infobars::InfoBar> CreateConfirmInfoBar(
52 scoped_ptr<ConfirmInfoBarDelegate> delegate) override;
54 private:
55 friend class content::WebContentsUserData<InfoBarService>;
57 explicit InfoBarService(content::WebContents* web_contents);
58 ~InfoBarService() override;
60 // InfoBarManager:
61 int GetActiveEntryID() override;
62 // TODO(droger): Remove these functions once infobar notifications are
63 // removed. See http://crbug.com/354380
64 void NotifyInfoBarAdded(infobars::InfoBar* infobar) override;
65 void NotifyInfoBarRemoved(infobars::InfoBar* infobar, bool animate) override;
67 // content::WebContentsObserver:
68 void RenderProcessGone(base::TerminationStatus status) override;
69 void DidStartNavigationToPendingEntry(
70 const GURL& url,
71 content::NavigationController::ReloadType reload_type) override;
72 void NavigationEntryCommitted(
73 const content::LoadCommittedDetails& load_details) override;
74 void WebContentsDestroyed() override;
75 bool OnMessageReceived(const IPC::Message& message) override;
77 // Message handlers.
78 void OnDidBlockDisplayingInsecureContent();
80 // See description in set_ignore_next_reload().
81 bool ignore_next_reload_;
83 DISALLOW_COPY_AND_ASSIGN(InfoBarService);
86 #endif // CHROME_BROWSER_INFOBARS_INFOBAR_SERVICE_H_