on master help sign in
Allow configuration of dev extras
c12cb3fTom Smalley
jsaddle-wkwebview/cbits-cocoa/AppDelegate.m+7−2
@@ -16,6 +16,7 @@ extern void callWithWebView(WKWebView *, HsStablePtr);
16HsStablePtr global_willFinishLaunchingWithOptions = 0;
16HsStablePtr global_willFinishLaunchingWithOptions = 0;
17HsStablePtr global_didFinishLaunchingWithOptions = 0;
17HsStablePtr global_didFinishLaunchingWithOptions = 0;
18HsStablePtr global_applicationUniversalLink = 0;
18HsStablePtr global_applicationUniversalLink = 0;
19+uint64_t global_developerExtrasEnabled = 1;
19
20
20@implementation AppDelegate
21@implementation AppDelegate
21
22
@@ -39,7 +40,9 @@ HsStablePtr global_applicationUniversalLink = 0;
39
40
40-(void)applicationWillFinishLaunching:(NSNotification *)notification {
41-(void)applicationWillFinishLaunching:(NSNotification *)notification {
41 WKWebViewConfiguration *theConfiguration = [[WKWebViewConfiguration alloc] init];
42 WKWebViewConfiguration *theConfiguration = [[WKWebViewConfiguration alloc] init];
43+ if (global_developerExtrasEnabled) {
42− [theConfiguration.preferences setValue:@YES forKey:@"developerExtrasEnabled"];
44+ [theConfiguration.preferences setValue:@YES forKey:@"developerExtrasEnabled"];
45+ }
43 WKWebView *webView = [[WKWebView alloc] initWithFrame: [_window.contentView frame] configuration:theConfiguration];
46 WKWebView *webView = [[WKWebView alloc] initWithFrame: [_window.contentView frame] configuration:theConfiguration];
44 [_window setContentView:webView];
47 [_window setContentView:webView];
45 callWithWebView(webView, _handler);
48 callWithWebView(webView, _handler);
@@ -89,11 +92,13 @@ void runInWKWebView(HsStablePtr handler,
89 const uint64_t hs_requestAuthorizationOptionCarPlay,
92 const uint64_t hs_requestAuthorizationOptionCarPlay,
90 const uint64_t hs_registerForRemoteNotifications,
93 const uint64_t hs_registerForRemoteNotifications,
91 HsStablePtr hs_didRegisterForRemoteNotificationsWithDeviceToken,
94 HsStablePtr hs_didRegisterForRemoteNotificationsWithDeviceToken,
92− HsStablePtr hs_didFailToRegisterForRemoteNotificationsWithError) {
95+ HsStablePtr hs_didFailToRegisterForRemoteNotificationsWithError,
96+ const uint64_t hs_developerExtrasEnabled) {
93 @autoreleasepool {
97 @autoreleasepool {
94 global_willFinishLaunchingWithOptions = hs_willFinishLaunchingWithOptions;
98 global_willFinishLaunchingWithOptions = hs_willFinishLaunchingWithOptions;
95 global_didFinishLaunchingWithOptions = hs_didFinishLaunchingWithOptions;
99 global_didFinishLaunchingWithOptions = hs_didFinishLaunchingWithOptions;
96 global_applicationUniversalLink = hs_applicationUniversalLink;
100 global_applicationUniversalLink = hs_applicationUniversalLink;
101+ global_developerExtrasEnabled = hs_developerExtrasEnabled;
97 NSApplication *application = [NSApplication sharedApplication];
102 NSApplication *application = [NSApplication sharedApplication];
98 AppDelegate *appDelegate = [[AppDelegate alloc] initApp:handler progName:[NSString stringWithCString:progName encoding:NSUTF8StringEncoding]];
103 AppDelegate *appDelegate = [[AppDelegate alloc] initApp:handler progName:[NSString stringWithCString:progName encoding:NSUTF8StringEncoding]];
99 [application setDelegate:appDelegate];
104 [application setDelegate:appDelegate];
jsaddle-wkwebview/cbits-uikit/AppDelegate.m+2−1
@@ -159,7 +159,8 @@ void runInWKWebView(HsStablePtr handler,
159 const uint64_t hs_requestAuthorizationOptionCarPlay,
159 const uint64_t hs_requestAuthorizationOptionCarPlay,
160 const uint64_t hs_registerForRemoteNotifications,
160 const uint64_t hs_registerForRemoteNotifications,
161 HsStablePtr hs_didRegisterForRemoteNotificationsWithDeviceToken,
161 HsStablePtr hs_didRegisterForRemoteNotificationsWithDeviceToken,
162− HsStablePtr hs_didFailToRegisterForRemoteNotificationsWithError) {
162+ HsStablePtr hs_didFailToRegisterForRemoteNotificationsWithError,
163+ const uint64_t hs_developerExtrasEnabled) {
163 @autoreleasepool {
164 @autoreleasepool {
164 globalHandler = handler;
165 globalHandler = handler;
165 global_willFinishLaunchingWithOptions = hs_willFinishLaunchingWithOptions;
166 global_willFinishLaunchingWithOptions = hs_willFinishLaunchingWithOptions;
jsaddle-wkwebview/src-ghc/Language/Javascript/JSaddle/WKWebView.hs+4
@@ -47,6 +47,7 @@ foreign import ccall runInWKWebView
47 -> Word64 -- registerForRemoteNotifications
47 -> Word64 -- registerForRemoteNotifications
48 -> StablePtr (CString -> IO ()) -- didRegisterForRemoteNotificationsWithDeviceToken
48 -> StablePtr (CString -> IO ()) -- didRegisterForRemoteNotificationsWithDeviceToken
49 -> StablePtr (CString -> IO ()) -- didFailToRegisterForRemoteNotificationsWithError
49 -> StablePtr (CString -> IO ()) -- didFailToRegisterForRemoteNotificationsWithError
50+ -> Word64 -- Allow developer tools
50 -> IO ()
51 -> IO ()
51
52
52data AppDelegateConfig = AppDelegateConfig
53data AppDelegateConfig = AppDelegateConfig
@@ -60,6 +61,7 @@ data AppDelegateConfig = AppDelegateConfig
60 , _appDelegateConfig_applicationSignificantTimeChange :: IO ()
61 , _appDelegateConfig_applicationSignificantTimeChange :: IO ()
61 , _appDelegateConfig_applicationUniversalLink :: CString -> IO ()
62 , _appDelegateConfig_applicationUniversalLink :: CString -> IO ()
62 , _appDelegateConfig_appDelegateNotificationConfig :: AppDelegateNotificationConfig
63 , _appDelegateConfig_appDelegateNotificationConfig :: AppDelegateNotificationConfig
64+ , _appDelegateConfig_developerExtrasEnabled :: Bool
63 }
65 }
64
66
65instance Default AppDelegateConfig where
67instance Default AppDelegateConfig where
@@ -74,6 +76,7 @@ instance Default AppDelegateConfig where
74 , _appDelegateConfig_applicationSignificantTimeChange = return ()
76 , _appDelegateConfig_applicationSignificantTimeChange = return ()
75 , _appDelegateConfig_applicationUniversalLink = \_ -> return ()
77 , _appDelegateConfig_applicationUniversalLink = \_ -> return ()
76 , _appDelegateConfig_appDelegateNotificationConfig = def
78 , _appDelegateConfig_appDelegateNotificationConfig = def
79+ , _appDelegateConfig_developerExtrasEnabled = True
77 }
80 }
78
81
79data AuthorizationOption = AuthorizationOption_Badge
82data AuthorizationOption = AuthorizationOption_Badge
@@ -174,3 +177,4 @@ run' cfg main = do
174 (fromBool registerForRemoteNotifications)
177 (fromBool registerForRemoteNotifications)
175 didRegisterForRemoteNotificationsWithDeviceToken
178 didRegisterForRemoteNotificationsWithDeviceToken
176 didFailToRegisterForRemoteNotificationsWithError
179 didFailToRegisterForRemoteNotificationsWithError
180+ (fromBool $ _appDelegateConfig_developerExtrasEnabled cfg)