You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by sh...@apache.org on 2015/09/01 01:35:13 UTC
[5/6] mac commit: @trivial - reformat
@trivial - reformat
Project: http://git-wip-us.apache.org/repos/asf/cordova-osx/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-osx/commit/3fad3570
Tree: http://git-wip-us.apache.org/repos/asf/cordova-osx/tree/3fad3570
Diff: http://git-wip-us.apache.org/repos/asf/cordova-osx/diff/3fad3570
Branch: refs/heads/master
Commit: 3fad35700e672c5f4b163b9a6a765f1e877ed029
Parents: 5ec1cc4
Author: Tobias Bocanegra <tr...@adobe.com>
Authored: Mon Aug 31 22:30:08 2015 +0100
Committer: Tobias Bocanegra <tr...@adobe.com>
Committed: Mon Aug 31 22:30:08 2015 +0100
----------------------------------------------------------------------
.../CordovaLib/Classes/CDVWebViewDelegate.m | 89 ++++++++------------
1 file changed, 37 insertions(+), 52 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/3fad3570/CordovaLib/CordovaLib/Classes/CDVWebViewDelegate.m
----------------------------------------------------------------------
diff --git a/CordovaLib/CordovaLib/Classes/CDVWebViewDelegate.m b/CordovaLib/CordovaLib/Classes/CDVWebViewDelegate.m
index 04fbd86..05afc47 100644
--- a/CordovaLib/CordovaLib/Classes/CDVWebViewDelegate.m
+++ b/CordovaLib/CordovaLib/Classes/CDVWebViewDelegate.m
@@ -6,9 +6,9 @@
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
-
+
http://www.apache.org/licenses/LICENSE-2.0
-
+
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -26,56 +26,49 @@
@synthesize console;
-- (void)webView:(WebView*)webView didClearWindowObject:(WebScriptObject*)windowScriptObject forFrame:(WebFrame*)frame
-{
- if (self.console == nil) {
+- (void) webView:(WebView*) webView didClearWindowObject:(WebScriptObject*) windowScriptObject forFrame:(WebFrame*) frame {
+ if (self.console == nil) {
self.console = [CDVConsole new];
}
- [windowScriptObject setValue:self.console forKey:@"console"];
-
- if (self.bridge == nil) {
+ [windowScriptObject setValue:self.console forKey:@"console"];
+
+ if (self.bridge == nil) {
self.bridge = [[CDVBridge alloc] initWithWebView:webView andViewController:self.viewController];
}
[windowScriptObject setValue:self.bridge forKey:@"cordovabridge"];
}
-- (void)webView:(WebView*)sender didFinishLoadForFrame:(WebFrame*)frame
-{
+- (void) webView:(WebView*) sender didFinishLoadForFrame:(WebFrame*) frame {
id win = [sender windowScriptObject];
NSString* nativeReady = @"try{cordova.require('cordova/channel').onNativeReady.fire();}catch(e){window._nativeReady = true;}";
[win evaluateWebScript:nativeReady];
}
-- (void) webView:(WebView*)webView addMessageToConsole:(NSDictionary*)message
-{
- if (![message isKindOfClass:[NSDictionary class]]) {
- return;
- }
-
- NSLog(@"JavaScript error: %@:%@: %@",
- [[message objectForKey:@"sourceURL"] lastPathComponent], // could be nil
- [message objectForKey:@"lineNumber"],
- [message objectForKey:@"message"]);
+- (void) webView:(WebView*) webView addMessageToConsole:(NSDictionary*) message {
+ if (![message isKindOfClass:[NSDictionary class]]) {
+ return;
+ }
+ NSLog(@"JavaScript error: %@:%@: %@",
+ [message[@"sourceURL"] lastPathComponent], // could be nil
+ message[@"lineNumber"],
+ message[@"message"]);
}
#pragma mark WebScripting protocol
/* checks whether a selector is acceptable to be called from JavaScript */
-+ (BOOL) isSelectorExcludedFromWebScript:(SEL)selector
-{
- return YES;
++ (BOOL) isSelectorExcludedFromWebScript:(SEL) selector {
+ return YES;
}
// right now exclude all properties (eg keys)
-+ (BOOL) isKeyExcludedFromWebScript:(const char*)name
-{
- return YES;
++ (BOOL) isKeyExcludedFromWebScript:(const char*) name {
+ return YES;
}
#pragma mark WebPolicyDelegate
-- (void)webView:(WebView *)sender decidePolicyForNavigationAction:(NSDictionary *)actionInformation request:(NSURLRequest *)request frame:(WebFrame *)frame decisionListener:(id<WebPolicyDecisionListener>)listener
-{
+- (void) webView:(WebView*) sender decidePolicyForNavigationAction:(NSDictionary*) actionInformation request:(NSURLRequest*) request frame:(WebFrame*) frame decisionListener:(id <WebPolicyDecisionListener>) listener {
NSString* url = [[request URL] description];
NSLog(@"navigating to %@", url);
@@ -85,66 +78,58 @@
#pragma mark WebUIDelegate
-- (BOOL)webView:(WebView*)sender runBeforeUnloadConfirmPanelWithMessage:(NSString*)message initiatedByFrame:(WebFrame*)frame
-{
+- (BOOL) webView:(WebView*) sender runBeforeUnloadConfirmPanelWithMessage:(NSString*) message initiatedByFrame:(WebFrame*) frame {
return [self webView:sender runJavaScriptConfirmPanelWithMessage:message initiatedByFrame:frame];
}
-- (void)webView:(WebView *)sender runOpenPanelForFileButtonWithResultListener:(id < WebOpenPanelResultListener >)resultListener allowMultipleFiles:(BOOL)allowMultipleFiles
-{
+- (void) webView:(WebView*) sender runOpenPanelForFileButtonWithResultListener:(id <WebOpenPanelResultListener>) resultListener allowMultipleFiles:(BOOL) allowMultipleFiles {
NSOpenPanel* dialog = [NSOpenPanel openPanel];
-
+
[dialog setCanChooseFiles:YES];
[dialog setAllowsMultipleSelection:allowMultipleFiles];
[dialog setCanChooseDirectories:YES];
-
+
if ([dialog runModal] == NSOKButton) {
[resultListener chooseFilenames:[[dialog URLs] valueForKey:@"relativePath"]];
}
}
-- (void)webView:(WebView*)sender runOpenPanelForFileButtonWithResultListener:(id<WebOpenPanelResultListener>)resultListener
-{
+- (void) webView:(WebView*) sender runOpenPanelForFileButtonWithResultListener:(id <WebOpenPanelResultListener>) resultListener {
[self webView:sender runOpenPanelForFileButtonWithResultListener:resultListener allowMultipleFiles:NO];
}
-- (void)webView:(WebView*)sender runJavaScriptAlertPanelWithMessage:(NSString*)message initiatedByFrame:(WebFrame*)frame
-{
+- (void) webView:(WebView*) sender runJavaScriptAlertPanelWithMessage:(NSString*) message initiatedByFrame:(WebFrame*) frame {
NSAlert* alert = [[NSAlert alloc] init];
[alert addButtonWithTitle:NSLocalizedString(@"OK", @"")];
[alert setMessageText:message];
-
+
[alert runModal];
}
-- (BOOL)webView:(WebView*)sender runJavaScriptConfirmPanelWithMessage:(NSString*)message initiatedByFrame:(WebFrame*)frame
-{
+- (BOOL) webView:(WebView*) sender runJavaScriptConfirmPanelWithMessage:(NSString*) message initiatedByFrame:(WebFrame*) frame {
NSAlert* alert = [[NSAlert alloc] init];
[alert addButtonWithTitle:NSLocalizedString(@"OK", @"")];
[alert addButtonWithTitle:NSLocalizedString(@"Cancel", @"")];
[alert setMessageText:message];
-
+
return ([alert runModal] == NSAlertFirstButtonReturn);
}
-- (NSString*)webView:(WebView*)sender runJavaScriptTextInputPanelWithPrompt:(NSString*)prompt defaultText:(NSString*)defaultText initiatedByFrame:(WebFrame*)frame
-{
- NSAlert* alert = [NSAlert alertWithMessageText:prompt
- defaultButton:NSLocalizedString(@"OK", @"")
- alternateButton:NSLocalizedString(@"Cancel", @"")
- otherButton:nil
- informativeTextWithFormat:@""];
-
+- (NSString*) webView:(WebView*) sender runJavaScriptTextInputPanelWithPrompt:(NSString*) prompt defaultText:(NSString*) defaultText initiatedByFrame:(WebFrame*) frame {
+ NSAlert *alert = [[NSAlert alloc] init];
+ [alert addButtonWithTitle:NSLocalizedString(@"OK", @"")];
+ [alert addButtonWithTitle:NSLocalizedString(@"Cancel", @"")];
+ [alert setMessageText:prompt];
NSTextField* input = [[NSTextField alloc] initWithFrame:NSMakeRect(0, 0, 300, 24)];
[input setStringValue:defaultText];
[alert setAccessoryView:input];
-
+
NSInteger button = [alert runModal];
if (button == NSAlertDefaultReturn) {
[input validateEditing];
return [input stringValue];
}
-
+
return nil;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org