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