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_
11 #include "base/callback.h"
12 #include "base/strings/string16.h"
13 #include "base/time/time.h"
14 #include "chrome/browser/history/history_service.h"
15 #include "content/public/browser/interstitial_page_delegate.h"
16 #include "net/ssl/ssl_info.h"
20 class DictionaryValue
;
24 class InterstitialPage
;
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 content::InterstitialPageDelegate
{
34 content::WebContents
* web_contents
,
36 const net::SSLInfo
& ssl_info
,
37 const GURL
& request_url
,
39 bool strict_enforcement
,
40 const base::Callback
<void(bool)>& callback
);
41 virtual ~SSLBlockingPage();
43 // A method that sets strings in the specified dictionary from the passed
44 // vector so that they can be used to resource the ssl_roadblock.html/
45 // ssl_error.html files.
46 // Note: there can be up to 5 strings in |extra_info|.
47 static void SetExtraInfo(base::DictionaryValue
* strings
,
48 const std::vector
<base::string16
>& extra_info
);
51 // InterstitialPageDelegate implementation.
52 virtual std::string
GetHTMLContents() OVERRIDE
;
53 virtual void CommandReceived(const std::string
& command
) OVERRIDE
;
54 virtual void OverrideEntry(content::NavigationEntry
* entry
) OVERRIDE
;
55 virtual void OverrideRendererPrefs(
56 content::RendererPreferences
* prefs
) OVERRIDE
;
57 virtual void OnProceed() OVERRIDE
;
58 virtual void OnDontProceed() OVERRIDE
;
61 void NotifyDenyCertificate();
62 void NotifyAllowCertificate();
64 // Used to query the HistoryService to see if the URL is in history. For UMA.
65 void OnGotHistoryCount(HistoryService::Handle handle
,
68 base::Time first_visit
);
70 base::Callback
<void(bool)> callback_
;
72 content::WebContents
* web_contents_
;
74 net::SSLInfo ssl_info_
;
76 // Could the user successfully override the error?
78 // Has the site requested strict enforcement of certificate errors?
79 bool strict_enforcement_
;
80 content::InterstitialPage
* interstitial_page_
; // Owns us.
81 // Is the hostname for an internal network?
83 // How many times is this same URL in history?
85 // Used for getting num_visits_.
86 CancelableRequestConsumer request_consumer_
;
88 // For the FieldTrial: this contains the name of the condition.
89 std::string trialCondition_
;
91 DISALLOW_COPY_AND_ASSIGN(SSLBlockingPage
);
94 #endif // CHROME_BROWSER_SSL_SSL_BLOCKING_PAGE_H_