| 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 #import "chrome/browser/ui/cocoa/ssl_client_certificate_selector_cocoa.h" | 5 #import "chrome/browser/ui/cocoa/ssl_client_certificate_selector_cocoa.h" |
| 6 | 6 |
| 7 #import <SecurityInterface/SFChooseIdentityPanel.h> | 7 #import <SecurityInterface/SFChooseIdentityPanel.h> |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 @interface SSLClientCertificateSelectorCocoa () | 42 @interface SSLClientCertificateSelectorCocoa () |
| 43 - (void)onConstrainedWindowClosed; | 43 - (void)onConstrainedWindowClosed; |
| 44 @end | 44 @end |
| 45 | 45 |
| 46 class SSLClientAuthObserverCocoaBridge : public SSLClientAuthObserver, | 46 class SSLClientAuthObserverCocoaBridge : public SSLClientAuthObserver, |
| 47 public ConstrainedWindowMacDelegate { | 47 public ConstrainedWindowMacDelegate { |
| 48 public: | 48 public: |
| 49 SSLClientAuthObserverCocoaBridge( | 49 SSLClientAuthObserverCocoaBridge( |
| 50 const content::BrowserContext* browser_context, | 50 const content::BrowserContext* browser_context, |
| 51 net::SSLCertRequestInfo* cert_request_info, | 51 net::SSLCertRequestInfo* cert_request_info, |
| 52 scoped_ptr<content::ClientCertificateDelegate> delegate, | 52 std::unique_ptr<content::ClientCertificateDelegate> delegate, |
| 53 SSLClientCertificateSelectorCocoa* controller) | 53 SSLClientCertificateSelectorCocoa* controller) |
| 54 : SSLClientAuthObserver(browser_context, | 54 : SSLClientAuthObserver(browser_context, |
| 55 cert_request_info, | 55 cert_request_info, |
| 56 std::move(delegate)), | 56 std::move(delegate)), |
| 57 controller_(controller) {} | 57 controller_(controller) {} |
| 58 | 58 |
| 59 // SSLClientAuthObserver implementation: | 59 // SSLClientAuthObserver implementation: |
| 60 void OnCertSelectedByNotification() override { | 60 void OnCertSelectedByNotification() override { |
| 61 [controller_ closeWebContentsModalDialog]; | 61 [controller_ closeWebContentsModalDialog]; |
| 62 } | 62 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 73 | 73 |
| 74 private: | 74 private: |
| 75 SSLClientCertificateSelectorCocoa* controller_; // weak | 75 SSLClientCertificateSelectorCocoa* controller_; // weak |
| 76 }; | 76 }; |
| 77 | 77 |
| 78 namespace chrome { | 78 namespace chrome { |
| 79 | 79 |
| 80 void ShowSSLClientCertificateSelector( | 80 void ShowSSLClientCertificateSelector( |
| 81 content::WebContents* contents, | 81 content::WebContents* contents, |
| 82 net::SSLCertRequestInfo* cert_request_info, | 82 net::SSLCertRequestInfo* cert_request_info, |
| 83 scoped_ptr<content::ClientCertificateDelegate> delegate) { | 83 std::unique_ptr<content::ClientCertificateDelegate> delegate) { |
| 84 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 84 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 85 | 85 |
| 86 // Not all WebContentses can show modal dialogs. | 86 // Not all WebContentses can show modal dialogs. |
| 87 // | 87 // |
| 88 // Use the top-level embedder if |contents| is a guest. | 88 // Use the top-level embedder if |contents| is a guest. |
| 89 // GetTopLevelWebContents() will return |contents| otherwise. | 89 // GetTopLevelWebContents() will return |contents| otherwise. |
| 90 // TODO(davidben): Move this hook to the WebContentsDelegate and only try to | 90 // TODO(davidben): Move this hook to the WebContentsDelegate and only try to |
| 91 // show a dialog in Browser's implementation. https://crbug.com/456255 | 91 // show a dialog in Browser's implementation. https://crbug.com/456255 |
| 92 if (web_modal::WebContentsModalDialogManager::FromWebContents( | 92 if (web_modal::WebContentsModalDialogManager::FromWebContents( |
| 93 guest_view::GuestViewBase::GetTopLevelWebContents(contents)) == | 93 guest_view::GuestViewBase::GetTopLevelWebContents(contents)) == |
| 94 nullptr) | 94 nullptr) |
| 95 return; | 95 return; |
| 96 | 96 |
| 97 // The dialog manages its own lifetime. | 97 // The dialog manages its own lifetime. |
| 98 SSLClientCertificateSelectorCocoa* selector = | 98 SSLClientCertificateSelectorCocoa* selector = |
| 99 [[SSLClientCertificateSelectorCocoa alloc] | 99 [[SSLClientCertificateSelectorCocoa alloc] |
| 100 initWithBrowserContext:contents->GetBrowserContext() | 100 initWithBrowserContext:contents->GetBrowserContext() |
| 101 certRequestInfo:cert_request_info | 101 certRequestInfo:cert_request_info |
| 102 delegate:std::move(delegate)]; | 102 delegate:std::move(delegate)]; |
| 103 [selector displayForWebContents:contents]; | 103 [selector displayForWebContents:contents]; |
| 104 } | 104 } |
| 105 | 105 |
| 106 } // namespace chrome | 106 } // namespace chrome |
| 107 | 107 |
| 108 @implementation SSLClientCertificateSelectorCocoa | 108 @implementation SSLClientCertificateSelectorCocoa |
| 109 | 109 |
| 110 - (id)initWithBrowserContext:(const content::BrowserContext*)browserContext | 110 - (id)initWithBrowserContext:(const content::BrowserContext*)browserContext |
| 111 certRequestInfo:(net::SSLCertRequestInfo*)certRequestInfo | 111 certRequestInfo:(net::SSLCertRequestInfo*)certRequestInfo |
| 112 delegate:(scoped_ptr<content::ClientCertificateDelegate>) | 112 delegate: |
| 113 delegate { | 113 (std::unique_ptr<content::ClientCertificateDelegate>) |
| 114 delegate { |
| 114 DCHECK(browserContext); | 115 DCHECK(browserContext); |
| 115 DCHECK(certRequestInfo); | 116 DCHECK(certRequestInfo); |
| 116 if ((self = [super init])) { | 117 if ((self = [super init])) { |
| 117 observer_.reset(new SSLClientAuthObserverCocoaBridge( | 118 observer_.reset(new SSLClientAuthObserverCocoaBridge( |
| 118 browserContext, certRequestInfo, std::move(delegate), self)); | 119 browserContext, certRequestInfo, std::move(delegate), self)); |
| 119 } | 120 } |
| 120 return self; | 121 return self; |
| 121 } | 122 } |
| 122 | 123 |
| 123 - (void)sheetDidEnd:(NSWindow*)parent | 124 - (void)sheetDidEnd:(NSWindow*)parent |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 } | 270 } |
| 270 | 271 |
| 271 - (void)onConstrainedWindowClosed { | 272 - (void)onConstrainedWindowClosed { |
| 272 observer_->StopObserving(); | 273 observer_->StopObserving(); |
| 273 panel_.reset(); | 274 panel_.reset(); |
| 274 constrainedWindow_.reset(); | 275 constrainedWindow_.reset(); |
| 275 [self release]; | 276 [self release]; |
| 276 } | 277 } |
| 277 | 278 |
| 278 @end | 279 @end |
| OLD | NEW |