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 CONTENT_BROWSER_SSL_SSL_MANAGER_H_
6 #define CONTENT_BROWSER_SSL_SSL_MANAGER_H_
10 #include "base/basictypes.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/weak_ptr.h"
13 #include "content/browser/ssl/ssl_error_handler.h"
14 #include "content/browser/ssl/ssl_policy_backend.h"
15 #include "content/common/content_export.h"
16 #include "content/public/browser/global_request_id.h"
17 #include "net/base/net_errors.h"
18 #include "net/cert/cert_status_flags.h"
27 class NavigationEntryImpl
;
28 class NavigationControllerImpl
;
30 struct LoadCommittedDetails
;
31 struct LoadFromMemoryCacheDetails
;
32 struct ResourceRedirectDetails
;
33 struct ResourceRequestDetails
;
35 // The SSLManager SSLManager controls the SSL UI elements in a WebContents. It
36 // listens for various events that influence when these elements should or
37 // should not be displayed and adjusts them accordingly.
39 // There is one SSLManager per tab.
40 // The security state (secure/insecure) is stored in the navigation entry.
41 // Along with it are stored any SSL error code and the associated cert.
43 class CONTENT_EXPORT SSLManager
{
45 // Entry point for SSLCertificateErrors. This function begins the process
46 // of resolving a certificate error during an SSL connection. SSLManager
47 // will adjust the security UI and either call |CancelSSLRequest| or
48 // |ContinueSSLRequest| of |delegate|.
50 // Called on the IO thread.
51 static void OnSSLCertificateError(
52 const base::WeakPtr
<SSLErrorHandler::Delegate
>& delegate
,
53 ResourceType resource_type
,
55 int render_process_id
,
57 const net::SSLInfo
& ssl_info
,
60 // Called when SSL state for a host or tab changes.
61 static void NotifySSLInternalStateChanged(BrowserContext
* context
);
63 // Construct an SSLManager for the specified tab.
64 // If |delegate| is NULL, SSLPolicy::GetDefaultPolicy() is used.
65 explicit SSLManager(NavigationControllerImpl
* controller
);
66 virtual ~SSLManager();
68 SSLPolicy
* policy() { return policy_
.get(); }
69 SSLPolicyBackend
* backend() { return &backend_
; }
71 // The navigation controller associated with this SSLManager. The
72 // NavigationController is guaranteed to outlive the SSLManager.
73 NavigationControllerImpl
* controller() { return controller_
; }
75 void DidCommitProvisionalLoad(const LoadCommittedDetails
& details
);
76 void DidLoadFromMemoryCache(const LoadFromMemoryCacheDetails
& details
);
77 void DidStartResourceResponse(const ResourceRequestDetails
& details
);
78 void DidReceiveResourceRedirect(const ResourceRedirectDetails
& details
);
80 // Insecure content entry point.
81 void DidDisplayInsecureContent();
82 void DidRunInsecureContent(const std::string
& security_origin
);
85 // Updates the NavigationEntry with our current state. This will
86 // notify the WebContents of an SSL state change if a change was
88 void UpdateEntry(NavigationEntryImpl
* entry
);
90 // Notifies the WebContents that the SSL state changed.
91 void NotifyDidChangeVisibleSSLState();
93 // The backend for the SSLPolicy to actuate its decisions.
94 SSLPolicyBackend backend_
;
96 // The SSLPolicy instance for this manager.
97 scoped_ptr
<SSLPolicy
> policy_
;
99 // The NavigationController that owns this SSLManager. We are responsible
100 // for the security UI of this tab.
101 NavigationControllerImpl
* controller_
;
103 DISALLOW_COPY_AND_ASSIGN(SSLManager
);
106 } // namespace content
108 #endif // CONTENT_BROWSER_SSL_SSL_MANAGER_H_