Index: chrome/browser/ui/cocoa/certificate_viewer_mac.mm |
diff --git a/chrome/browser/ui/cocoa/certificate_viewer_mac.mm b/chrome/browser/ui/cocoa/certificate_viewer_mac.mm |
index 1adb0f166bd8687c67f8d0aa8155bed3b1d21f63..16044b97a77d07e4ab388a05eb6e85d69ad4c030 100644 |
--- a/chrome/browser/ui/cocoa/certificate_viewer_mac.mm |
+++ b/chrome/browser/ui/cocoa/certificate_viewer_mac.mm |
@@ -6,37 +6,17 @@ |
#include <Security/Security.h> |
#include <SecurityInterface/SFCertificatePanel.h> |
tapted
2016/03/21 02:47:13
These includes shouldn't be needed
Patti Lor
2016/05/03 00:05:00
Done.
|
-#include <vector> |
#include "base/mac/foundation_util.h" |
#include "base/mac/scoped_cftyperef.h" |
tapted
2016/03/21 02:47:13
nor this
Patti Lor
2016/05/03 00:05:00
Done.
|
#include "base/macros.h" |
tapted
2016/03/21 02:47:12
or this - but there should probable be a base/logg
Patti Lor
2016/05/03 00:05:00
Done.
|
#include "chrome/browser/certificate_viewer.h" |
-#import "chrome/browser/ui/cocoa/constrained_window/constrained_window_mac.h" |
#import "chrome/browser/ui/cocoa/constrained_window/constrained_window_sheet.h" |
#import "chrome/browser/ui/cocoa/constrained_window/constrained_window_sheet_controller.h" |
#include "net/cert/x509_certificate.h" |
#include "net/cert/x509_util_mac.h" |
tapted
2016/03/21 02:47:13
the net/cert includes probably aren't needed eithe
Patti Lor
2016/05/03 00:05:00
Done.
|
#import "ui/base/cocoa/window_size_constants.h" |
tapted
2016/03/21 02:47:13
this seems unused too, (but that seems to have alw
Patti Lor
2016/05/03 00:05:00
Done.
|
-class SSLCertificateViewerCocoaBridge; |
- |
-@interface SFCertificatePanel (SystemPrivate) |
-// A system-private interface that dismisses a panel whose sheet was started by |
-// -beginSheetForWindow: |
-// modalDelegate: |
-// didEndSelector: |
-// contextInfo: |
-// certificates: |
-// showGroup: |
-// as though the user clicked the button identified by returnCode. Verified |
-// present in 10.8. |
-- (void)_dismissWithCode:(NSInteger)code; |
-@end |
- |
-@interface SSLCertificateViewerCocoa () |
-- (void)onConstrainedWindowClosed; |
-@end |
class SSLCertificateViewerCocoaBridge : public ConstrainedWindowMacDelegate { |
public: |
@@ -63,29 +43,8 @@ class SSLCertificateViewerCocoaBridge : public ConstrainedWindowMacDelegate { |
DISALLOW_COPY_AND_ASSIGN(SSLCertificateViewerCocoaBridge); |
}; |
-void ShowCertificateViewer(content::WebContents* web_contents, |
- gfx::NativeWindow parent, |
- net::X509Certificate* cert) { |
- // SSLCertificateViewerCocoa will manage its own lifetime and will release |
- // itself when the dialog is closed. |
- // See -[SSLCertificateViewerCocoa onConstrainedWindowClosed]. |
- SSLCertificateViewerCocoa* viewer = |
- [[SSLCertificateViewerCocoa alloc] initWithCertificate:cert]; |
- [viewer displayForWebContents:web_contents]; |
-} |
- |
@implementation SSLCertificateViewerCocoa |
-- (id)initWithCertificate:(net::X509Certificate*)certificate { |
- if ((self = [super init])) { |
- base::ScopedCFTypeRef<CFArrayRef> cert_chain( |
- certificate->CreateOSCertChainForCert()); |
- NSArray* certificates = base::mac::CFToNSCast(cert_chain.get()); |
- certificates_.reset([certificates retain]); |
- } |
- return self; |
-} |
- |
- (void)sheetDidEnd:(NSWindow*)parent |
returnCode:(NSInteger)returnCode |
context:(void*)context { |
@@ -94,45 +53,7 @@ void ShowCertificateViewer(content::WebContents* web_contents, |
} |
- (void)displayForWebContents:(content::WebContents*)webContents { |
- // Explicitly disable revocation checking, regardless of user preferences |
- // or system settings. The behaviour of SFCertificatePanel is to call |
- // SecTrustEvaluate on the certificate(s) supplied, effectively |
- // duplicating the behaviour of net::X509Certificate::Verify(). However, |
- // this call stalls the UI if revocation checking is enabled in the |
- // Keychain preferences or if the cert may be an EV cert. By disabling |
- // revocation checking, the stall is limited to the time taken for path |
- // building and verification, which should be minimized due to the path |
- // being provided in |certificates|. This does not affect normal |
- // revocation checking from happening, which is controlled by |
- // net::X509Certificate::Verify() and user preferences, but will prevent |
- // the certificate viewer UI from displaying which certificate is revoked. |
- // This is acceptable, as certificate revocation will still be shown in |
- // the page info bubble if a certificate in the chain is actually revoked. |
- base::ScopedCFTypeRef<CFMutableArrayRef> policies( |
- CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks)); |
- if (!policies.get()) { |
- NOTREACHED(); |
- return; |
- } |
- // Add a basic X.509 policy, in order to match the behaviour of |
- // SFCertificatePanel when no policies are specified. |
- SecPolicyRef basic_policy = NULL; |
- OSStatus status = net::x509_util::CreateBasicX509Policy(&basic_policy); |
- if (status != noErr) { |
- NOTREACHED(); |
- return; |
- } |
- CFArrayAppendValue(policies, basic_policy); |
- CFRelease(basic_policy); |
- |
- status = net::x509_util::CreateRevocationPolicies(false, false, policies); |
- if (status != noErr) { |
- NOTREACHED(); |
- return; |
- } |
- |
- panel_.reset([[SFCertificatePanel alloc] init]); |
- [panel_ setPolicies:(id) policies.get()]; |
+ [super displayForWebContents:webContents]; |
constrainedWindow_ = |
CreateAndShowWebModalDialogMac(observer_.get(), webContents, self); |
@@ -204,3 +125,11 @@ void ShowCertificateViewer(content::WebContents* web_contents, |
} |
@end |
+ |
+void ShowCertificateViewer(content::WebContents* web_contents, |
+ gfx::NativeWindow parent, |
+ net::X509Certificate* cert) { |
+ SSLCertificateViewerCocoa* viewer = |
+ [[SSLCertificateViewerCocoa alloc] initWithCertificate:cert]; |
+ [viewer displayForWebContents:web_contents]; |
+} |