diff options
author | Kristian Monsen <kristianm@google.com> | 2010-06-28 16:42:48 +0100 |
---|---|---|
committer | Kristian Monsen <kristianm@google.com> | 2010-07-02 10:29:56 +0100 |
commit | 06ea8e899e48f1f2f396b70e63fae369f2f23232 (patch) | |
tree | 20c1428cd05c76f32394ab354ea35ed99acd86d8 /WebKitTools/MiniBrowser | |
parent | 72aad67af14193199e29cdd5c4ddc095a8b9a8a8 (diff) | |
download | external_webkit-06ea8e899e48f1f2f396b70e63fae369f2f23232.zip external_webkit-06ea8e899e48f1f2f396b70e63fae369f2f23232.tar.gz external_webkit-06ea8e899e48f1f2f396b70e63fae369f2f23232.tar.bz2 |
Merge WebKit at r61871: Initial merge by git.
Change-Id: I6cff43abca9cc4782e088a469ad4f03f166a65d5
Diffstat (limited to 'WebKitTools/MiniBrowser')
-rw-r--r-- | WebKitTools/MiniBrowser/MiniBrowser.xcodeproj/project.pbxproj | 134 | ||||
-rw-r--r-- | WebKitTools/MiniBrowser/WebBundle-Info.plist | 22 | ||||
-rw-r--r-- | WebKitTools/MiniBrowser/mac/AppDelegate.h | 8 | ||||
-rw-r--r-- | WebKitTools/MiniBrowser/mac/AppDelegate.m | 49 | ||||
-rw-r--r-- | WebKitTools/MiniBrowser/mac/BrowserWindowController.m | 47 | ||||
-rw-r--r-- | WebKitTools/MiniBrowser/mac/MiniBrowser_Prefix.pch | 6 | ||||
-rw-r--r-- | WebKitTools/MiniBrowser/mac/WebBundle/WebBundleMain.m | 124 | ||||
-rw-r--r-- | WebKitTools/MiniBrowser/win/BrowserView.cpp | 9 |
8 files changed, 362 insertions, 37 deletions
diff --git a/WebKitTools/MiniBrowser/MiniBrowser.xcodeproj/project.pbxproj b/WebKitTools/MiniBrowser/MiniBrowser.xcodeproj/project.pbxproj index 4518dd3..eeb70c9 100644 --- a/WebKitTools/MiniBrowser/MiniBrowser.xcodeproj/project.pbxproj +++ b/WebKitTools/MiniBrowser/MiniBrowser.xcodeproj/project.pbxproj @@ -11,14 +11,42 @@ 256AC3DA0F4B6AC300CF3369 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 256AC3D90F4B6AC300CF3369 /* AppDelegate.m */; }; 8D11072B0486CEB800E47090 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C165CFE840E0CC02AAC07 /* InfoPlist.strings */; }; 8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */; }; + BC20545E11C96C92008F3375 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */; }; BC329487116A92E2008635D0 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = BC329486116A92E2008635D0 /* main.m */; }; BC329498116A941B008635D0 /* BrowserWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = BC329497116A941B008635D0 /* BrowserWindowController.m */; }; BC3294A3116A9852008635D0 /* BrowserWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = BC3294A1116A9852008635D0 /* BrowserWindow.xib */; }; BC8FB5A8116AA1FE0080D413 /* WebKit2.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BC8FB5A7116AA1FE0080D413 /* WebKit2.framework */; }; + BCBD384011B08A6800E01E54 /* WebBundleMain.m in Sources */ = {isa = PBXBuildFile; fileRef = BCBD383D11B08A3100E01E54 /* WebBundleMain.m */; }; + BCBD384411B08AAD00E01E54 /* WebKit2.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BC8FB5A7116AA1FE0080D413 /* WebKit2.framework */; }; + BCBD38D011B08C0200E01E54 /* WebBundle.bundle in Copy WebBundle */ = {isa = PBXBuildFile; fileRef = BCBD381D11B0898200E01E54 /* WebBundle.bundle */; }; BCE625EE117FC80E00572433 /* BrowserStatisticsWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = BCE625ED117FC80E00572433 /* BrowserStatisticsWindow.xib */; }; BCE625F1117FC82700572433 /* BrowserStatisticsWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = BCE625F0117FC82700572433 /* BrowserStatisticsWindowController.m */; }; /* End PBXBuildFile section */ +/* Begin PBXContainerItemProxy section */ + BCBD38C511B08BA400E01E54 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 29B97313FDCFA39411CA2CEA /* Project object */; + proxyType = 1; + remoteGlobalIDString = BCBD381C11B0898200E01E54; + remoteInfo = WebBundle; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXCopyFilesBuildPhase section */ + BCBD38CF11B08C0100E01E54 /* Copy WebBundle */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = Contents; + dstSubfolderSpec = 1; + files = ( + BCBD38D011B08C0200E01E54 /* WebBundle.bundle in Copy WebBundle */, + ); + name = "Copy WebBundle"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + /* Begin PBXFileReference section */ 089C165DFE840E0CC02AAC07 /* InfoPlist.strings */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = InfoPlist.strings; path = mac/English.lproj/InfoPlist.strings; sourceTree = "<group>"; }; 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = "<absolute>"; }; @@ -37,6 +65,9 @@ BC329497116A941B008635D0 /* BrowserWindowController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = BrowserWindowController.m; path = mac/BrowserWindowController.m; sourceTree = "<group>"; }; BC3294A2116A9852008635D0 /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = mac/English.lproj/BrowserWindow.xib; sourceTree = "<group>"; }; BC8FB5A7116AA1FE0080D413 /* WebKit2.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = WebKit2.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + BCBD381D11B0898200E01E54 /* WebBundle.bundle */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = WebBundle.bundle; sourceTree = BUILT_PRODUCTS_DIR; }; + BCBD381E11B0898200E01E54 /* WebBundle-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "WebBundle-Info.plist"; sourceTree = "<group>"; }; + BCBD383D11B08A3100E01E54 /* WebBundleMain.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WebBundleMain.m; sourceTree = "<group>"; }; BCE625ED117FC80E00572433 /* BrowserStatisticsWindow.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = BrowserStatisticsWindow.xib; path = mac/BrowserStatisticsWindow.xib; sourceTree = "<group>"; }; BCE625EF117FC82700572433 /* BrowserStatisticsWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BrowserStatisticsWindowController.h; path = mac/BrowserStatisticsWindowController.h; sourceTree = "<group>"; }; BCE625F0117FC82700572433 /* BrowserStatisticsWindowController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = BrowserStatisticsWindowController.m; path = mac/BrowserStatisticsWindowController.m; sourceTree = "<group>"; }; @@ -52,6 +83,15 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + BCBD381B11B0898200E01E54 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + BC20545E11C96C92008F3375 /* Cocoa.framework in Frameworks */, + BCBD384411B08AAD00E01E54 /* WebKit2.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ @@ -91,6 +131,7 @@ isa = PBXGroup; children = ( 8D1107320486CEB800E47090 /* MiniBrowser.app */, + BCBD381D11B0898200E01E54 /* WebBundle.bundle */, ); name = Products; sourceTree = "<group>"; @@ -100,6 +141,7 @@ children = ( 080E96DDFE201D6D7F000001 /* Classes */, 29B97315FDCFA39411CA2CEA /* Other Sources */, + BCBD382B11B089F700E01E54 /* WebBundle */, 29B97317FDCFA39411CA2CEA /* Resources */, BC1770481188EB05007D9E9A /* Scripts */, 29B97323FDCFA39411CA2CEA /* Frameworks */, @@ -121,6 +163,7 @@ isa = PBXGroup; children = ( 8D1107310486CEB800E47090 /* MiniBrowser-Info.plist */, + BCBD381E11B0898200E01E54 /* WebBundle-Info.plist */, 089C165CFE840E0CC02AAC07 /* InfoPlist.strings */, BC3294A1116A9852008635D0 /* BrowserWindow.xib */, 1DDD58140DA1D0A300B32029 /* MainMenu.xib */, @@ -146,6 +189,15 @@ name = Scripts; sourceTree = "<group>"; }; + BCBD382B11B089F700E01E54 /* WebBundle */ = { + isa = PBXGroup; + children = ( + BCBD383D11B08A3100E01E54 /* WebBundleMain.m */, + ); + name = WebBundle; + path = mac/WebBundle; + sourceTree = "<group>"; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -154,6 +206,7 @@ buildConfigurationList = C01FCF4A08A954540054247B /* Build configuration list for PBXNativeTarget "MiniBrowser" */; buildPhases = ( 8D1107290486CEB800E47090 /* Resources */, + BCBD38CF11B08C0100E01E54 /* Copy WebBundle */, 8D11072C0486CEB800E47090 /* Sources */, 8D11072E0486CEB800E47090 /* Frameworks */, BC17701E1188DFB4007D9E9A /* Make Launchable */, @@ -161,6 +214,7 @@ buildRules = ( ); dependencies = ( + BCBD38C611B08BA400E01E54 /* PBXTargetDependency */, ); name = MiniBrowser; productInstallPath = "$(HOME)/Applications"; @@ -168,6 +222,23 @@ productReference = 8D1107320486CEB800E47090 /* MiniBrowser.app */; productType = "com.apple.product-type.application"; }; + BCBD381C11B0898200E01E54 /* WebBundle */ = { + isa = PBXNativeTarget; + buildConfigurationList = BCBD382111B0898300E01E54 /* Build configuration list for PBXNativeTarget "WebBundle" */; + buildPhases = ( + BCBD381911B0898200E01E54 /* Resources */, + BCBD381A11B0898200E01E54 /* Sources */, + BCBD381B11B0898200E01E54 /* Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = WebBundle; + productName = WebBundle; + productReference = BCBD381D11B0898200E01E54 /* WebBundle.bundle */; + productType = "com.apple.product-type.bundle"; + }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ @@ -181,6 +252,7 @@ projectRoot = ""; targets = ( 8D1107260486CEB800E47090 /* MiniBrowser */, + BCBD381C11B0898200E01E54 /* WebBundle */, ); }; /* End PBXProject section */ @@ -197,6 +269,13 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + BCBD381911B0898200E01E54 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ @@ -228,8 +307,24 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + BCBD381A11B0898200E01E54 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + BCBD384011B08A6800E01E54 /* WebBundleMain.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXSourcesBuildPhase section */ +/* Begin PBXTargetDependency section */ + BCBD38C611B08BA400E01E54 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = BCBD381C11B0898200E01E54 /* WebBundle */; + targetProxy = BCBD38C511B08BA400E01E54 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + /* Begin PBXVariantGroup section */ 089C165CFE840E0CC02AAC07 /* InfoPlist.strings */ = { isa = PBXVariantGroup; @@ -258,6 +353,36 @@ /* End PBXVariantGroup section */ /* Begin XCBuildConfiguration section */ + BCBD381F11B0898300E01E54 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + COPY_PHASE_STRIP = NO; + GCC_ENABLE_OBJC_GC = supported; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = mac/MiniBrowser_Prefix.pch; + INFOPLIST_FILE = "WebBundle-Info.plist"; + PRODUCT_NAME = WebBundle; + WRAPPER_EXTENSION = bundle; + }; + name = Debug; + }; + BCBD382011B0898300E01E54 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + COPY_PHASE_STRIP = YES; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + GCC_ENABLE_OBJC_GC = supported; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = mac/MiniBrowser_Prefix.pch; + INFOPLIST_FILE = "WebBundle-Info.plist"; + PRODUCT_NAME = WebBundle; + WRAPPER_EXTENSION = bundle; + }; + name = Release; + }; C01FCF4B08A954540054247B /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { @@ -318,6 +443,15 @@ /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ + BCBD382111B0898300E01E54 /* Build configuration list for PBXNativeTarget "WebBundle" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + BCBD381F11B0898300E01E54 /* Debug */, + BCBD382011B0898300E01E54 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; C01FCF4A08A954540054247B /* Build configuration list for PBXNativeTarget "MiniBrowser" */ = { isa = XCConfigurationList; buildConfigurations = ( diff --git a/WebKitTools/MiniBrowser/WebBundle-Info.plist b/WebKitTools/MiniBrowser/WebBundle-Info.plist new file mode 100644 index 0000000..c285a47 --- /dev/null +++ b/WebKitTools/MiniBrowser/WebBundle-Info.plist @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>CFBundleDevelopmentRegion</key> + <string>English</string> + <key>CFBundleExecutable</key> + <string>${EXECUTABLE_NAME}</string> + <key>CFBundleIdentifier</key> + <string>com.yourcompany.${PRODUCT_NAME:rfc1034identifier}</string> + <key>CFBundleInfoDictionaryVersion</key> + <string>6.0</string> + <key>CFBundlePackageType</key> + <string>BNDL</string> + <key>CFBundleShortVersionString</key> + <string>1.0</string> + <key>CFBundleSignature</key> + <string>????</string> + <key>CFBundleVersion</key> + <string>1</string> +</dict> +</plist> diff --git a/WebKitTools/MiniBrowser/mac/AppDelegate.h b/WebKitTools/MiniBrowser/mac/AppDelegate.h index 73efe32..2173c93 100644 --- a/WebKitTools/MiniBrowser/mac/AppDelegate.h +++ b/WebKitTools/MiniBrowser/mac/AppDelegate.h @@ -23,8 +23,14 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ +enum ProcessModel { + kProcessModelSharedSecondaryThread, + kProcessModelSharedSecondaryProcess +}; +typedef unsigned long ProcessModel; + @interface BrowserAppDelegate : NSObject <NSApplicationDelegate> { - WKProcessModel currentProcessModel; + ProcessModel currentProcessModel; WKPageNamespaceRef threadPageNamespace; WKPageNamespaceRef processPageNamespace; } diff --git a/WebKitTools/MiniBrowser/mac/AppDelegate.m b/WebKitTools/MiniBrowser/mac/AppDelegate.m index 64037fa..efc9b37 100644 --- a/WebKitTools/MiniBrowser/mac/AppDelegate.m +++ b/WebKitTools/MiniBrowser/mac/AppDelegate.m @@ -28,26 +28,53 @@ #import "BrowserWindowController.h" #import "BrowserStatisticsWindowController.h" -static NSString *defaultURL = @"http://webkit.org/"; +#import <WebKit2/WKStringCF.h> +#import <WebKit2/WKContextPrivate.h> + +static NSString *defaultURL = @"file:///Users/andersca/Desktop/t.html"; @implementation BrowserAppDelegate +void _didRecieveMessageFromInjectedBundle(WKContextRef context, WKStringRef message, const void *clientInfo) +{ + CFStringRef cfMessage = WKStringCopyCFString(0, message); + LOG(@"ContextInjectedBundleClient - didRecieveMessage - message: %@", cfMessage); + CFRelease(cfMessage); + + WKStringRef newMessage = WKStringCreateWithCFString(CFSTR("Roger that!")); + WKContextPostMessageToInjectedBundle(context, newMessage); + WKStringRelease(newMessage); +} + - (id)init { self = [super init]; if (self) { if ([NSEvent modifierFlags] & NSShiftKeyMask) - currentProcessModel = kWKProcessModelSecondaryThread; + currentProcessModel = kProcessModelSharedSecondaryThread; else - currentProcessModel = kWKProcessModelSecondaryProcess; + currentProcessModel = kProcessModelSharedSecondaryProcess; - WKContextRef threadContext = WKContextCreateWithProcessModel(kWKProcessModelSecondaryThread); + WKContextRef threadContext = WKContextGetSharedThreadContext(); threadPageNamespace = WKPageNamespaceCreate(threadContext); WKContextRelease(threadContext); - WKContextRef processContext = WKContextCreateWithProcessModel(kWKProcessModelSecondaryProcess); + CFStringRef bundlePathCF = (CFStringRef)[[NSBundle mainBundle] pathForAuxiliaryExecutable:@"WebBundle.bundle"]; + WKStringRef bundlePath = WKStringCreateWithCFString(bundlePathCF); + + WKContextRef processContext = WKContextCreateWithInjectedBundlePath(bundlePath); + + WKContextInjectedBundleClient bundleClient = { + 0, /* version */ + 0, /* clientInfo */ + _didRecieveMessageFromInjectedBundle + }; + WKContextSetInjectedBundleClient(processContext, &bundleClient); + processPageNamespace = WKPageNamespaceCreate(processContext); WKContextRelease(processContext); + + WKStringRelease(bundlePath); } return self; @@ -63,19 +90,19 @@ static NSString *defaultURL = @"http://webkit.org/"; - (WKPageNamespaceRef)getCurrentPageNamespace { - return (currentProcessModel == kWKProcessModelSecondaryThread) ? threadPageNamespace : processPageNamespace; + return (currentProcessModel == kProcessModelSharedSecondaryThread) ? threadPageNamespace : processPageNamespace; } - (BOOL)validateMenuItem:(NSMenuItem *)menuItem { if ([menuItem action] == @selector(setSharedProcessProcessModel:)) - [menuItem setState:currentProcessModel == kWKProcessModelSecondaryProcess ? NSOnState : NSOffState]; + [menuItem setState:currentProcessModel == kProcessModelSharedSecondaryProcess ? NSOnState : NSOffState]; else if ([menuItem action] == @selector(setSharedThreadProcessModel:)) - [menuItem setState:currentProcessModel == kWKProcessModelSecondaryThread ? NSOnState : NSOffState]; + [menuItem setState:currentProcessModel == kProcessModelSharedSecondaryThread ? NSOnState : NSOffState]; return YES; } -- (void)_setProcessModel:(WKProcessModel)processModel +- (void)_setProcessModel:(ProcessModel)processModel { if (processModel == currentProcessModel) return; @@ -85,12 +112,12 @@ static NSString *defaultURL = @"http://webkit.org/"; - (IBAction)setSharedProcessProcessModel:(id)sender { - [self _setProcessModel:kWKProcessModelSecondaryProcess]; + [self _setProcessModel:kProcessModelSharedSecondaryProcess]; } - (IBAction)setSharedThreadProcessModel:(id)sender { - [self _setProcessModel:kWKProcessModelSecondaryThread]; + [self _setProcessModel:kProcessModelSharedSecondaryThread]; } - (IBAction)showStatisticsWindow:(id)sender diff --git a/WebKitTools/MiniBrowser/mac/BrowserWindowController.m b/WebKitTools/MiniBrowser/mac/BrowserWindowController.m index b9306c0..11e51a0 100644 --- a/WebKitTools/MiniBrowser/mac/BrowserWindowController.m +++ b/WebKitTools/MiniBrowser/mac/BrowserWindowController.m @@ -25,6 +25,7 @@ #import "BrowserWindowController.h" +#import <WebKit2/WKPagePrivate.h> #import <WebKit2/WKStringCF.h> #import <WebKit2/WKURLCF.h> @@ -99,7 +100,7 @@ - (BOOL)windowShouldClose:(id)sender { - NSLog(@"windowShouldClose"); + LOG(@"windowShouldClose"); BOOL canCloseImmediately = WKPageTryClose(_webView.pageRef); return canCloseImmediately; } @@ -120,49 +121,49 @@ static void _didStartProvisionalLoadForFrame(WKPageRef page, WKFrameRef frame, const void *clientInfo) { - NSLog(@"didStartProvisionalLoadForFrame"); + LOG(@"didStartProvisionalLoadForFrame"); } static void _didReceiveServerRedirectForProvisionalLoadForFrame(WKPageRef page, WKFrameRef frame, const void *clientInfo) { - NSLog(@"didReceiveServerRedirectForProvisionalLoadForFrame"); + LOG(@"didReceiveServerRedirectForProvisionalLoadForFrame"); } static void _didFailProvisionalLoadWithErrorForFrame(WKPageRef page, WKFrameRef frame, const void *clientInfo) { - NSLog(@"didFailProvisionalLoadWithErrorForFrame"); + LOG(@"didFailProvisionalLoadWithErrorForFrame"); } static void _didCommitLoadForFrame(WKPageRef page, WKFrameRef frame, const void *clientInfo) { - NSLog(@"didCommitLoadForFrame"); + LOG(@"didCommitLoadForFrame"); } static void _didFinishLoadForFrame(WKPageRef page, WKFrameRef frame, const void *clientInfo) { - NSLog(@"didFinishLoadForFrame"); + LOG(@"didFinishLoadForFrame"); } static void _didFailLoadWithErrorForFrame(WKPageRef page, WKFrameRef frame, const void *clientInfo) { - NSLog(@"didFailLoadWithErrorForFrame"); + LOG(@"didFailLoadWithErrorForFrame"); } static void _didReceiveTitleForFrame(WKPageRef page, WKStringRef title, WKFrameRef frame, const void *clientInfo) { CFStringRef cfTitle = WKStringCopyCFString(0, title); - NSLog(@"didReceiveTitleForFrame \"%@\"", (NSString *)cfTitle); + LOG(@"didReceiveTitleForFrame \"%@\"", (NSString *)cfTitle); CFRelease(cfTitle); } static void _didFirstLayoutForFrame(WKPageRef page, WKFrameRef frame, const void *clientInfo) { - NSLog(@"didFirstLayoutForFrame"); + LOG(@"didFirstLayoutForFrame"); } static void _didFirstVisuallyNonEmptyLayoutForFrame(WKPageRef page, WKFrameRef frame, const void *clientInfo) { - NSLog(@"didFirstVisuallyNonEmptyLayoutForFrame"); + LOG(@"didFirstVisuallyNonEmptyLayoutForFrame"); } static void _didStartProgress(WKPageRef page, const void *clientInfo) @@ -170,9 +171,9 @@ static void _didStartProgress(WKPageRef page, const void *clientInfo) [(BrowserWindowController *)clientInfo didStartProgress]; } -static void _didChangeProgress(WKPageRef page, double value, const void *clientInfo) +static void _didChangeProgress(WKPageRef page, const void *clientInfo) { - [(BrowserWindowController *)clientInfo didChangeProgress:value]; + [(BrowserWindowController *)clientInfo didChangeProgress:WKPageGetEstimatedProgress(page)]; } static void _didFinishProgress(WKPageRef page, const void *clientInfo) @@ -182,25 +183,25 @@ static void _didFinishProgress(WKPageRef page, const void *clientInfo) static void _didBecomeUnresponsive(WKPageRef page, const void *clientInfo) { - NSLog(@"didBecomeUnresponsive"); + LOG(@"didBecomeUnresponsive"); } static void _didBecomeResponsive(WKPageRef page, const void *clientInfo) { - NSLog(@"didBecomeResponsive"); + LOG(@"didBecomeResponsive"); } #pragma mark Policy Client Callbacks static void _decidePolicyForNavigationAction(WKPageRef page, uint32_t navigationType, WKURLRef url, WKFrameRef frame, WKFramePolicyListenerRef listener, const void *clientInfo) { - NSLog(@"decidePolicyForNavigationAction"); + LOG(@"decidePolicyForNavigationAction"); WKFramePolicyListenerUse(listener); } static void _decidePolicyForNewWindowAction(WKPageRef page, uint32_t navigationType, WKURLRef url, WKFrameRef frame, WKFramePolicyListenerRef listener, const void *clientInfo) { - NSLog(@"decidePolicyForNewWindowAction"); + LOG(@"decidePolicyForNewWindowAction"); WKFramePolicyListenerUse(listener); } @@ -213,7 +214,7 @@ static void _decidePolicyForMIMEType(WKPageRef page, WKStringRef MIMEType, WKURL static WKPageRef _createNewPage(WKPageRef page, const void* clientInfo) { - NSLog(@"createNewPage"); + LOG(@"createNewPage"); BrowserWindowController *controller = [[BrowserWindowController alloc] initWithPageNamespace:WKPageGetPageNamespace(page)]; [controller loadWindow]; @@ -222,13 +223,13 @@ static WKPageRef _createNewPage(WKPageRef page, const void* clientInfo) static void _showPage(WKPageRef page, const void *clientInfo) { - NSLog(@"showPage"); + LOG(@"showPage"); [[(BrowserWindowController *)clientInfo window] orderFront:nil]; } static void _closePage(WKPageRef page, const void *clientInfo) { - NSLog(@"closePage"); + LOG(@"closePage"); WKPageClose(page); [[(BrowserWindowController *)clientInfo window] close]; WKPageRelease(page); @@ -259,7 +260,7 @@ static void _didNavigateWithNavigationData(WKPageRef page, WKNavigationDataRef n { CFStringRef title = WKStringCopyCFString(0, WKNavigationDataGetTitle(navigationData)); CFURLRef url = WKURLCopyCFURL(0, WKNavigationDataGetURL(navigationData)); - NSLog(@"HistoryClient - didNavigateWithNavigationData - title: %@ - url: %@", title, url); + LOG(@"HistoryClient - didNavigateWithNavigationData - title: %@ - url: %@", title, url); CFRelease(title); CFRelease(url); } @@ -268,7 +269,7 @@ static void _didPerformClientRedirect(WKPageRef page, WKURLRef sourceURL, WKURLR { CFURLRef cfSourceURL = WKURLCopyCFURL(0, sourceURL); CFURLRef cfDestinationURL = WKURLCopyCFURL(0, destinationURL); - NSLog(@"HistoryClient - didPerformClientRedirect - sourceURL: %@ - destinationURL: %@", cfSourceURL, cfDestinationURL); + LOG(@"HistoryClient - didPerformClientRedirect - sourceURL: %@ - destinationURL: %@", cfSourceURL, cfDestinationURL); CFRelease(cfSourceURL); CFRelease(cfDestinationURL); } @@ -277,7 +278,7 @@ static void _didPerformServerRedirect(WKPageRef page, WKURLRef sourceURL, WKURLR { CFURLRef cfSourceURL = WKURLCopyCFURL(0, sourceURL); CFURLRef cfDestinationURL = WKURLCopyCFURL(0, destinationURL); - NSLog(@"HistoryClient - didPerformServerRedirect - sourceURL: %@ - destinationURL: %@", cfSourceURL, cfDestinationURL); + LOG(@"HistoryClient - didPerformServerRedirect - sourceURL: %@ - destinationURL: %@", cfSourceURL, cfDestinationURL); CFRelease(cfSourceURL); CFRelease(cfDestinationURL); } @@ -286,7 +287,7 @@ static void _didUpdateHistoryTitle(WKPageRef page, WKStringRef title, WKURLRef U { CFStringRef cfTitle = WKStringCopyCFString(0, title); CFURLRef cfURL = WKURLCopyCFURL(0, URL); - NSLog(@"HistoryClient - didUpdateHistoryTitle - title: %@ - URL: %@", cfTitle, cfURL); + LOG(@"HistoryClient - didUpdateHistoryTitle - title: %@ - URL: %@", cfTitle, cfURL); CFRelease(cfTitle); CFRelease(cfURL); } diff --git a/WebKitTools/MiniBrowser/mac/MiniBrowser_Prefix.pch b/WebKitTools/MiniBrowser/mac/MiniBrowser_Prefix.pch index af79d0f..faa14fc 100644 --- a/WebKitTools/MiniBrowser/mac/MiniBrowser_Prefix.pch +++ b/WebKitTools/MiniBrowser/mac/MiniBrowser_Prefix.pch @@ -28,3 +28,9 @@ #endif #import <WebKit2/WebKit2.h> + +#if ENABLE_LOGGING +#define LOG NSLog +#else +#define LOG(...) ((void)0) +#endif
\ No newline at end of file diff --git a/WebKitTools/MiniBrowser/mac/WebBundle/WebBundleMain.m b/WebKitTools/MiniBrowser/mac/WebBundle/WebBundleMain.m new file mode 100644 index 0000000..f52c98e --- /dev/null +++ b/WebKitTools/MiniBrowser/mac/WebBundle/WebBundleMain.m @@ -0,0 +1,124 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include <Cocoa/Cocoa.h> +#include <WebKit2/WKBundle.h> +#include <WebKit2/WKBundleInitialize.h> +#include <WebKit2/WKBundlePage.h> +#include <WebKit2/WKString.h> +#include <WebKit2/WKStringCF.h> +#include <WebKit2/WKURLCF.h> +#include <stdio.h> + +static WKBundleRef globalBundle; + +// WKBundlePageClient + +void _didStartProvisionalLoadForFrame(WKBundlePageRef page, WKBundleFrameRef frame, const void *clientInfo) +{ +} + +void _didReceiveServerRedirectForProvisionalLoadForFrame(WKBundlePageRef page, WKBundleFrameRef frame, const void *clientInfo) +{ +} + +void _didFailProvisionalLoadWithErrorForFrame(WKBundlePageRef page, WKBundleFrameRef frame, const void *clientInfo) +{ +} + +void _didCommitLoadForFrame(WKBundlePageRef page, WKBundleFrameRef frame, const void *clientInfo) +{ +} + +void _didFinishLoadForFrame(WKBundlePageRef page, WKBundleFrameRef frame, const void *clientInfo) +{ +} + +void _didFailLoadWithErrorForFrame(WKBundlePageRef page, WKBundleFrameRef frame, const void *clientInfo) +{ +} + +void _didReceiveTitleForFrame(WKBundlePageRef page, WKStringRef title, WKBundleFrameRef frame, const void *clientInfo) +{ +} + +void _didClearWindowForFrame(WKBundlePageRef page, WKBundleFrameRef frame, JSContextRef ctx, JSObjectRef window, const void *clientInfo) +{ + CFURLRef cfURL = WKURLCopyCFURL(0, WKBundlePageGetMainFrameURL(page)); + LOG(@"WKBundlePageClient - _didClearWindowForFrame %@", [(NSURL *)cfURL absoluteString]); + CFRelease(cfURL); + + WKStringRef message = WKStringCreateWithCFString(CFSTR("Window was cleared")); + WKBundlePostMessage(globalBundle, message); + WKStringRelease(message); +} + + +// WKBundleClient + +void _didCreatePage(WKBundleRef bundle, WKBundlePageRef page, const void* clientInfo) +{ + LOG(@"WKBundleClient - didCreatePage\n"); + + WKBundlePageClient client = { + 0, + 0, + _didStartProvisionalLoadForFrame, + _didReceiveServerRedirectForProvisionalLoadForFrame, + _didFailProvisionalLoadWithErrorForFrame, + _didCommitLoadForFrame, + _didFinishLoadForFrame, + _didFailLoadWithErrorForFrame, + _didReceiveTitleForFrame, + _didClearWindowForFrame + }; + WKBundlePageSetClient(page, &client); +} + +void _willDestroyPage(WKBundleRef bundle, WKBundlePageRef page, const void* clientInfo) +{ + LOG(@"WKBundleClient - willDestroyPage\n"); +} + +void _didRecieveMessage(WKBundleRef bundle, WKStringRef message, const void *clientInfo) +{ + CFStringRef cfMessage = WKStringCopyCFString(0, message); + LOG(@"WKBundleClient - didRecieveMessage %@\n", cfMessage); + CFRelease(cfMessage); +} + +void WKBundleInitialize(WKBundleRef bundle) +{ + globalBundle = bundle; + + WKBundleClient client = { + 0, + 0, + _didCreatePage, + _willDestroyPage, + _didRecieveMessage + }; + WKBundleSetClient(bundle, &client); +} diff --git a/WebKitTools/MiniBrowser/win/BrowserView.cpp b/WebKitTools/MiniBrowser/win/BrowserView.cpp index 95385ca..49e46bf 100644 --- a/WebKitTools/MiniBrowser/win/BrowserView.cpp +++ b/WebKitTools/MiniBrowser/win/BrowserView.cpp @@ -27,6 +27,7 @@ #include "BrowserView.h" #include "BrowserWindow.h" +#include <WebKit2/WKContextPrivate.h> #include <WebKit2/WKURLCF.h> static const unsigned short HIGH_BIT_MASK_SHORT = 0x8000; @@ -66,8 +67,12 @@ void BrowserView::create(RECT webViewRect, BrowserWindow* parentWindow) bool isShiftKeyDown = ::GetKeyState(VK_SHIFT) & HIGH_BIT_MASK_SHORT; - //WKContextRef context = WKContextCreateWithProcessModel(isShiftKeyDown ? kWKProcessModelSecondaryThread : kWKProcessModelSecondaryProcess); - WKContextRef context = WKContextCreateWithProcessModel(kWKProcessModelSecondaryThread); + WKContextRef context; + if (isShiftKeyDown) + context = WKContextGetSharedThreadContext(); + else + context = WKContextGetSharedProcessContext(); + WKPageNamespaceRef pageNamespace = WKPageNamespaceCreate(context); m_webView = WKViewCreate(webViewRect, pageNamespace, parentWindow->window()); |