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> |
| 11 |
10 #include "base/logging.h" | 12 #include "base/logging.h" |
11 #include "base/mac/foundation_util.h" | 13 #include "base/mac/foundation_util.h" |
12 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
13 #include "base/strings/sys_string_conversions.h" | 15 #include "base/strings/sys_string_conversions.h" |
14 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
15 #include "chrome/browser/ssl/ssl_client_auth_observer.h" | 17 #include "chrome/browser/ssl/ssl_client_auth_observer.h" |
16 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_mac.h" | 18 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_mac.h" |
17 #include "chrome/grit/generated_resources.h" | 19 #include "chrome/grit/generated_resources.h" |
18 #include "components/guest_view/browser/guest_view_base.h" | 20 #include "components/guest_view/browser/guest_view_base.h" |
19 #include "components/web_modal/web_contents_modal_dialog_manager.h" | 21 #include "components/web_modal/web_contents_modal_dialog_manager.h" |
(...skipping 24 matching lines...) Expand all Loading... |
44 class SSLClientAuthObserverCocoaBridge : public SSLClientAuthObserver, | 46 class SSLClientAuthObserverCocoaBridge : public SSLClientAuthObserver, |
45 public ConstrainedWindowMacDelegate { | 47 public ConstrainedWindowMacDelegate { |
46 public: | 48 public: |
47 SSLClientAuthObserverCocoaBridge( | 49 SSLClientAuthObserverCocoaBridge( |
48 const content::BrowserContext* browser_context, | 50 const content::BrowserContext* browser_context, |
49 net::SSLCertRequestInfo* cert_request_info, | 51 net::SSLCertRequestInfo* cert_request_info, |
50 scoped_ptr<content::ClientCertificateDelegate> delegate, | 52 scoped_ptr<content::ClientCertificateDelegate> delegate, |
51 SSLClientCertificateSelectorCocoa* controller) | 53 SSLClientCertificateSelectorCocoa* controller) |
52 : SSLClientAuthObserver(browser_context, | 54 : SSLClientAuthObserver(browser_context, |
53 cert_request_info, | 55 cert_request_info, |
54 delegate.Pass()), | 56 std::move(delegate)), |
55 controller_(controller) {} | 57 controller_(controller) {} |
56 | 58 |
57 // SSLClientAuthObserver implementation: | 59 // SSLClientAuthObserver implementation: |
58 void OnCertSelectedByNotification() override { | 60 void OnCertSelectedByNotification() override { |
59 [controller_ closeWebContentsModalDialog]; | 61 [controller_ closeWebContentsModalDialog]; |
60 } | 62 } |
61 | 63 |
62 // ConstrainedWindowMacDelegate implementation: | 64 // ConstrainedWindowMacDelegate implementation: |
63 void OnConstrainedWindowClosed(ConstrainedWindowMac* window) override { | 65 void OnConstrainedWindowClosed(ConstrainedWindowMac* window) override { |
64 // |onConstrainedWindowClosed| will delete the sheet which might be still | 66 // |onConstrainedWindowClosed| will delete the sheet which might be still |
(...skipping 25 matching lines...) Expand all Loading... |
90 if (web_modal::WebContentsModalDialogManager::FromWebContents( | 92 if (web_modal::WebContentsModalDialogManager::FromWebContents( |
91 guest_view::GuestViewBase::GetTopLevelWebContents(contents)) == | 93 guest_view::GuestViewBase::GetTopLevelWebContents(contents)) == |
92 nullptr) | 94 nullptr) |
93 return; | 95 return; |
94 | 96 |
95 // The dialog manages its own lifetime. | 97 // The dialog manages its own lifetime. |
96 SSLClientCertificateSelectorCocoa* selector = | 98 SSLClientCertificateSelectorCocoa* selector = |
97 [[SSLClientCertificateSelectorCocoa alloc] | 99 [[SSLClientCertificateSelectorCocoa alloc] |
98 initWithBrowserContext:contents->GetBrowserContext() | 100 initWithBrowserContext:contents->GetBrowserContext() |
99 certRequestInfo:cert_request_info | 101 certRequestInfo:cert_request_info |
100 delegate:delegate.Pass()]; | 102 delegate:std::move(delegate)]; |
101 [selector displayForWebContents:contents]; | 103 [selector displayForWebContents:contents]; |
102 } | 104 } |
103 | 105 |
104 } // namespace chrome | 106 } // namespace chrome |
105 | 107 |
106 @implementation SSLClientCertificateSelectorCocoa | 108 @implementation SSLClientCertificateSelectorCocoa |
107 | 109 |
108 - (id)initWithBrowserContext:(const content::BrowserContext*)browserContext | 110 - (id)initWithBrowserContext:(const content::BrowserContext*)browserContext |
109 certRequestInfo:(net::SSLCertRequestInfo*)certRequestInfo | 111 certRequestInfo:(net::SSLCertRequestInfo*)certRequestInfo |
110 delegate:(scoped_ptr<content::ClientCertificateDelegate>) | 112 delegate:(scoped_ptr<content::ClientCertificateDelegate>) |
111 delegate { | 113 delegate { |
112 DCHECK(browserContext); | 114 DCHECK(browserContext); |
113 DCHECK(certRequestInfo); | 115 DCHECK(certRequestInfo); |
114 if ((self = [super init])) { | 116 if ((self = [super init])) { |
115 observer_.reset(new SSLClientAuthObserverCocoaBridge( | 117 observer_.reset(new SSLClientAuthObserverCocoaBridge( |
116 browserContext, certRequestInfo, delegate.Pass(), self)); | 118 browserContext, certRequestInfo, std::move(delegate), self)); |
117 } | 119 } |
118 return self; | 120 return self; |
119 } | 121 } |
120 | 122 |
121 - (void)sheetDidEnd:(NSWindow*)parent | 123 - (void)sheetDidEnd:(NSWindow*)parent |
122 returnCode:(NSInteger)returnCode | 124 returnCode:(NSInteger)returnCode |
123 context:(void*)context { | 125 context:(void*)context { |
124 net::X509Certificate* cert = NULL; | 126 net::X509Certificate* cert = NULL; |
125 if (returnCode == NSFileHandlingPanelOKButton) { | 127 if (returnCode == NSFileHandlingPanelOKButton) { |
126 CFRange range = CFRangeMake(0, CFArrayGetCount(identities_)); | 128 CFRange range = CFRangeMake(0, CFArrayGetCount(identities_)); |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 } | 265 } |
264 | 266 |
265 - (void)onConstrainedWindowClosed { | 267 - (void)onConstrainedWindowClosed { |
266 observer_->StopObserving(); | 268 observer_->StopObserving(); |
267 panel_.reset(); | 269 panel_.reset(); |
268 constrainedWindow_.reset(); | 270 constrainedWindow_.reset(); |
269 [self release]; | 271 [self release]; |
270 } | 272 } |
271 | 273 |
272 @end | 274 @end |
OLD | NEW |