1 // Copyright (c) 2011 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_INFOBARS_INSECURE_CONTENT_INFOBAR_DELEGATE_H_ 6 #define CHROME_BROWSER_INFOBARS_INSECURE_CONTENT_INFOBAR_DELEGATE_H_ 7 8 #include "components/infobars/core/confirm_infobar_delegate.h" 9 10 class InfoBarService; 11 12 // Base class for delegates that show warnings on HTTPS pages which try to 13 // display or run insecure content. 14 class InsecureContentInfoBarDelegate : public ConfirmInfoBarDelegate { 15 public: 16 enum InfoBarType { 17 DISPLAY, // Shown when "inactive" content (e.g. images) has been blocked. 18 RUN, // Shown when "active" content (e.g. script) has been blocked. 19 }; 20 21 // Depending on the |type| requested and whether an insecure content infobar 22 // is already present in |infobar_service|, may do nothing; otherwise, creates 23 // an insecure content infobar and delegate and either adds the infobar to 24 // |infobar_service| or replaces the existing infobar. 25 static void Create(InfoBarService* infobar_service, InfoBarType type); 26 27 private: 28 enum HistogramEvents { 29 DISPLAY_INFOBAR_SHOWN = 0, // Infobar was displayed. 30 DISPLAY_USER_OVERRIDE, // User clicked allow anyway button. 31 DISPLAY_USER_DID_NOT_LOAD, // User clicked the don't load button. 32 DISPLAY_INFOBAR_DISMISSED, // User clicked close button. 33 RUN_INFOBAR_SHOWN, 34 RUN_USER_OVERRIDE, 35 RUN_USER_DID_NOT_LOAD, 36 RUN_INFOBAR_DISMISSED, 37 NUM_EVENTS 38 }; 39 40 explicit InsecureContentInfoBarDelegate(InfoBarType type); 41 virtual ~InsecureContentInfoBarDelegate(); 42 43 // ConfirmInfoBarDelegate: 44 virtual void InfoBarDismissed() OVERRIDE; 45 virtual InsecureContentInfoBarDelegate* 46 AsInsecureContentInfoBarDelegate() OVERRIDE; 47 virtual base::string16 GetMessageText() const OVERRIDE; 48 virtual base::string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; 49 virtual bool Accept() OVERRIDE; 50 virtual bool Cancel() OVERRIDE; 51 virtual base::string16 GetLinkText() const OVERRIDE; 52 virtual bool LinkClicked(WindowOpenDisposition disposition) OVERRIDE; 53 54 InfoBarType type_; 55 56 DISALLOW_IMPLICIT_CONSTRUCTORS(InsecureContentInfoBarDelegate); 57 }; 58 59 #endif // CHROME_BROWSER_INFOBARS_INSECURE_CONTENT_INFOBAR_DELEGATE_H_ 60 61