eb59556f707300e987670918eb548cf9578bf455
[platform/framework/web/crosswalk.git] / src / chrome / browser / infobars / insecure_content_infobar_delegate.h
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   ~InsecureContentInfoBarDelegate() override;
42
43   // ConfirmInfoBarDelegate:
44   void InfoBarDismissed() override;
45   InsecureContentInfoBarDelegate* AsInsecureContentInfoBarDelegate() override;
46   base::string16 GetMessageText() const override;
47   base::string16 GetButtonLabel(InfoBarButton button) const override;
48   bool Accept() override;
49   bool Cancel() override;
50   base::string16 GetLinkText() const override;
51   bool LinkClicked(WindowOpenDisposition disposition) override;
52
53   InfoBarType type_;
54
55   DISALLOW_IMPLICIT_CONSTRUCTORS(InsecureContentInfoBarDelegate);
56 };
57
58 #endif  // CHROME_BROWSER_INFOBARS_INSECURE_CONTENT_INFOBAR_DELEGATE_H_
59