OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #include "chrome/browser/devtools/global_confirm_info_bar.h" | 5 #include "chrome/browser/devtools/global_confirm_info_bar.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
11 #include "chrome/browser/ui/host_desktop.h" | 11 #include "chrome/browser/ui/host_desktop.h" |
12 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 12 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
13 #include "components/infobars/core/infobar.h" | 13 #include "components/infobars/core/infobar.h" |
14 #include "ui/gfx/image/image.h" | 14 #include "ui/gfx/image/image.h" |
15 | 15 |
16 // InfoBarDelegateProxy ------------------------------------------------------- | 16 // InfoBarDelegateProxy ------------------------------------------------------- |
17 | 17 |
18 class GlobalConfirmInfoBar::DelegateProxy : public ConfirmInfoBarDelegate { | 18 class GlobalConfirmInfoBar::DelegateProxy : public ConfirmInfoBarDelegate { |
19 public: | 19 public: |
20 explicit DelegateProxy(base::WeakPtr<GlobalConfirmInfoBar> global_info_bar); | 20 explicit DelegateProxy(base::WeakPtr<GlobalConfirmInfoBar> global_info_bar); |
21 ~DelegateProxy() override; | 21 ~DelegateProxy() override; |
22 void Detach(); | 22 void Detach(); |
23 | 23 |
24 private: | 24 private: |
25 friend class GlobalConfirmInfoBar; | 25 friend class GlobalConfirmInfoBar; |
26 | 26 |
27 // ConfirmInfoBarDelegate overrides | 27 // ConfirmInfoBarDelegate overrides |
28 infobars::InfoBarDelegate::InfoBarIdentifier GetIdentifier() const override; | |
28 base::string16 GetMessageText() const override; | 29 base::string16 GetMessageText() const override; |
29 int GetButtons() const override; | 30 int GetButtons() const override; |
30 base::string16 GetButtonLabel(InfoBarButton button) const override; | 31 base::string16 GetButtonLabel(InfoBarButton button) const override; |
31 bool Accept() override; | 32 bool Accept() override; |
32 bool Cancel() override; | 33 bool Cancel() override; |
33 base::string16 GetLinkText() const override; | 34 base::string16 GetLinkText() const override; |
34 GURL GetLinkURL() const override; | 35 GURL GetLinkURL() const override; |
35 bool LinkClicked(WindowOpenDisposition disposition) override; | 36 bool LinkClicked(WindowOpenDisposition disposition) override; |
36 bool EqualsDelegate(infobars::InfoBarDelegate* delegate) const override; | 37 bool EqualsDelegate(infobars::InfoBarDelegate* delegate) const override; |
37 void InfoBarDismissed() override; | 38 void InfoBarDismissed() override; |
38 | 39 |
39 infobars::InfoBar* info_bar_; | 40 infobars::InfoBar* info_bar_; |
40 base::WeakPtr<GlobalConfirmInfoBar> global_info_bar_; | 41 base::WeakPtr<GlobalConfirmInfoBar> global_info_bar_; |
41 | 42 |
42 DISALLOW_COPY_AND_ASSIGN(DelegateProxy); | 43 DISALLOW_COPY_AND_ASSIGN(DelegateProxy); |
43 }; | 44 }; |
44 | 45 |
45 GlobalConfirmInfoBar::DelegateProxy::DelegateProxy( | 46 GlobalConfirmInfoBar::DelegateProxy::DelegateProxy( |
46 base::WeakPtr<GlobalConfirmInfoBar> global_info_bar) | 47 base::WeakPtr<GlobalConfirmInfoBar> global_info_bar) |
47 : info_bar_(nullptr), | 48 : info_bar_(nullptr), |
48 global_info_bar_(global_info_bar) { | 49 global_info_bar_(global_info_bar) { |
49 } | 50 } |
50 | 51 |
51 GlobalConfirmInfoBar::DelegateProxy::~DelegateProxy() { | 52 GlobalConfirmInfoBar::DelegateProxy::~DelegateProxy() { |
52 } | 53 } |
53 | 54 |
55 infobars::InfoBarDelegate::InfoBarIdentifier | |
56 GlobalConfirmInfoBar::DelegateProxy::GetIdentifier() const { | |
57 return global_info_bar_ ? global_info_bar_->delegate_->GetIdentifier() | |
58 : INVALID_ID; | |
Peter Kasting
2015/12/30 01:52:57
Uggghhhh. This really shouldn't be needed; I don'
gone
2015/12/30 07:29:03
Yeah, when I hit this I was a bit confused about w
| |
59 } | |
60 | |
54 base::string16 GlobalConfirmInfoBar::DelegateProxy::GetMessageText() const { | 61 base::string16 GlobalConfirmInfoBar::DelegateProxy::GetMessageText() const { |
55 return global_info_bar_ ? global_info_bar_->delegate_->GetMessageText() | 62 return global_info_bar_ ? global_info_bar_->delegate_->GetMessageText() |
56 : base::string16(); | 63 : base::string16(); |
57 } | 64 } |
58 | 65 |
59 int GlobalConfirmInfoBar::DelegateProxy::GetButtons() const { | 66 int GlobalConfirmInfoBar::DelegateProxy::GetButtons() const { |
60 return global_info_bar_ ? global_info_bar_->delegate_->GetButtons() | 67 return global_info_bar_ ? global_info_bar_->delegate_->GetButtons() |
61 : 0; | 68 : 0; |
62 } | 69 } |
63 | 70 |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
195 break; | 202 break; |
196 } | 203 } |
197 } | 204 } |
198 } | 205 } |
199 | 206 |
200 void GlobalConfirmInfoBar::OnManagerShuttingDown( | 207 void GlobalConfirmInfoBar::OnManagerShuttingDown( |
201 infobars::InfoBarManager* manager) { | 208 infobars::InfoBarManager* manager) { |
202 manager->RemoveObserver(this); | 209 manager->RemoveObserver(this); |
203 proxies_.erase(manager); | 210 proxies_.erase(manager); |
204 } | 211 } |
OLD | NEW |