mirror of
https://github.com/munki/munki.git
synced 2026-01-05 22:20:00 -06:00
Make use of WKWebView compatible with 10.10 and 10.11
This commit is contained in:
@@ -628,7 +628,7 @@
|
||||
DEVELOPMENT_TEAM = "";
|
||||
INFOPLIST_FILE = "$(SRCROOT)/Managed Software Center/Info.plist";
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.12;
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.10;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.googlecode.munki.ManagedSoftwareCenter;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||
@@ -645,7 +645,7 @@
|
||||
DEVELOPMENT_TEAM = "";
|
||||
INFOPLIST_FILE = "$(SRCROOT)/Managed Software Center/Info.plist";
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.12;
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.10;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.googlecode.munki.ManagedSoftwareCenter;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||
|
||||
@@ -21,7 +21,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
|
||||
NSLog("%@", "Finished launching")
|
||||
if let info_dict = Bundle.main.infoDictionary {
|
||||
if let vers = info_dict["CFBundleShortVersionString"] as? String {
|
||||
print(vers)
|
||||
//print(vers)
|
||||
msc_log("MSC", "launched", msg: "VER=\(vers)")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
<dependencies>
|
||||
<deployment identifier="macosx"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14113"/>
|
||||
<plugIn identifier="com.apple.WebKit2IBPlugin" version="14113"/>
|
||||
<capability name="box content view" minToolsVersion="7.0"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
@@ -51,7 +50,9 @@
|
||||
<outlet property="myItemsMenuItem" destination="1bG-B4-adC" id="PCP-Ye-eRl"/>
|
||||
<outlet property="myItemsToolbarButton" destination="K8l-s4-jvt" id="cHq-DK-BZy"/>
|
||||
<outlet property="navigateBackButton" destination="AG2-ba-10I" id="cPd-dh-gGG"/>
|
||||
<outlet property="navigateBackMenuItem" destination="4nC-yt-nEz" id="bDM-jd-pUL"/>
|
||||
<outlet property="navigateForwardButton" destination="a6V-j2-ZvV" id="IGk-12-NL7"/>
|
||||
<outlet property="navigateForwardMenuItem" destination="nIf-zM-816" id="l80-4O-0q4"/>
|
||||
<outlet property="progressSpinner" destination="6oL-54-k6Q" id="SHv-QS-lUx"/>
|
||||
<outlet property="searchField" destination="1z2-9L-z6e" id="xp8-BZ-5dZ"/>
|
||||
<outlet property="softwareMenuItem" destination="YIg-jD-AbB" id="D6s-mC-x4d"/>
|
||||
@@ -59,7 +60,7 @@
|
||||
<outlet property="updateButtonCell" destination="enf-JF-dWM" id="a2w-hN-n3L"/>
|
||||
<outlet property="updatesMenuItem" destination="HOZ-SU-4Sm" id="UdT-3I-JpJ"/>
|
||||
<outlet property="updatesToolbarButton" destination="Rwi-cJ-59c" id="MRY-by-5VU"/>
|
||||
<outlet property="webView" destination="0ir-Bi-3hM" id="Xvc-dn-sXi"/>
|
||||
<outlet property="webViewPlaceholder" destination="Wf8-HB-bc8" id="qCG-zy-8UQ"/>
|
||||
<outlet property="window" destination="EeR-uP-dFY" id="FfQ-Q4-xUU"/>
|
||||
</connections>
|
||||
</customObject>
|
||||
@@ -157,14 +158,12 @@
|
||||
<items>
|
||||
<menuItem title="Back" keyEquivalent="[" id="4nC-yt-nEz">
|
||||
<connections>
|
||||
<action selector="goBack:" target="0ir-Bi-3hM" id="qwV-oq-3nd"/>
|
||||
<binding destination="XGW-R4-ybE" name="enabled" keyPath="self.webView.canGoBack" id="w32-Jd-eRh"/>
|
||||
<action selector="navigateBackBtnClicked:" target="XGW-R4-ybE" id="1Js-TT-NXZ"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Forward" keyEquivalent="]" id="nIf-zM-816">
|
||||
<connections>
|
||||
<action selector="goForward:" target="0ir-Bi-3hM" id="Hk5-y4-mFs"/>
|
||||
<binding destination="XGW-R4-ybE" name="enabled" keyPath="self.webView.canGoForward" id="m40-2h-Wkr"/>
|
||||
<action selector="navigateForwardBtnClicked:" target="XGW-R4-ybE" id="SFV-5J-eBx"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Reload Page" keyEquivalent="r" id="RZb-6e-dMo">
|
||||
@@ -256,7 +255,7 @@
|
||||
<windowStyleMask key="styleMask" titled="YES" closable="YES" resizable="YES"/>
|
||||
<windowCollectionBehavior key="collectionBehavior" fullScreenNone="YES"/>
|
||||
<rect key="contentRect" x="636" y="390" width="512" height="360"/>
|
||||
<rect key="screenRect" x="0.0" y="0.0" width="1440" height="878"/>
|
||||
<rect key="screenRect" x="0.0" y="0.0" width="1440" height="877"/>
|
||||
<value key="minSize" type="size" width="512" height="360"/>
|
||||
<view key="contentView" id="QRQ-UP-dFP">
|
||||
<rect key="frame" x="0.0" y="0.0" width="512" height="360"/>
|
||||
@@ -343,20 +342,16 @@
|
||||
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES" texturedBackground="YES"/>
|
||||
<windowCollectionBehavior key="collectionBehavior" fullScreenPrimary="YES"/>
|
||||
<rect key="contentRect" x="132" y="116" width="1143" height="730"/>
|
||||
<rect key="screenRect" x="0.0" y="0.0" width="1440" height="878"/>
|
||||
<rect key="screenRect" x="0.0" y="0.0" width="1440" height="877"/>
|
||||
<value key="minSize" type="size" width="1000" height="475"/>
|
||||
<view key="contentView" id="H4V-bM-OJY">
|
||||
<rect key="frame" x="0.0" y="0.0" width="1143" height="730"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<wkWebView wantsLayer="YES" fixedFrame="YES" allowsBackForwardNavigationGestures="YES" allowsLinkPreview="NO" translatesAutoresizingMaskIntoConstraints="NO" id="0ir-Bi-3hM">
|
||||
<customView fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Wf8-HB-bc8">
|
||||
<rect key="frame" x="0.0" y="0.0" width="1143" height="730"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<wkWebViewConfiguration key="configuration">
|
||||
<audiovisualMediaTypes key="mediaTypesRequiringUserActionForPlayback" none="YES"/>
|
||||
<wkPreferences key="preferences" javaScriptCanOpenWindowsAutomatically="NO"/>
|
||||
</wkWebViewConfiguration>
|
||||
</wkWebView>
|
||||
</customView>
|
||||
</subviews>
|
||||
</view>
|
||||
<toolbar key="toolbar" implicitIdentifier="1393D938-3469-4EFC-8191-CC1B9C26850B" autosavesConfiguration="NO" allowsUserCustomization="NO" displayMode="iconAndLabel" sizeMode="regular" id="hOq-DI-ljx">
|
||||
|
||||
@@ -9,14 +9,15 @@
|
||||
import Cocoa
|
||||
import WebKit
|
||||
|
||||
class MainWindowController: NSWindowController, NSWindowDelegate, WKNavigationDelegate {
|
||||
|
||||
class MainWindowController: NSWindowController, NSWindowDelegate, WKNavigationDelegate, WKScriptMessageHandler {
|
||||
|
||||
var _alertedUserToOutstandingUpdates = false
|
||||
var _update_in_progress = false
|
||||
var managedsoftwareupdate_task = ""
|
||||
var cached_self_service = SelfService()
|
||||
var alert_controller = MSCAlertController()
|
||||
var htmlDir = ""
|
||||
var wkContentController = WKUserContentController()
|
||||
|
||||
// status properties
|
||||
var _status_title = ""
|
||||
@@ -37,18 +38,19 @@ class MainWindowController: NSWindowController, NSWindowDelegate, WKNavigationDe
|
||||
|
||||
@IBOutlet weak var searchField: NSSearchField!
|
||||
|
||||
@IBOutlet weak var webView: WKWebView!
|
||||
|
||||
@IBOutlet weak var navigateBackMenuItem: NSMenuItem!
|
||||
@IBOutlet weak var navigateForwardMenuItem: NSMenuItem!
|
||||
@IBOutlet weak var softwareMenuItem: NSMenuItem!
|
||||
@IBOutlet weak var categoriesMenuItem: NSMenuItem!
|
||||
@IBOutlet weak var myItemsMenuItem: NSMenuItem!
|
||||
@IBOutlet weak var updatesMenuItem: NSMenuItem!
|
||||
@IBOutlet weak var findMenuItem: NSMenuItem!
|
||||
|
||||
@IBOutlet weak var webViewPlaceholder: NSView!
|
||||
var webView: WKWebView!
|
||||
|
||||
override func windowDidLoad() {
|
||||
super.windowDidLoad()
|
||||
|
||||
// Implement this method to handle any initialization after your window controller's window has been loaded from its nib file.
|
||||
}
|
||||
|
||||
func appShouldTerminate() -> NSApplication.TerminateReply {
|
||||
@@ -328,10 +330,42 @@ class MainWindowController: NSWindowController, NSWindowDelegate, WKNavigationDe
|
||||
|
||||
// End NSWindowDelegate methods
|
||||
|
||||
func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage) {
|
||||
// react to messages set to us by JavaScript
|
||||
print("Got message from JavaScript!")
|
||||
if message.name == "installButtonClicked" {
|
||||
installButtonClicked()
|
||||
}
|
||||
}
|
||||
|
||||
func addJSmessageHandlers() {
|
||||
// define messages JavaScript can send us
|
||||
wkContentController.add(self, name: "installButtonClicked")
|
||||
}
|
||||
|
||||
func insertWebView() {
|
||||
// replace our webview placeholder with the real one
|
||||
if let superview = webViewPlaceholder.superview {
|
||||
// define webview configuration
|
||||
let webConfiguration = WKWebViewConfiguration()
|
||||
addJSmessageHandlers()
|
||||
webConfiguration.userContentController = wkContentController
|
||||
webConfiguration.preferences.javaScriptEnabled = true
|
||||
webConfiguration.preferences.javaEnabled = false
|
||||
// init our webview
|
||||
let replacementWebView = WKWebView(frame: webViewPlaceholder.frame, configuration: webConfiguration)
|
||||
replacementWebView.autoresizingMask = webViewPlaceholder.autoresizingMask
|
||||
replacementWebView.allowsBackForwardNavigationGestures = true
|
||||
// replace the placeholder in the window view with the real webview
|
||||
superview.replaceSubview(webViewPlaceholder, with: replacementWebView)
|
||||
webView = replacementWebView
|
||||
}
|
||||
}
|
||||
|
||||
override func awakeFromNib() {
|
||||
// Stuff we need to intialize when we start
|
||||
super.awakeFromNib()
|
||||
//webView.drawsBackground = false
|
||||
insertWebView()
|
||||
webView.navigationDelegate = self
|
||||
setNoPageCache()
|
||||
alert_controller = MSCAlertController()
|
||||
@@ -765,7 +799,9 @@ class MainWindowController: NSWindowController, NSWindowDelegate, WKNavigationDe
|
||||
func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
|
||||
progressSpinner.stopAnimation(self)
|
||||
navigateBackButton.isEnabled = webView.canGoBack
|
||||
navigateBackMenuItem.isEnabled = webView.canGoBack
|
||||
navigateForwardButton.isEnabled = webView.canGoForward
|
||||
navigateForwardMenuItem.isEnabled = webView.canGoForward
|
||||
}
|
||||
|
||||
func webView(_ webView: WKWebView,
|
||||
|
||||
@@ -22,6 +22,11 @@
|
||||
<string>1</string>
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
|
||||
<key>NSAppTransportSecurity</key>
|
||||
<dict>
|
||||
<key>NSAllowsArbitraryLoads</key>
|
||||
<true/>
|
||||
</dict>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
<string>Copyright © 2018 The Munki Project. All rights reserved.</string>
|
||||
<key>NSMainNibFile</key>
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
<div class='progress-spinner ${hide_progress_spinner}' id="updates-progress-spinner"></div>
|
||||
<div class="msc-button install-updates in-header">
|
||||
<button class="button-area uppercase"
|
||||
onClick="window.AppController.installButtonClicked();">
|
||||
onClick="window.webkit.messageHandlers.installButtonClicked.postMessage('');">
|
||||
<div class="msc-button-inner install-updates ${install_all_button_classes}"
|
||||
id='install-all-button-text'>
|
||||
${install_btn_label}
|
||||
|
||||
Reference in New Issue
Block a user