ssl_blocking_page.h revision 868fa2fe829687343ffae624259930155e16dbd8
1// Copyright (c) 2012 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_SSL_SSL_BLOCKING_PAGE_H_
6#define CHROME_BROWSER_SSL_SSL_BLOCKING_PAGE_H_
7
8#include <string>
9#include <vector>
10
11#include "base/callback.h"
12#include "base/strings/string16.h"
13#include "base/time.h"
14#include "content/public/browser/interstitial_page_delegate.h"
15#include "googleurl/src/gurl.h"
16#include "net/ssl/ssl_info.h"
17
18namespace base {
19class DictionaryValue;
20}
21
22namespace content {
23class InterstitialPage;
24class WebContents;
25}
26
27// This class is responsible for showing/hiding the interstitial page that is
28// shown when a certificate error happens.
29// It deletes itself when the interstitial page is closed.
30class SSLBlockingPage : public content::InterstitialPageDelegate {
31 public:
32  SSLBlockingPage(
33      content::WebContents* web_contents,
34      int cert_error,
35      const net::SSLInfo& ssl_info,
36      const GURL& request_url,
37      bool overridable,
38      bool strict_enforcement,
39      const base::Callback<void(bool)>& callback);
40  virtual ~SSLBlockingPage();
41
42  // A method that sets strings in the specified dictionary from the passed
43  // vector so that they can be used to resource the ssl_roadblock.html/
44  // ssl_error.html files.
45  // Note: there can be up to 5 strings in |extra_info|.
46  static void SetExtraInfo(base::DictionaryValue* strings,
47                           const std::vector<string16>& extra_info);
48
49 protected:
50  // InterstitialPageDelegate implementation.
51  virtual std::string GetHTMLContents() OVERRIDE;
52  virtual void CommandReceived(const std::string& command) OVERRIDE;
53  virtual void OverrideEntry(content::NavigationEntry* entry) OVERRIDE;
54  virtual void OverrideRendererPrefs(
55      content::RendererPreferences* prefs) OVERRIDE;
56  virtual void OnProceed() OVERRIDE;
57  virtual void OnDontProceed() OVERRIDE;
58
59 private:
60  void NotifyDenyCertificate();
61  void NotifyAllowCertificate();
62
63  base::Callback<void(bool)> callback_;
64
65  content::WebContents* web_contents_;
66  int cert_error_;
67  base::TimeTicks display_start_time_;
68  net::SSLInfo ssl_info_;
69  GURL request_url_;
70  // Could the user successfully override the error?
71  bool overridable_;
72  // Has the site requested strict enforcement of certificate errors?
73  bool strict_enforcement_;
74  content::InterstitialPage* interstitial_page_;  // Owns us.
75
76  // For the FieldTrial: this contains the name of the condition.
77  std::string trialCondition_;
78
79  DISALLOW_COPY_AND_ASSIGN(SSLBlockingPage);
80};
81
82#endif  // CHROME_BROWSER_SSL_SSL_BLOCKING_PAGE_H_
83