blob: 1814b615523bb6d8eb506da9d5098585c5e3f7dc [file] [log] [blame]
pfeldmand3a885c2015-10-22 23:28:261// Copyright 2014 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_DEVTOOLS_GLOBAL_CONFIRM_INFO_BAR_H_
6#define CHROME_BROWSER_DEVTOOLS_GLOBAL_CONFIRM_INFO_BAR_H_
7
8#include <map>
9
10#include "base/macros.h"
11#include "base/memory/weak_ptr.h"
12#include "chrome/browser/infobars/infobar_service.h"
13#include "chrome/browser/ui/browser_tab_strip_tracker.h"
14#include "chrome/browser/ui/tabs/tab_strip_model_observer.h"
15#include "components/infobars/core/confirm_infobar_delegate.h"
16
17namespace content {
18class WebContents;
19}
20
21// GlobalConfirmInfoBar is shown for every tab in every browser until it
22// is dismissed or the close method is called.
23// It listens to all tabs in all browsers and adds/removes confirm infobar
24// to each of the tabs.
25class GlobalConfirmInfoBar : public TabStripModelObserver,
26 public infobars::InfoBarManager::Observer {
27 public:
28 static base::WeakPtr<GlobalConfirmInfoBar>
29 Show(scoped_ptr<ConfirmInfoBarDelegate> delegate);
30 void Close();
31
32 private:
33 explicit GlobalConfirmInfoBar(scoped_ptr<ConfirmInfoBarDelegate> delegate);
34 ~GlobalConfirmInfoBar() override;
35 class DelegateProxy;
36
37 // TabStripModelObserver:
38 void TabInsertedAt(content::WebContents* web_contents,
39 int index,
40 bool foreground) override;
41 void TabChangedAt(content::WebContents* web_contents,
42 int index,
43 TabChangeType change_type) override;
44
45 // infobars::InfoBarManager::Observer:
46 void OnInfoBarRemoved(infobars::InfoBar* info_bar, bool animate) override;
47 void OnManagerShuttingDown(infobars::InfoBarManager* manager) override;
48
49 scoped_ptr<ConfirmInfoBarDelegate> delegate_;
50 std::map<infobars::InfoBarManager*, DelegateProxy*> proxies_;
51 BrowserTabStripTracker browser_tab_strip_tracker_;
52
53 base::WeakPtrFactory<GlobalConfirmInfoBar> weak_factory_;
54
55 DISALLOW_COPY_AND_ASSIGN(GlobalConfirmInfoBar);
56};
57
58#endif // CHROME_BROWSER_DEVTOOLS_GLOBAL_CONFIRM_INFO_BAR_H_