Supervised user import: Listen for profile creation/deletion
[chromium-blink-merge.git] / content / browser / ssl / ssl_manager.h
blobd4fca43e6b994112abda28baccf97cdeb5450ede
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_
8 #include <string>
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"
19 #include "url/gurl.h"
21 namespace net {
22 class SSLInfo;
25 namespace content {
26 class BrowserContext;
27 class NavigationEntryImpl;
28 class NavigationControllerImpl;
29 class SSLPolicy;
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 SSLManager {
44 public:
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,
54 const GURL& url,
55 int render_process_id,
56 int render_frame_id,
57 const net::SSLInfo& ssl_info,
58 bool fatal);
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);
84 private:
85 // Update the NavigationEntry with our current state.
86 void UpdateEntry(NavigationEntryImpl* entry);
88 // The backend for the SSLPolicy to actuate its decisions.
89 SSLPolicyBackend backend_;
91 // The SSLPolicy instance for this manager.
92 scoped_ptr<SSLPolicy> policy_;
94 // The NavigationController that owns this SSLManager. We are responsible
95 // for the security UI of this tab.
96 NavigationControllerImpl* controller_;
98 DISALLOW_COPY_AND_ASSIGN(SSLManager);
101 } // namespace content
103 #endif // CONTENT_BROWSER_SSL_SSL_MANAGER_H_