Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / ssl / ssl_blocking_page.h
blob46dc6a8efa0cf1257403b71f513a2d48b3339ceb
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/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"
17 #include "url/gurl.h"
19 namespace base {
20 class DictionaryValue;
23 namespace content {
24 class InterstitialPage;
25 class WebContents;
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 {
32 public:
33 SSLBlockingPage(
34 content::WebContents* web_contents,
35 int cert_error,
36 const net::SSLInfo& ssl_info,
37 const GURL& request_url,
38 bool overridable,
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);
50 protected:
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;
60 private:
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,
66 bool success,
67 int num_visits,
68 base::Time first_visit);
70 base::Callback<void(bool)> callback_;
72 content::WebContents* web_contents_;
73 int cert_error_;
74 net::SSLInfo ssl_info_;
75 GURL request_url_;
76 // Could the user successfully override the error?
77 bool overridable_;
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?
82 bool internal_;
83 // How many times is this same URL in history?
84 int num_visits_;
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_