| OLD | NEW |
| 1 // Copyright (c) 2011 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 #include "ssl_add_cert_handler.h" | 5 #include "ssl_add_cert_handler.h" |
| 6 | 6 |
| 7 #include <SecurityInterface/SFCertificatePanel.h> | 7 #include <SecurityInterface/SFCertificatePanel.h> |
| 8 #include <SecurityInterface/SFCertificateView.h> | 8 #include <SecurityInterface/SFCertificateView.h> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/memory/scoped_nsobject.h" | 11 #include "base/memory/scoped_nsobject.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 [panel autorelease]; | 52 [panel autorelease]; |
| 53 handler_->Finished(returnCode == NSOKButton); | 53 handler_->Finished(returnCode == NSOKButton); |
| 54 [self release]; | 54 [self release]; |
| 55 } | 55 } |
| 56 | 56 |
| 57 - (void)askToAddCert { | 57 - (void)askToAddCert { |
| 58 NSWindow* parentWindow = NULL; | 58 NSWindow* parentWindow = NULL; |
| 59 Browser* browser = browser::GetLastActiveBrowser(); | 59 Browser* browser = browser::GetLastActiveBrowser(); |
| 60 // TODO(snej): Can I get the Browser that issued the request? | 60 // TODO(snej): Can I get the Browser that issued the request? |
| 61 if (browser) { | 61 if (browser) { |
| 62 parentWindow = browser->window()->GetNativeHandle(); | 62 parentWindow = browser->window()->GetNativeWindow(); |
| 63 if ([parentWindow attachedSheet]) | 63 if ([parentWindow attachedSheet]) |
| 64 parentWindow = nil; | 64 parentWindow = nil; |
| 65 } | 65 } |
| 66 | 66 |
| 67 // Create the cert panel, which will be released in my -sheetDidEnd: method. | 67 // Create the cert panel, which will be released in my -sheetDidEnd: method. |
| 68 SFCertificatePanel* panel = [[SFCertificatePanel alloc] init]; | 68 SFCertificatePanel* panel = [[SFCertificatePanel alloc] init]; |
| 69 [panel setDefaultButtonTitle:l10n_util::GetNSString(IDS_ADD_CERT_DIALOG_ADD)]; | 69 [panel setDefaultButtonTitle:l10n_util::GetNSString(IDS_ADD_CERT_DIALOG_ADD)]; |
| 70 [panel setAlternateButtonTitle:l10n_util::GetNSString(IDS_CANCEL)]; | 70 [panel setAlternateButtonTitle:l10n_util::GetNSString(IDS_CANCEL)]; |
| 71 SecCertificateRef cert = handler_->cert()->os_cert_handle(); | 71 SecCertificateRef cert = handler_->cert()->os_cert_handle(); |
| 72 NSArray* certs = [NSArray arrayWithObject: (id)cert]; | 72 NSArray* certs = [NSArray arrayWithObject: (id)cert]; |
| 73 | 73 |
| 74 if (parentWindow) { | 74 if (parentWindow) { |
| 75 // Open the cert panel as a sheet on the browser window. | 75 // Open the cert panel as a sheet on the browser window. |
| 76 [panel beginSheetForWindow:parentWindow | 76 [panel beginSheetForWindow:parentWindow |
| 77 modalDelegate:self | 77 modalDelegate:self |
| 78 didEndSelector:@selector(sheetDidEnd:returnCode:context:) | 78 didEndSelector:@selector(sheetDidEnd:returnCode:context:) |
| 79 contextInfo:NULL | 79 contextInfo:NULL |
| 80 certificates:certs | 80 certificates:certs |
| 81 showGroup:NO]; | 81 showGroup:NO]; |
| 82 } else { | 82 } else { |
| 83 // No available browser window, so run independently as a (blocking) dialog. | 83 // No available browser window, so run independently as a (blocking) dialog. |
| 84 int returnCode = [panel runModalForCertificates:certs showGroup:NO]; | 84 int returnCode = [panel runModalForCertificates:certs showGroup:NO]; |
| 85 [self sheetDidEnd:panel returnCode:returnCode context:NULL]; | 85 [self sheetDidEnd:panel returnCode:returnCode context:NULL]; |
| 86 } | 86 } |
| 87 } | 87 } |
| 88 | 88 |
| 89 @end | 89 @end |
| OLD | NEW |