Index: chrome/browser/mac/certificate_viewer_base.mm |
diff --git a/chrome/browser/ui/cocoa/certificate_viewer_mac.mm b/chrome/browser/mac/certificate_viewer_base.mm |
similarity index 55% |
copy from chrome/browser/ui/cocoa/certificate_viewer_mac.mm |
copy to chrome/browser/mac/certificate_viewer_base.mm |
index 1adb0f166bd8687c67f8d0aa8155bed3b1d21f63..ca447d4d2cdaf6e74c25a62bca333e0b85de0e21 100644 |
--- a/chrome/browser/ui/cocoa/certificate_viewer_mac.mm |
+++ b/chrome/browser/mac/certificate_viewer_base.mm |
@@ -1,80 +1,16 @@ |
-// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
+// Copyright (c) 2016 The Chromium Authors. All rights reserved. |
tapted
2016/03/21 02:47:12
nit: no (c)
Patti Lor
2016/05/03 00:05:00
Done.
|
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#import "chrome/browser/ui/cocoa/certificate_viewer_mac.h" |
- |
-#include <Security/Security.h> |
-#include <SecurityInterface/SFCertificatePanel.h> |
-#include <vector> |
+#include "chrome/browser/mac/certificate_viewer_base.h" |
tapted
2016/03/21 02:47:12
import
Patti Lor
2016/05/03 00:05:00
Done.
|
#include "base/mac/foundation_util.h" |
#include "base/mac/scoped_cftyperef.h" |
-#include "base/macros.h" |
-#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" |
-#import "ui/base/cocoa/window_size_constants.h" |
- |
-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: |
- explicit SSLCertificateViewerCocoaBridge(SSLCertificateViewerCocoa * |
- controller) |
- : controller_(controller) { |
- } |
- |
- virtual ~SSLCertificateViewerCocoaBridge() {} |
- |
- // ConstrainedWindowMacDelegate implementation: |
- void OnConstrainedWindowClosed(ConstrainedWindowMac* window) override { |
- // |onConstrainedWindowClosed| will delete the sheet which might be still |
- // in use higher up the call stack. Wait for the next cycle of the event |
- // loop to call this function. |
- [controller_ performSelector:@selector(onConstrainedWindowClosed) |
- withObject:nil |
- afterDelay:0]; |
- } |
- private: |
- SSLCertificateViewerCocoa* controller_; // weak |
- |
- 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 |
+@implementation SSLCertificateViewerMacBase |
- (id)initWithCertificate:(net::X509Certificate*)certificate { |
if ((self = [super init])) { |
@@ -86,13 +22,6 @@ void ShowCertificateViewer(content::WebContents* web_contents, |
return self; |
} |
-- (void)sheetDidEnd:(NSWindow*)parent |
- returnCode:(NSInteger)returnCode |
- context:(void*)context { |
- if (!closePending_) |
- constrainedWindow_->CloseWebContentsModalDialog(); |
-} |
- |
- (void)displayForWebContents:(content::WebContents*)webContents { |
// Explicitly disable revocation checking, regardless of user preferences |
// or system settings. The behaviour of SFCertificatePanel is to call |
@@ -133,15 +62,14 @@ void ShowCertificateViewer(content::WebContents* web_contents, |
panel_.reset([[SFCertificatePanel alloc] init]); |
[panel_ setPolicies:(id) policies.get()]; |
- |
- constrainedWindow_ = |
- CreateAndShowWebModalDialogMac(observer_.get(), webContents, self); |
} |
- (NSWindow*)overlayWindow { |
return overlayWindow_; |
} |
+// ConstrainedWindowSheet: |
tapted
2016/03/21 02:47:12
For objc the current approach is something like
/
Patti Lor
2016/05/03 00:05:00
Done.
|
+ |
- (void)showSheetForWindow:(NSWindow*)window { |
overlayWindow_.reset([window retain]); |
[panel_ beginSheetForWindow:window |
@@ -149,16 +77,16 @@ void ShowCertificateViewer(content::WebContents* web_contents, |
didEndSelector:@selector(sheetDidEnd: |
returnCode: |
context:) |
- contextInfo:NULL |
- certificates:certificates_ |
- showGroup:YES]; |
+ contextInfo:NULL |
tapted
2016/03/21 02:47:12
rollback indenting change
Patti Lor
2016/05/03 00:05:00
Done.
|
+ certificates:certificates_ |
+ showGroup:YES]; |
} |
- (void)closeSheetWithAnimation:(BOOL)withAnimation { |
closePending_ = YES; |
overlayWindow_.reset(); |
- // Closing the sheet using -[NSApp endSheet:] doesn't work so use the private |
- // method. |
+ // Closing the sheet using -[NSApp endSheet:] doesn't work so use the |
tapted
2016/03/21 02:47:12
re-wrap
Patti Lor
2016/05/03 00:05:00
Done.
|
+ // private method. |
[panel_ _dismissWithCode:NSFileHandlingPanelCancelButton]; |
} |
@@ -197,10 +125,4 @@ void ShowCertificateViewer(content::WebContents* web_contents, |
return panel_; |
} |
-- (void)onConstrainedWindowClosed { |
- panel_.reset(); |
- constrainedWindow_.reset(); |
- [self release]; |
-} |
- |
@end |