| 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 "chrome/browser/ui/browser.h" | 7 #include "chrome/browser/ui/browser.h" |
| 8 #include "chrome/browser/ui/host_desktop.h" | 8 #include "chrome/browser/ui/host_desktop.h" |
| 9 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 9 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 10 #include "components/infobars/core/infobar.h" | 10 #include "components/infobars/core/infobar.h" |
| 11 #include "ui/gfx/image/image.h" | 11 #include "ui/gfx/image/image.h" |
| 12 | 12 |
| 13 // InfoBarDelegateProxy ------------------------------------------------------- | 13 // InfoBarDelegateProxy ------------------------------------------------------- |
| 14 | 14 |
| 15 class GlobalConfirmInfoBar::DelegateProxy : public ConfirmInfoBarDelegate { | 15 class GlobalConfirmInfoBar::DelegateProxy : public ConfirmInfoBarDelegate { |
| 16 public: | 16 public: |
| 17 explicit DelegateProxy(base::WeakPtr<GlobalConfirmInfoBar> global_info_bar); | 17 explicit DelegateProxy(base::WeakPtr<GlobalConfirmInfoBar> global_info_bar); |
| 18 ~DelegateProxy() override; | 18 ~DelegateProxy() override; |
| 19 void Detach(); | 19 void Detach(); |
| 20 | 20 |
| 21 private: | 21 private: |
| 22 friend class GlobalConfirmInfoBar; | 22 friend class GlobalConfirmInfoBar; |
| 23 | 23 |
| 24 // ConfirmInfoBarDelegate overrides | 24 // ConfirmInfoBarDelegate overrides |
| 25 std::string GetIdentifier() const override; |
| 25 base::string16 GetMessageText() const override; | 26 base::string16 GetMessageText() const override; |
| 26 int GetButtons() const override; | 27 int GetButtons() const override; |
| 27 base::string16 GetButtonLabel(InfoBarButton button) const override; | 28 base::string16 GetButtonLabel(InfoBarButton button) const override; |
| 28 bool Accept() override; | 29 bool Accept() override; |
| 29 bool Cancel() override; | 30 bool Cancel() override; |
| 30 base::string16 GetLinkText() const override; | 31 base::string16 GetLinkText() const override; |
| 31 GURL GetLinkURL() const override; | 32 GURL GetLinkURL() const override; |
| 32 bool LinkClicked(WindowOpenDisposition disposition) override; | 33 bool LinkClicked(WindowOpenDisposition disposition) override; |
| 33 bool EqualsDelegate(infobars::InfoBarDelegate* delegate) const override; | 34 bool EqualsDelegate(infobars::InfoBarDelegate* delegate) const override; |
| 34 void InfoBarDismissed() override; | 35 void InfoBarDismissed() override; |
| 35 | 36 |
| 36 infobars::InfoBar* info_bar_; | 37 infobars::InfoBar* info_bar_; |
| 37 base::WeakPtr<GlobalConfirmInfoBar> global_info_bar_; | 38 base::WeakPtr<GlobalConfirmInfoBar> global_info_bar_; |
| 38 | 39 |
| 39 DISALLOW_COPY_AND_ASSIGN(DelegateProxy); | 40 DISALLOW_COPY_AND_ASSIGN(DelegateProxy); |
| 40 }; | 41 }; |
| 41 | 42 |
| 42 GlobalConfirmInfoBar::DelegateProxy::DelegateProxy( | 43 GlobalConfirmInfoBar::DelegateProxy::DelegateProxy( |
| 43 base::WeakPtr<GlobalConfirmInfoBar> global_info_bar) | 44 base::WeakPtr<GlobalConfirmInfoBar> global_info_bar) |
| 44 : info_bar_(nullptr), | 45 : info_bar_(nullptr), |
| 45 global_info_bar_(global_info_bar) { | 46 global_info_bar_(global_info_bar) { |
| 46 } | 47 } |
| 47 | 48 |
| 48 GlobalConfirmInfoBar::DelegateProxy::~DelegateProxy() { | 49 GlobalConfirmInfoBar::DelegateProxy::~DelegateProxy() { |
| 49 } | 50 } |
| 50 | 51 |
| 52 std::string GlobalConfirmInfoBar::DelegateProxy::GetIdentifier() const { |
| 53 return global_info_bar_ ? global_info_bar_->delegate_->GetIdentifier() |
| 54 : "GlobalConfirmInfoBar"; |
| 55 } |
| 56 |
| 51 base::string16 GlobalConfirmInfoBar::DelegateProxy::GetMessageText() const { | 57 base::string16 GlobalConfirmInfoBar::DelegateProxy::GetMessageText() const { |
| 52 return global_info_bar_ ? global_info_bar_->delegate_->GetMessageText() | 58 return global_info_bar_ ? global_info_bar_->delegate_->GetMessageText() |
| 53 : base::string16(); | 59 : base::string16(); |
| 54 } | 60 } |
| 55 | 61 |
| 56 int GlobalConfirmInfoBar::DelegateProxy::GetButtons() const { | 62 int GlobalConfirmInfoBar::DelegateProxy::GetButtons() const { |
| 57 return global_info_bar_ ? global_info_bar_->delegate_->GetButtons() | 63 return global_info_bar_ ? global_info_bar_->delegate_->GetButtons() |
| 58 : 0; | 64 : 0; |
| 59 } | 65 } |
| 60 | 66 |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 break; | 197 break; |
| 192 } | 198 } |
| 193 } | 199 } |
| 194 } | 200 } |
| 195 | 201 |
| 196 void GlobalConfirmInfoBar::OnManagerShuttingDown( | 202 void GlobalConfirmInfoBar::OnManagerShuttingDown( |
| 197 infobars::InfoBarManager* manager) { | 203 infobars::InfoBarManager* manager) { |
| 198 manager->RemoveObserver(this); | 204 manager->RemoveObserver(this); |
| 199 proxies_.erase(manager); | 205 proxies_.erase(manager); |
| 200 } | 206 } |
| OLD | NEW |