ozone: evdev: Sync caps lock LED state to evdev
[chromium-blink-merge.git] / chrome / browser / ssl / ssl_blocking_page.h
blob6d427c1bd84b36229787569b2b9891facf31bf8d
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.
5 #ifndef CHROME_BROWSER_SSL_SSL_BLOCKING_PAGE_H_
6 #define CHROME_BROWSER_SSL_SSL_BLOCKING_PAGE_H_
8 #include <string>
9 #include <vector>
11 #include "base/callback.h"
12 #include "base/strings/string16.h"
13 #include "base/task/cancelable_task_tracker.h"
14 #include "base/time/time.h"
15 #include "chrome/browser/interstitials/security_interstitial_metrics_helper.h"
16 #include "chrome/browser/interstitials/security_interstitial_page.h"
17 #include "net/ssl/ssl_info.h"
18 #include "url/gurl.h"
20 #if defined(ENABLE_EXTENSIONS)
21 namespace extensions {
22 class ExperienceSamplingEvent;
24 #endif
26 class SSLErrorClassification;
28 // This class is responsible for showing/hiding the interstitial page that is
29 // shown when a certificate error happens.
30 // It deletes itself when the interstitial page is closed.
31 class SSLBlockingPage : public SecurityInterstitialPage {
32 public:
33 // These represent the commands sent from the interstitial JavaScript. They
34 // are defined in chrome/browser/resources/ssl/ssl_errors_common.js.
35 // DO NOT reorder or change these without also changing the JavaScript!
36 enum SSLBlockingPageCommands {
37 CMD_DONT_PROCEED = 0,
38 CMD_PROCEED = 1,
39 CMD_MORE = 2,
40 CMD_RELOAD = 3,
41 CMD_HELP = 4,
42 CMD_CLOCK = 5
45 enum SSLBlockingPageOptionsMask {
46 // Indicates whether or not the user could (assuming perfect knowledge)
47 // successfully override the error and still get the security guarantees
48 // of TLS.
49 OVERRIDABLE = 1 << 0,
50 // Indicates whether or not the site the user is trying to connect to has
51 // requested strict enforcement of certificate validation (e.g. with HTTP
52 // Strict-Transport-Security).
53 STRICT_ENFORCEMENT = 1 << 1,
54 // Indicates whether a user decision had been previously made but the
55 // decision has expired.
56 EXPIRED_BUT_PREVIOUSLY_ALLOWED = 1 << 2
59 // Interstitial type, used in tests.
60 static const void* kTypeForTesting;
62 ~SSLBlockingPage() override;
64 // Creates an SSL blocking page. If the blocking page isn't shown, the caller
65 // is responsible for cleaning up the blocking page, otherwise the
66 // interstitial takes ownership when shown. |options_mask| must be a bitwise
67 // mask of SSLBlockingPageOptionsMask values.
68 SSLBlockingPage(content::WebContents* web_contents,
69 int cert_error,
70 const net::SSLInfo& ssl_info,
71 const GURL& request_url,
72 int options_mask,
73 const base::Time& time_triggered,
74 const base::Callback<void(bool)>& callback);
76 // SecurityInterstitialPage method:
77 const void* GetTypeForTesting() const override;
79 // Returns true if |options_mask| refers to an overridable SSL error.
80 static bool IsOptionsOverridable(int options_mask);
82 protected:
83 // InterstitialPageDelegate implementation.
84 void CommandReceived(const std::string& command) override;
85 void OverrideEntry(content::NavigationEntry* entry) override;
86 void OverrideRendererPrefs(content::RendererPreferences* prefs) override;
87 void OnProceed() override;
88 void OnDontProceed() override;
90 // SecurityInterstitialPage implementation:
91 bool ShouldCreateNewNavigation() const override;
92 void PopulateInterstitialStrings(
93 base::DictionaryValue* load_time_data) override;
95 private:
96 void NotifyDenyCertificate();
97 void NotifyAllowCertificate();
99 std::string GetUmaHistogramPrefix() const;
100 std::string GetSamplingEventName() const;
102 base::Callback<void(bool)> callback_;
104 const int cert_error_;
105 const net::SSLInfo ssl_info_;
106 // There are two ways for the user to override an interstitial:
108 // overridable_) By clicking on "Advanced" and then "Proceed".
109 // - This corresponds to "the user can override using the UI".
110 // danger_overridable_) By typing the word "danger".
111 // - This is an undocumented workaround.
112 // - This can be set to "false" dynamically to prevent the behaviour.
113 const bool overridable_;
114 bool danger_overridable_;
115 // Has the site requested strict enforcement of certificate errors?
116 const bool strict_enforcement_;
117 // Did the user previously allow a bad certificate but the decision has now
118 // expired?
119 const bool expired_but_previously_allowed_;
120 scoped_ptr<SSLErrorClassification> ssl_error_classification_;
121 scoped_ptr<SecurityInterstitialMetricsHelper> metrics_helper_;
122 // The time at which the interstitial was triggered. The interstitial
123 // calculates all times relative to this.
124 const base::Time time_triggered_;
126 // Which type of interstitial this is.
127 enum SSLInterstitialReason {
128 SSL_REASON_SSL,
129 SSL_REASON_BAD_CLOCK
130 } interstitial_reason_;
132 DISALLOW_COPY_AND_ASSIGN(SSLBlockingPage);
135 #endif // CHROME_BROWSER_SSL_SSL_BLOCKING_PAGE_H_