Donald E Curtis | a873644 | 2015-08-05 15:48:13 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2014 The WebRTC Project Authors. All rights reserved. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license |
| 5 | * that can be found in the LICENSE file in the root of the source |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
| 11 | #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 12 | #error "This file requires ARC support." |
| 13 | #endif |
| 14 | |
| 15 | #import "APPRTCAppDelegate.h" |
| 16 | |
hjon | 79858f8 | 2016-03-13 22:08:26 -0700 | [diff] [blame] | 17 | #import "webrtc/base/objc/RTCSSLAdapter.h" |
| 18 | |
Donald E Curtis | a873644 | 2015-08-05 15:48:13 -0700 | [diff] [blame] | 19 | #import "APPRTCViewController.h" |
Donald E Curtis | a873644 | 2015-08-05 15:48:13 -0700 | [diff] [blame] | 20 | |
| 21 | @interface APPRTCAppDelegate () <NSWindowDelegate> |
| 22 | @end |
| 23 | |
| 24 | @implementation APPRTCAppDelegate { |
| 25 | APPRTCViewController* _viewController; |
| 26 | NSWindow* _window; |
| 27 | } |
| 28 | |
| 29 | #pragma mark - NSApplicationDelegate |
| 30 | |
| 31 | - (void)applicationDidFinishLaunching:(NSNotification*)notification { |
hjon | 79858f8 | 2016-03-13 22:08:26 -0700 | [diff] [blame] | 32 | RTCInitializeSSL(); |
Donald E Curtis | a873644 | 2015-08-05 15:48:13 -0700 | [diff] [blame] | 33 | NSScreen* screen = [NSScreen mainScreen]; |
| 34 | NSRect visibleRect = [screen visibleFrame]; |
| 35 | NSRect windowRect = NSMakeRect(NSMidX(visibleRect), |
| 36 | NSMidY(visibleRect), |
| 37 | 1320, |
| 38 | 1140); |
| 39 | NSUInteger styleMask = NSTitledWindowMask | NSClosableWindowMask; |
| 40 | _window = [[NSWindow alloc] initWithContentRect:windowRect |
| 41 | styleMask:styleMask |
| 42 | backing:NSBackingStoreBuffered |
| 43 | defer:NO]; |
| 44 | _window.delegate = self; |
| 45 | [_window makeKeyAndOrderFront:self]; |
| 46 | [_window makeMainWindow]; |
| 47 | _viewController = [[APPRTCViewController alloc] initWithNibName:nil |
| 48 | bundle:nil]; |
| 49 | [_window setContentView:[_viewController view]]; |
| 50 | } |
| 51 | |
| 52 | #pragma mark - NSWindow |
| 53 | |
| 54 | - (void)windowWillClose:(NSNotification*)notification { |
| 55 | [_viewController windowWillClose:notification]; |
hjon | 79858f8 | 2016-03-13 22:08:26 -0700 | [diff] [blame] | 56 | RTCCleanupSSL(); |
Donald E Curtis | a873644 | 2015-08-05 15:48:13 -0700 | [diff] [blame] | 57 | [NSApp terminate:self]; |
| 58 | } |
| 59 | |
| 60 | @end |
| 61 | |