1 // Copyright 2018 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_EXTENSIONS_API_MESSAGING_INCOGNITO_CONNECTABILITY_INFOBAR_DELEGATE_H_ 6 #define CHROME_BROWSER_EXTENSIONS_API_MESSAGING_INCOGNITO_CONNECTABILITY_INFOBAR_DELEGATE_H_ 7 8 #include "base/callback_forward.h" 9 #include "base/strings/string16.h" 10 #include "chrome/browser/extensions/api/messaging/incognito_connectability.h" 11 #include "components/infobars/core/confirm_infobar_delegate.h" 12 13 class InfoBarService; 14 15 namespace extensions { 16 17 class IncognitoConnectabilityInfoBarDelegate : public ConfirmInfoBarDelegate { 18 public: 19 typedef base::Callback<void( 20 IncognitoConnectability::ScopedAlertTracker::Mode)> 21 InfoBarCallback; 22 23 // Creates a confirmation infobar and delegate and adds the infobar to 24 // |infobar_service|. 25 static infobars::InfoBar* Create(InfoBarService* infobar_service, 26 const base::string16& message, 27 const InfoBarCallback& callback); 28 29 // Marks the infobar as answered so that the callback is not executed when the 30 // delegate is destroyed. set_answered()31 void set_answered() { answered_ = true; } 32 33 private: 34 IncognitoConnectabilityInfoBarDelegate(const base::string16& message, 35 const InfoBarCallback& callback); 36 ~IncognitoConnectabilityInfoBarDelegate() override; 37 38 // ConfirmInfoBarDelegate: 39 infobars::InfoBarDelegate::InfoBarIdentifier GetIdentifier() const override; 40 base::string16 GetMessageText() const override; 41 base::string16 GetButtonLabel(InfoBarButton button) const override; 42 bool Accept() override; 43 bool Cancel() override; 44 45 base::string16 message_; 46 bool answered_; 47 InfoBarCallback callback_; 48 }; 49 50 } // namespace extensions 51 52 #endif // CHROME_BROWSER_EXTENSIONS_API_MESSAGING_INCOGNITO_CONNECTABILITY_INFOBAR_DELEGATE_H_ 53