blob: c88e10c8440845517d63034d5ffd7b99b4b13634 [file] [log] [blame]
[email protected]b172aee2012-04-10 17:05:261// Copyright (c) 2012 The Chromium Authors. All rights reserved.
license.botbf09a502008-08-24 00:55:552// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
initial.commit09911bf2008-07-26 23:55:294
[email protected]74b962a2011-06-03 21:22:545#ifndef CONTENT_BROWSER_SSL_SSL_POLICY_H_
6#define CONTENT_BROWSER_SSL_SSL_POLICY_H_
initial.commit09911bf2008-07-26 23:55:297
[email protected]5d063842009-05-15 04:08:248#include <string>
9
[email protected]4cf611e32012-02-13 16:06:1710#include "base/memory/ref_counted.h"
[email protected]d0fcff72013-07-23 02:45:4311#include "webkit/common/resource_type.h"
[email protected]5d063842009-05-15 04:08:2412
[email protected]89f23a32012-10-24 22:31:2413namespace content {
14class NavigationEntryImpl;
[email protected]5d063842009-05-15 04:08:2415class SSLCertErrorHandler;
[email protected]5d063842009-05-15 04:08:2416class SSLPolicyBackend;
17class SSLRequestInfo;
[email protected]8ff00d72012-10-23 19:12:2118class WebContentsImpl;
[email protected]10f417c52011-12-28 21:04:2319
[email protected]425210cc2009-03-17 18:56:4220// SSLPolicy
21//
22// This class is responsible for making the security decisions that concern the
[email protected]5edce1e2009-05-14 08:47:3023// SSL trust indicators. It relies on the SSLPolicyBackend to actually enact
24// the decisions it reaches.
[email protected]425210cc2009-03-17 18:56:4225//
[email protected]848dd042011-06-04 18:24:0326class SSLPolicy {
initial.commit09911bf2008-07-26 23:55:2927 public:
[email protected]5d063842009-05-15 04:08:2428 explicit SSLPolicy(SSLPolicyBackend* backend);
initial.commit09911bf2008-07-26 23:55:2929
[email protected]5d063842009-05-15 04:08:2430 // An error occurred with the certificate in an SSL connection.
31 void OnCertError(SSLCertErrorHandler* handler);
32
[email protected]89f23a32012-10-24 22:31:2433 void DidRunInsecureContent(NavigationEntryImpl* entry,
[email protected]4b8d74932009-09-29 07:26:2534 const std::string& security_origin);
[email protected]09843b5f2009-09-26 08:30:5935
[email protected]5d063842009-05-15 04:08:2436 // We have started a resource request with the given info.
37 void OnRequestStarted(SSLRequestInfo* info);
38
39 // Update the SSL information in |entry| to match the current state.
[email protected]770005b2012-04-16 15:58:1340 // |web_contents| is the WebContentsImpl associated with this entry.
[email protected]89f23a32012-10-24 22:31:2441 void UpdateEntry(NavigationEntryImpl* entry,
42 WebContentsImpl* web_contents);
initial.commit09911bf2008-07-26 23:55:2943
[email protected]5d063842009-05-15 04:08:2444 SSLPolicyBackend* backend() const { return backend_; }
45
[email protected]92812682009-03-18 01:07:0746 private:
[email protected]848dd042011-06-04 18:24:0347 // Callback that the user chose to accept or deny the certificate.
[email protected]4cf611e32012-02-13 16:06:1748 void OnAllowCertificate(scoped_refptr<SSLCertErrorHandler> handler,
49 bool allow);
[email protected]848dd042011-06-04 18:24:0350
[email protected]faf9cd62010-04-20 19:17:5851 // Helper method for derived classes handling certificate errors.
[email protected]d9be47702012-05-16 03:41:2252 //
53 // |overridable| indicates whether or not the user could (assuming perfect
54 // knowledge) successfully override the error and still get the security
55 // guarantees of TLS. |strict_enforcement| indicates whether or not the
56 // site the user is trying to connect to has requested strict enforcement
57 // of certificate validation (e.g. with HTTP Strict-Transport-Security).
58 void OnCertErrorInternal(SSLCertErrorHandler* handler,
59 bool overridable,
60 bool strict_enforcement);
[email protected]5d063842009-05-15 04:08:2461
[email protected]5d063842009-05-15 04:08:2462 // If the security style of |entry| has not been initialized, then initialize
63 // it with the default style for its URL.
[email protected]89f23a32012-10-24 22:31:2464 void InitializeEntryIfNeeded(NavigationEntryImpl* entry);
[email protected]5d063842009-05-15 04:08:2465
[email protected]f17a0ee2010-05-17 17:38:4766 // Mark |origin| as having run insecure content in the process with ID |pid|.
67 void OriginRanInsecureContent(const std::string& origin, int pid);
[email protected]5d063842009-05-15 04:08:2468
69 // The backend we use to enact our decisions.
70 SSLPolicyBackend* backend_;
71
[email protected]425210cc2009-03-17 18:56:4272 DISALLOW_COPY_AND_ASSIGN(SSLPolicy);
initial.commit09911bf2008-07-26 23:55:2973};
74
[email protected]89f23a32012-10-24 22:31:2475} // namespace content
76
[email protected]74b962a2011-06-03 21:22:5477#endif // CONTENT_BROWSER_SSL_SSL_POLICY_H_