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" |
Donald E Curtis | a873644 | 2015-08-05 15:48:13 -0700 | [diff] [blame] | 16 | #import "APPRTCViewController.h" |
kthelgason | 314bc5f | 2016-08-31 10:23:27 -0700 | [diff] [blame^] | 17 | #import "WebRTC/RTCSSLAdapter.h" |
Donald E Curtis | a873644 | 2015-08-05 15:48:13 -0700 | [diff] [blame] | 18 | |
| 19 | @interface APPRTCAppDelegate () <NSWindowDelegate> |
| 20 | @end |
| 21 | |
| 22 | @implementation APPRTCAppDelegate { |
| 23 | APPRTCViewController* _viewController; |
| 24 | NSWindow* _window; |
| 25 | } |
| 26 | |
| 27 | #pragma mark - NSApplicationDelegate |
| 28 | |
| 29 | - (void)applicationDidFinishLaunching:(NSNotification*)notification { |
hjon | 79858f8 | 2016-03-13 22:08:26 -0700 | [diff] [blame] | 30 | RTCInitializeSSL(); |
Donald E Curtis | a873644 | 2015-08-05 15:48:13 -0700 | [diff] [blame] | 31 | NSScreen* screen = [NSScreen mainScreen]; |
| 32 | NSRect visibleRect = [screen visibleFrame]; |
| 33 | NSRect windowRect = NSMakeRect(NSMidX(visibleRect), |
| 34 | NSMidY(visibleRect), |
| 35 | 1320, |
| 36 | 1140); |
| 37 | NSUInteger styleMask = NSTitledWindowMask | NSClosableWindowMask; |
| 38 | _window = [[NSWindow alloc] initWithContentRect:windowRect |
| 39 | styleMask:styleMask |
| 40 | backing:NSBackingStoreBuffered |
| 41 | defer:NO]; |
| 42 | _window.delegate = self; |
| 43 | [_window makeKeyAndOrderFront:self]; |
| 44 | [_window makeMainWindow]; |
| 45 | _viewController = [[APPRTCViewController alloc] initWithNibName:nil |
| 46 | bundle:nil]; |
| 47 | [_window setContentView:[_viewController view]]; |
| 48 | } |
| 49 | |
| 50 | #pragma mark - NSWindow |
| 51 | |
| 52 | - (void)windowWillClose:(NSNotification*)notification { |
| 53 | [_viewController windowWillClose:notification]; |
hjon | 79858f8 | 2016-03-13 22:08:26 -0700 | [diff] [blame] | 54 | RTCCleanupSSL(); |
Donald E Curtis | a873644 | 2015-08-05 15:48:13 -0700 | [diff] [blame] | 55 | [NSApp terminate:self]; |
| 56 | } |
| 57 | |
| 58 | @end |
| 59 | |