OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CONTENT_BROWSER_SSL_SSL_MANAGER_H_ | 5 #ifndef CONTENT_BROWSER_SSL_SSL_MANAGER_H_ |
6 #define CONTENT_BROWSER_SSL_SSL_MANAGER_H_ | 6 #define CONTENT_BROWSER_SSL_SSL_MANAGER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
13 #include "content/browser/ssl/ssl_policy_backend.h" | 13 #include "content/browser/ssl/ssl_policy_backend.h" |
14 #include "content/browser/ssl/ssl_error_handler.h" | 14 #include "content/browser/ssl/ssl_error_handler.h" |
15 #include "content/common/content_export.h" | 15 #include "content/common/content_export.h" |
16 #include "content/public/browser/global_request_id.h" | 16 #include "content/public/browser/global_request_id.h" |
17 #include "content/public/browser/notification_observer.h" | 17 #include "content/public/browser/notification_observer.h" |
18 #include "content/public/browser/notification_registrar.h" | 18 #include "content/public/browser/notification_registrar.h" |
19 #include "googleurl/src/gurl.h" | 19 #include "googleurl/src/gurl.h" |
20 #include "net/base/cert_status_flags.h" | 20 #include "net/base/cert_status_flags.h" |
21 #include "net/base/net_errors.h" | 21 #include "net/base/net_errors.h" |
22 | 22 |
23 namespace net { | 23 namespace net { |
24 class SSLInfo; | 24 class SSLInfo; |
25 } | 25 } |
26 | 26 |
27 namespace content { | 27 namespace content { |
| 28 class BrowserContext; |
28 class NavigationEntryImpl; | 29 class NavigationEntryImpl; |
29 class NavigationControllerImpl; | 30 class NavigationControllerImpl; |
30 class SSLPolicy; | 31 class SSLPolicy; |
31 struct LoadFromMemoryCacheDetails; | 32 struct LoadFromMemoryCacheDetails; |
32 struct ResourceRedirectDetails; | 33 struct ResourceRedirectDetails; |
33 struct ResourceRequestDetails; | 34 struct ResourceRequestDetails; |
34 | 35 |
35 // The SSLManager SSLManager controls the SSL UI elements in a WebContents. It | 36 // 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 // listens for various events that influence when these elements should or |
37 // should not be displayed and adjusts them accordingly. | 38 // should not be displayed and adjusts them accordingly. |
(...skipping 13 matching lines...) Expand all Loading... |
51 static void OnSSLCertificateError( | 52 static void OnSSLCertificateError( |
52 const base::WeakPtr<SSLErrorHandler::Delegate>& delegate, | 53 const base::WeakPtr<SSLErrorHandler::Delegate>& delegate, |
53 const GlobalRequestID& id, | 54 const GlobalRequestID& id, |
54 ResourceType::Type resource_type, | 55 ResourceType::Type resource_type, |
55 const GURL& url, | 56 const GURL& url, |
56 int render_process_id, | 57 int render_process_id, |
57 int render_view_id, | 58 int render_view_id, |
58 const net::SSLInfo& ssl_info, | 59 const net::SSLInfo& ssl_info, |
59 bool fatal); | 60 bool fatal); |
60 | 61 |
61 // Called when SSL state for a host or tab changes. Broadcasts the | 62 // Called when SSL state for a host or tab changes. |
62 // SSL_INTERNAL_STATE_CHANGED notification. | 63 static void NotifySSLInternalStateChanged(BrowserContext* context); |
63 static void NotifySSLInternalStateChanged( | |
64 NavigationControllerImpl* controller); | |
65 | 64 |
66 // Construct an SSLManager for the specified tab. | 65 // Construct an SSLManager for the specified tab. |
67 // If |delegate| is NULL, SSLPolicy::GetDefaultPolicy() is used. | 66 // If |delegate| is NULL, SSLPolicy::GetDefaultPolicy() is used. |
68 explicit SSLManager(NavigationControllerImpl* controller); | 67 explicit SSLManager(NavigationControllerImpl* controller); |
69 virtual ~SSLManager(); | 68 virtual ~SSLManager(); |
70 | 69 |
71 SSLPolicy* policy() { return policy_.get(); } | 70 SSLPolicy* policy() { return policy_.get(); } |
72 SSLPolicyBackend* backend() { return &backend_; } | 71 SSLPolicyBackend* backend() { return &backend_; } |
73 | 72 |
74 // The navigation controller associated with this SSLManager. The | 73 // The navigation controller associated with this SSLManager. The |
75 // NavigationController is guaranteed to outlive the SSLManager. | 74 // NavigationController is guaranteed to outlive the SSLManager. |
76 NavigationControllerImpl* controller() { return controller_; } | 75 NavigationControllerImpl* controller() { return controller_; } |
77 | 76 |
78 // This entry point is called directly (instead of via the notification | 77 // This entry point is called directly (instead of via the notification |
79 // service) because we need more precise control of the order in which folks | 78 // service) because we need more precise control of the order in which folks |
80 // are notified of this event. | 79 // are notified of this event. |
81 void DidCommitProvisionalLoad(const NotificationDetails& details); | 80 void DidCommitProvisionalLoad(const NotificationDetails& details); |
82 | 81 |
83 // Insecure content entry point. | 82 // Insecure content entry point. |
| 83 void DidDisplayInsecureContent(); |
84 void DidRunInsecureContent(const std::string& security_origin); | 84 void DidRunInsecureContent(const std::string& security_origin); |
85 | 85 |
86 // Entry point for navigation. This function begins the process of updating | 86 // Entry point for navigation. This function begins the process of updating |
87 // the security UI when the main frame navigates to a new URL. | 87 // the security UI when the main frame navigates to a new URL. |
88 // | 88 // |
89 // Called on the UI thread. | 89 // Called on the UI thread. |
90 virtual void Observe(int type, | 90 virtual void Observe(int type, |
91 const NotificationSource& source, | 91 const NotificationSource& source, |
92 const NotificationDetails& details) OVERRIDE; | 92 const NotificationDetails& details) OVERRIDE; |
93 | 93 |
94 private: | 94 private: |
95 // Entry points for notifications to which we subscribe. Note that | 95 // Entry points for notifications to which we subscribe. Note that |
96 // DidCommitProvisionalLoad uses the abstract NotificationDetails type since | 96 // DidCommitProvisionalLoad uses the abstract NotificationDetails type since |
97 // the type we need is in NavigationController which would create a circular | 97 // the type we need is in NavigationController which would create a circular |
98 // header file dependency. | 98 // header file dependency. |
99 void DidLoadFromMemoryCache(LoadFromMemoryCacheDetails* details); | 99 void DidLoadFromMemoryCache(LoadFromMemoryCacheDetails* details); |
100 void DidStartResourceResponse(ResourceRequestDetails* details); | 100 void DidStartResourceResponse(ResourceRequestDetails* details); |
101 void DidReceiveResourceRedirect(ResourceRedirectDetails* details); | 101 void DidReceiveResourceRedirect(ResourceRedirectDetails* details); |
102 void DidChangeSSLInternalState(); | |
103 | 102 |
104 // Update the NavigationEntry with our current state. | 103 // Update the NavigationEntry with our current state. |
105 void UpdateEntry(NavigationEntryImpl* entry); | 104 void UpdateEntry(NavigationEntryImpl* entry); |
106 | 105 |
107 // The backend for the SSLPolicy to actuate its decisions. | 106 // The backend for the SSLPolicy to actuate its decisions. |
108 SSLPolicyBackend backend_; | 107 SSLPolicyBackend backend_; |
109 | 108 |
110 // The SSLPolicy instance for this manager. | 109 // The SSLPolicy instance for this manager. |
111 scoped_ptr<SSLPolicy> policy_; | 110 scoped_ptr<SSLPolicy> policy_; |
112 | 111 |
113 // The NavigationController that owns this SSLManager. We are responsible | 112 // The NavigationController that owns this SSLManager. We are responsible |
114 // for the security UI of this tab. | 113 // for the security UI of this tab. |
115 NavigationControllerImpl* controller_; | 114 NavigationControllerImpl* controller_; |
116 | 115 |
117 // Handles registering notifications with the NotificationService. | 116 // Handles registering notifications with the NotificationService. |
118 NotificationRegistrar registrar_; | 117 NotificationRegistrar registrar_; |
119 | 118 |
120 DISALLOW_COPY_AND_ASSIGN(SSLManager); | 119 DISALLOW_COPY_AND_ASSIGN(SSLManager); |
121 }; | 120 }; |
122 | 121 |
123 } // namespace content | 122 } // namespace content |
124 | 123 |
125 #endif // CONTENT_BROWSER_SSL_SSL_MANAGER_H_ | 124 #endif // CONTENT_BROWSER_SSL_SSL_MANAGER_H_ |
OLD | NEW |