참고소스 수정본
@@ -0,0 +1,87 @@
|
||||
// Copyright (C) 2010-2017 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. ``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
|
||||
// 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? "../../../../Internal/Configurations/HaveInternalSDK.xcconfig"
|
||||
#include "SDKVariant.xcconfig"
|
||||
|
||||
USE_INTERNAL_SDK = $(USE_INTERNAL_SDK_$(CONFIGURATION));
|
||||
USE_INTERNAL_SDK_Production = YES;
|
||||
USE_INTERNAL_SDK_Debug = $(HAVE_INTERNAL_SDK);
|
||||
USE_INTERNAL_SDK_Release = $(HAVE_INTERNAL_SDK);
|
||||
|
||||
GCC_PREPROCESSOR_DEFINITIONS = DISABLE_LEGACY_WEBKIT_DEPRECATIONS $(inherited);
|
||||
|
||||
CLANG_CXX_LANGUAGE_STANDARD = gnu++1z;
|
||||
CLANG_CXX_LIBRARY = libc++;
|
||||
CLANG_ENABLE_OBJC_WEAK = YES;
|
||||
DEBUG_INFORMATION_FORMAT = dwarf-with-dsym;
|
||||
PREBINDING = NO
|
||||
GCC_C_LANGUAGE_STANDARD = gnu99
|
||||
GCC_ENABLE_CPP_EXCEPTIONS = NO;
|
||||
GCC_PRECOMPILE_PREFIX_HEADER = YES
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
GCC_TREAT_WARNINGS_AS_ERRORS = YES
|
||||
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_COMMA = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
GCC_WARN_ABOUT_DEPRECATED_FUNCTIONS = NO;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES
|
||||
GCC_WARN_UNUSED_VARIABLE = YES
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
||||
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
|
||||
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
|
||||
WARNING_CFLAGS = -Wall -W -Wno-unused-parameter
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
|
||||
SUPPORTED_PLATFORMS = iphoneos iphonesimulator macosx tvos tvsimulator watchos watchsimulator;
|
||||
|
||||
TARGET_MAC_OS_X_VERSION_MAJOR = $(TARGET_MAC_OS_X_VERSION_MAJOR$(MACOSX_DEPLOYMENT_TARGET:suffix:identifier));
|
||||
TARGET_MAC_OS_X_VERSION_MAJOR_13 = 101300;
|
||||
TARGET_MAC_OS_X_VERSION_MAJOR_14 = 101400;
|
||||
TARGET_MAC_OS_X_VERSION_MAJOR_15 = 101500;
|
||||
TARGET_MAC_OS_X_VERSION_MAJOR_16 = 101600;
|
||||
|
||||
SDKROOT = macosx.internal;
|
||||
|
||||
OTHER_CFLAGS = $(ASAN_OTHER_CFLAGS);
|
||||
OTHER_CPLUSPLUSFLAGS = $(ASAN_OTHER_CPLUSPLUSFLAGS);
|
||||
OTHER_LDFLAGS = $(ASAN_OTHER_LDFLAGS);
|
||||
|
||||
CODE_SIGN_IDENTITY = -;
|
||||
@@ -0,0 +1,45 @@
|
||||
// Copyright (C) 2010, 2013 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. ``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
|
||||
// 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 "Base.xcconfig"
|
||||
|
||||
ARCHS = $(ARCHS_STANDARD_32_64_BIT);
|
||||
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
|
||||
TARGET_MAC_OS_X_VERSION_MAJOR = $(MAC_OS_X_VERSION_MAJOR);
|
||||
|
||||
MACOSX_DEPLOYMENT_TARGET = $(MACOSX_DEPLOYMENT_TARGET_$(TARGET_MAC_OS_X_VERSION_MAJOR))
|
||||
MACOSX_DEPLOYMENT_TARGET_101300 = 10.13;
|
||||
MACOSX_DEPLOYMENT_TARGET_101400 = 10.14;
|
||||
MACOSX_DEPLOYMENT_TARGET_101500 = 10.15;
|
||||
MACOSX_DEPLOYMENT_TARGET_101600 = 10.16;
|
||||
|
||||
GCC_WARN_ABOUT_DEPRECATED_FUNCTIONS = YES;
|
||||
|
||||
SDKROOT = $(SDKROOT_$(USE_INTERNAL_SDK));
|
||||
SDKROOT_ = macosx;
|
||||
SDKROOT_YES = macosx.internal;
|
||||
|
||||
WK_CCACHE_DIR = $(SRCROOT)/../ccache;
|
||||
#include "../../ccache/ccache.xcconfig"
|
||||
@@ -0,0 +1,30 @@
|
||||
// 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. ``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
|
||||
// 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.
|
||||
|
||||
PRODUCT_NAME = Playwright
|
||||
PRODUCT_BUNDLE_IDENTIFIER = org.webkit.$(PRODUCT_NAME:rfc1034identifier)
|
||||
GCC_PREFIX_HEADER = mac/Playwright_Prefix.pch
|
||||
INFOPLIST_FILE = mac/Info.plist
|
||||
EXCLUDED_SOURCE_FILE_NAMES[sdk=iphone*] = *
|
||||
OTHER_LDFLAGS[sdk=macosx*] = $(inherited) -framework Cocoa -framework WebKit
|
||||
STRIP_STYLE = debugging;
|
||||
@@ -0,0 +1,45 @@
|
||||
// Copyright (C) 2019 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. ``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
|
||||
// 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.
|
||||
|
||||
WK_EMPTY_ = YES;
|
||||
WK_NOT_ = YES;
|
||||
WK_NOT_YES = NO;
|
||||
|
||||
WK_ALTERNATE_FRAMEWORKS_DIR = $(WK_ALTERNATE_FRAMEWORKS_DIR_$(SDK_VARIANT));
|
||||
WK_ALTERNATE_FRAMEWORKS_DIR_iosmac = /System/iOSSupport;
|
||||
WK_USE_ALTERNATE_FRAMEWORKS_DIR = $(WK_NOT_$(WK_EMPTY_$(WK_ALTERNATE_FRAMEWORKS_DIR)));
|
||||
|
||||
WK_ALTERNATE_PLATFORM_NAME = $(WK_ALTERNATE_PLATFORM_NAME_$(SDK_VARIANT));
|
||||
WK_ALTERNATE_PLATFORM_NAME_iosmac = maccatalyst;
|
||||
WK_USE_ALTERNATE_PLATFORM_NAME = $(WK_NOT_$(WK_EMPTY_$(WK_ALTERNATE_PLATFORM_NAME)));
|
||||
|
||||
WK_ALTERNATE_WEBKIT_SDK_PATH = $(WK_ALTERNATE_WEBKIT_SDK_PATH_$(WK_USE_ALTERNATE_FRAMEWORKS_DIR));
|
||||
WK_ALTERNATE_WEBKIT_SDK_PATH_YES = $(WK_ALTERNATE_FRAMEWORKS_DIR)/;
|
||||
|
||||
WK_PLATFORM_NAME = $(WK_PLATFORM_NAME_ALTERNATE_$(WK_USE_ALTERNATE_PLATFORM_NAME));
|
||||
WK_PLATFORM_NAME_ALTERNATE_YES = $(WK_ALTERNATE_PLATFORM_NAME);
|
||||
WK_PLATFORM_NAME_ALTERNATE_NO = $(PLATFORM_NAME);
|
||||
|
||||
EFFECTIVE_PLATFORM_NAME = $(EFFECTIVE_PLATFORM_NAME_ALTERNATE_$(WK_USE_ALTERNATE_PLATFORM_NAME));
|
||||
EFFECTIVE_PLATFORM_NAME_ALTERNATE_YES = -$(WK_ALTERNATE_PLATFORM_NAME);
|
||||
EFFECTIVE_PLATFORM_NAME_ALTERNATE_NO = $(EFFECTIVE_PLATFORM_NAME);
|
||||
@@ -0,0 +1,68 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"filename" : "logo-16.png",
|
||||
"idiom" : "mac",
|
||||
"scale" : "1x",
|
||||
"size" : "16x16"
|
||||
},
|
||||
{
|
||||
"filename" : "logo-32.png",
|
||||
"idiom" : "mac",
|
||||
"scale" : "2x",
|
||||
"size" : "16x16"
|
||||
},
|
||||
{
|
||||
"filename" : "logo-33.png",
|
||||
"idiom" : "mac",
|
||||
"scale" : "1x",
|
||||
"size" : "32x32"
|
||||
},
|
||||
{
|
||||
"filename" : "logo-64.png",
|
||||
"idiom" : "mac",
|
||||
"scale" : "2x",
|
||||
"size" : "32x32"
|
||||
},
|
||||
{
|
||||
"filename" : "logo-128.png",
|
||||
"idiom" : "mac",
|
||||
"scale" : "1x",
|
||||
"size" : "128x128"
|
||||
},
|
||||
{
|
||||
"filename" : "logo-256.png",
|
||||
"idiom" : "mac",
|
||||
"scale" : "2x",
|
||||
"size" : "128x128"
|
||||
},
|
||||
{
|
||||
"filename" : "logo-257.png",
|
||||
"idiom" : "mac",
|
||||
"scale" : "1x",
|
||||
"size" : "256x256"
|
||||
},
|
||||
{
|
||||
"filename" : "logo-512.png",
|
||||
"idiom" : "mac",
|
||||
"scale" : "2x",
|
||||
"size" : "256x256"
|
||||
},
|
||||
{
|
||||
"filename" : "logo-513.png",
|
||||
"idiom" : "mac",
|
||||
"scale" : "1x",
|
||||
"size" : "512x512"
|
||||
},
|
||||
{
|
||||
"filename" : "logo-1024.png",
|
||||
"idiom" : "mac",
|
||||
"scale" : "2x",
|
||||
"size" : "512x512"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 144 KiB |
|
After Width: | Height: | Size: 9.9 KiB |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 22 KiB |
|
After Width: | Height: | Size: 22 KiB |
|
After Width: | Height: | Size: 2.5 KiB |
|
After Width: | Height: | Size: 2.5 KiB |
|
After Width: | Height: | Size: 47 KiB |
|
After Width: | Height: | Size: 47 KiB |
|
After Width: | Height: | Size: 4.8 KiB |
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
@interface MBToolbarItem : NSToolbarItem
|
||||
@end
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#import "MBToolbarItem.h"
|
||||
|
||||
@implementation MBToolbarItem
|
||||
|
||||
- (void)validate
|
||||
{
|
||||
[self setEnabled:[[self target] validateUserInterfaceItem:self]];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,21 @@
|
||||
# Build Playwright only on SnowLeopard and later.
|
||||
|
||||
OSX_VERSION ?= $(shell sw_vers -productVersion | cut -d. -f 2)
|
||||
BUILD_PLAYWRIGHT = $(shell (( $(OSX_VERSION) >= 6 )) && echo "YES" )
|
||||
|
||||
ifeq "$(BUILD_PLAYWRIGHT)" "YES"
|
||||
|
||||
SCRIPTS_PATH = ../Scripts
|
||||
include ../../Makefile.shared
|
||||
|
||||
else
|
||||
|
||||
all: ;
|
||||
|
||||
debug d development dev develop: ;
|
||||
|
||||
release r deployment dep deploy: ;
|
||||
|
||||
clean: ;
|
||||
|
||||
endif
|
||||
@@ -0,0 +1,276 @@
|
||||
// !$*UTF8*$!
|
||||
{
|
||||
archiveVersion = 1;
|
||||
classes = {
|
||||
};
|
||||
objectVersion = 46;
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
256AC3DA0F4B6AC300CF336A /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 256AC3D90F4B6AC300CF336A /* AppDelegate.m */; };
|
||||
51E244FA11EFCE07008228D2 /* MBToolbarItem.m in Sources */ = {isa = PBXBuildFile; fileRef = 51E244F911EFCE07008228D2 /* MBToolbarItem.m */; };
|
||||
5C9332AF24C1349C0036DECF /* SecurityInterface.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5C9332AE24C1349C0036DECF /* SecurityInterface.framework */; };
|
||||
7A8E843E26858D80008EC0B1 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 7A8E843D26858D80008EC0B1 /* Images.xcassets */; };
|
||||
BC329487116A92E2008635D1 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = BC329486116A92E2008635D1 /* main.m */; };
|
||||
BC329498116A941B008635D1 /* BrowserWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = BC329497116A941B008635D1 /* BrowserWindowController.m */; };
|
||||
BC72B89511E57E07001EB4EB /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 1DDD58150DA1D0A300B3202A /* MainMenu.xib */; };
|
||||
BC72B89611E57E0F001EB4EB /* BrowserWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = BC3294A2116A9852008635D1 /* BrowserWindow.xib */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
1AFFEF761860EE6800DA465F /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; };
|
||||
1AFFEF781860EE6800DA465F /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = System/Library/Frameworks/CoreData.framework; sourceTree = SDKROOT; };
|
||||
1DDD58150DA1D0A300B3202A /* MainMenu.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = MainMenu.xib; path = mac/MainMenu.xib; sourceTree = "<group>"; };
|
||||
256AC3D80F4B6AC300CF336A /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AppDelegate.h; path = mac/AppDelegate.h; sourceTree = "<group>"; };
|
||||
256AC3D90F4B6AC300CF336A /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AppDelegate.m; path = mac/AppDelegate.m; sourceTree = "<group>"; };
|
||||
256AC3F00F4B6AF500CF336A /* Playwright_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Playwright_Prefix.pch; path = mac/Playwright_Prefix.pch; sourceTree = "<group>"; };
|
||||
29B97324FDCFA39411CA2CEB /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = "<absolute>"; };
|
||||
29B97325FDCFA39411CA2CEB /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = "<absolute>"; };
|
||||
37BAF90620218053000EA87A /* Playwright.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Playwright.entitlements; sourceTree = "<group>"; };
|
||||
51E244F811EFCE07008228D2 /* MBToolbarItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MBToolbarItem.h; sourceTree = "<group>"; };
|
||||
51E244F911EFCE07008228D2 /* MBToolbarItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MBToolbarItem.m; sourceTree = "<group>"; };
|
||||
5C9332AE24C1349C0036DECF /* SecurityInterface.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SecurityInterface.framework; path = System/Library/Frameworks/SecurityInterface.framework; sourceTree = SDKROOT; };
|
||||
7A8E843D26858D80008EC0B1 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = "<group>"; };
|
||||
8D1107320486CEB800E47091 /* Playwright.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Playwright.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
A1B89B95221E027A00EB4CEB /* SDKVariant.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = SDKVariant.xcconfig; sourceTree = "<group>"; };
|
||||
BC329486116A92E2008635D1 /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = mac/main.m; sourceTree = "<group>"; };
|
||||
BC329496116A941B008635D1 /* BrowserWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BrowserWindowController.h; path = mac/BrowserWindowController.h; sourceTree = "<group>"; };
|
||||
BC329497116A941B008635D1 /* BrowserWindowController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = BrowserWindowController.m; path = mac/BrowserWindowController.m; sourceTree = "<group>"; };
|
||||
BC3294A2116A9852008635D1 /* BrowserWindow.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = BrowserWindow.xib; path = mac/BrowserWindow.xib; sourceTree = "<group>"; };
|
||||
BC72B89A11E57E8A001EB4EB /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = mac/Info.plist; sourceTree = "<group>"; };
|
||||
BCA8CBDD11E578A000812FB8 /* Base.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Base.xcconfig; sourceTree = "<group>"; };
|
||||
BCA8CBDE11E578A000812FB8 /* DebugRelease.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = DebugRelease.xcconfig; sourceTree = "<group>"; };
|
||||
BCA8CBDF11E578A000812FB8 /* Playwright.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Playwright.xcconfig; sourceTree = "<group>"; };
|
||||
F393B1A6286A71AE007B8F61 /* WebKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = WebKit.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
8D11072E0486CEB800E47091 /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
5C9332AF24C1349C0036DECF /* SecurityInterface.framework in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXFrameworksBuildPhase section */
|
||||
|
||||
/* Begin PBXGroup section */
|
||||
080E96DDFE201D6D7F000002 /* Playwright */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
256AC3D80F4B6AC300CF336A /* AppDelegate.h */,
|
||||
256AC3D90F4B6AC300CF336A /* AppDelegate.m */,
|
||||
BC329496116A941B008635D1 /* BrowserWindowController.h */,
|
||||
BC329497116A941B008635D1 /* BrowserWindowController.m */,
|
||||
7A8E843D26858D80008EC0B1 /* Images.xcassets */,
|
||||
BC72B89A11E57E8A001EB4EB /* Info.plist */,
|
||||
BC329486116A92E2008635D1 /* main.m */,
|
||||
51E244F811EFCE07008228D2 /* MBToolbarItem.h */,
|
||||
51E244F911EFCE07008228D2 /* MBToolbarItem.m */,
|
||||
37BAF90620218053000EA87A /* Playwright.entitlements */,
|
||||
);
|
||||
name = Playwright;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
1058C7A2FEA54F0111CA2CBC /* Other Frameworks */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
29B97324FDCFA39411CA2CEB /* AppKit.framework */,
|
||||
1AFFEF781860EE6800DA465F /* CoreData.framework */,
|
||||
29B97325FDCFA39411CA2CEB /* Foundation.framework */,
|
||||
);
|
||||
name = "Other Frameworks";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
19C28FACFE9D520D11CA2CBC /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
8D1107320486CEB800E47091 /* Playwright.app */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
29B97314FDCFA39411CA2CEB /* Playwright */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
256AC3F00F4B6AF500CF336A /* Playwright_Prefix.pch */,
|
||||
080E96DDFE201D6D7F000002 /* Playwright */,
|
||||
29B97317FDCFA39411CA2CEB /* Resources */,
|
||||
BCA8CBDA11E5787800812FB8 /* Configurations */,
|
||||
29B97323FDCFA39411CA2CEB /* Frameworks */,
|
||||
19C28FACFE9D520D11CA2CBC /* Products */,
|
||||
);
|
||||
name = Playwright;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
29B97317FDCFA39411CA2CEB /* Resources */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
BC3294A2116A9852008635D1 /* BrowserWindow.xib */,
|
||||
1DDD58150DA1D0A300B3202A /* MainMenu.xib */,
|
||||
);
|
||||
name = Resources;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
29B97323FDCFA39411CA2CEB /* Frameworks */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
1058C7A2FEA54F0111CA2CBC /* Other Frameworks */,
|
||||
1AFFEF761860EE6800DA465F /* Cocoa.framework */,
|
||||
5C9332AE24C1349C0036DECF /* SecurityInterface.framework */,
|
||||
F393B1A6286A71AE007B8F61 /* WebKit.framework */,
|
||||
);
|
||||
name = Frameworks;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
BCA8CBDA11E5787800812FB8 /* Configurations */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
BCA8CBDD11E578A000812FB8 /* Base.xcconfig */,
|
||||
BCA8CBDE11E578A000812FB8 /* DebugRelease.xcconfig */,
|
||||
BCA8CBDF11E578A000812FB8 /* Playwright.xcconfig */,
|
||||
A1B89B95221E027A00EB4CEB /* SDKVariant.xcconfig */,
|
||||
);
|
||||
path = Configurations;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXGroup section */
|
||||
|
||||
/* Begin PBXNativeTarget section */
|
||||
8D1107260486CEB800E47091 /* Playwright */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = C01FCF4A08A954540054247C /* Build configuration list for PBXNativeTarget "Playwright" */;
|
||||
buildPhases = (
|
||||
8D1107290486CEB800E47091 /* Resources */,
|
||||
8D11072C0486CEB800E47091 /* Sources */,
|
||||
8D11072E0486CEB800E47091 /* Frameworks */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
);
|
||||
name = Playwright;
|
||||
productInstallPath = "$(HOME)/Applications";
|
||||
productName = Playwright;
|
||||
productReference = 8D1107320486CEB800E47091 /* Playwright.app */;
|
||||
productType = "com.apple.product-type.application";
|
||||
};
|
||||
/* End PBXNativeTarget section */
|
||||
|
||||
/* Begin PBXProject section */
|
||||
29B97313FDCFA39411CA2CEC /* Project object */ = {
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
LastSwiftUpdateCheck = 0700;
|
||||
LastUpgradeCheck = 1000;
|
||||
TargetAttributes = {
|
||||
8D1107260486CEB800E47091 = {
|
||||
SystemCapabilities = {
|
||||
com.apple.Sandbox = {
|
||||
enabled = 1;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "Playwright" */;
|
||||
compatibilityVersion = "Xcode 3.2";
|
||||
developmentRegion = en;
|
||||
hasScannedForEncodings = 1;
|
||||
knownRegions = (
|
||||
en,
|
||||
);
|
||||
mainGroup = 29B97314FDCFA39411CA2CEB /* Playwright */;
|
||||
projectDirPath = "";
|
||||
projectRoot = "";
|
||||
targets = (
|
||||
8D1107260486CEB800E47091 /* Playwright */,
|
||||
);
|
||||
};
|
||||
/* End PBXProject section */
|
||||
|
||||
/* Begin PBXResourcesBuildPhase section */
|
||||
8D1107290486CEB800E47091 /* Resources */ = {
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
BC72B89611E57E0F001EB4EB /* BrowserWindow.xib in Resources */,
|
||||
7A8E843E26858D80008EC0B1 /* Images.xcassets in Resources */,
|
||||
BC72B89511E57E07001EB4EB /* MainMenu.xib in Resources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXResourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXSourcesBuildPhase section */
|
||||
8D11072C0486CEB800E47091 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
256AC3DA0F4B6AC300CF336A /* AppDelegate.m in Sources */,
|
||||
BC329498116A941B008635D1 /* BrowserWindowController.m in Sources */,
|
||||
BC329487116A92E2008635D1 /* main.m in Sources */,
|
||||
51E244FA11EFCE07008228D2 /* MBToolbarItem.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXSourcesBuildPhase section */
|
||||
|
||||
/* Begin XCBuildConfiguration section */
|
||||
C01FCF4B08A954540054247C /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = BCA8CBDF11E578A000812FB8 /* Playwright.xcconfig */;
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
C01FCF4C08A954540054247B /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = BCA8CBDF11E578A000812FB8 /* Playwright.xcconfig */;
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
C01FCF4F08A954540054247C /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = BCA8CBDE11E578A000812FB8 /* DebugRelease.xcconfig */;
|
||||
buildSettings = {
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
C01FCF5008A954540054247C /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = BCA8CBDE11E578A000812FB8 /* DebugRelease.xcconfig */;
|
||||
buildSettings = {
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
/* End XCBuildConfiguration section */
|
||||
|
||||
/* Begin XCConfigurationList section */
|
||||
C01FCF4A08A954540054247C /* Build configuration list for PBXNativeTarget "Playwright" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
C01FCF4B08A954540054247C /* Debug */,
|
||||
C01FCF4C08A954540054247B /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
C01FCF4E08A954540054247B /* Build configuration list for PBXProject "Playwright" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
C01FCF4F08A954540054247C /* Debug */,
|
||||
C01FCF5008A954540054247C /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
/* End XCConfigurationList section */
|
||||
};
|
||||
rootObject = 29B97313FDCFA39411CA2CEC /* Project object */;
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "1140"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
buildImplicitDependencies = "YES">
|
||||
<BuildActionEntries>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "8D1107260486CEB800E47090"
|
||||
BuildableName = "Playwright.app"
|
||||
BlueprintName = "Playwright"
|
||||
ReferencedContainer = "container:Playwright.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
</BuildActionEntries>
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||
<Testables>
|
||||
</Testables>
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
debugServiceExtension = "internal"
|
||||
allowLocationSimulation = "YES">
|
||||
<BuildableProductRunnable
|
||||
runnableDebuggingMode = "0">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "8D1107260486CEB800E47090"
|
||||
BuildableName = "Playwright.app"
|
||||
BlueprintName = "Playwright"
|
||||
ReferencedContainer = "container:Playwright.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildableProductRunnable>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
buildConfiguration = "Release"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
debugDocumentVersioning = "YES">
|
||||
<BuildableProductRunnable
|
||||
runnableDebuggingMode = "0">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "8D1107260486CEB800E47090"
|
||||
BuildableName = "Playwright.app"
|
||||
BlueprintName = "Playwright"
|
||||
ReferencedContainer = "container:Playwright.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildableProductRunnable>
|
||||
</ProfileAction>
|
||||
<AnalyzeAction
|
||||
buildConfiguration = "Debug">
|
||||
</AnalyzeAction>
|
||||
<ArchiveAction
|
||||
buildConfiguration = "Release"
|
||||
revealArchiveInOrganizer = "YES">
|
||||
</ArchiveAction>
|
||||
</Scheme>
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#import <WebKit/_WKBrowserInspector.h>
|
||||
#import <WebKit/_WKDownloadDelegate.h>
|
||||
|
||||
@interface WebViewDialog : NSObject
|
||||
@property (nonatomic, strong) WKWebView *webView;
|
||||
@property (nonatomic, copy) void (^completionHandler)(BOOL accept, NSString* value);
|
||||
@end
|
||||
|
||||
@interface BrowserAppDelegate : NSObject <NSApplicationDelegate, WKNavigationDelegate, WKUIDelegate, _WKBrowserInspectorDelegate, WKDownloadDelegate> {
|
||||
NSMutableSet *_headlessWindows;
|
||||
NSMutableSet *_browserContexts;
|
||||
bool _headless;
|
||||
bool _noStartupWindow;
|
||||
bool _inspectorPipe;
|
||||
NSMutableSet *_dialogs;
|
||||
NSString* _initialURL;
|
||||
NSString* _userDataDir;
|
||||
NSString* _proxyServer;
|
||||
NSString* _proxyBypassList;
|
||||
IBOutlet NSMenuItem *_newWebKit2WindowItem;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@interface NSApplication (PlaywrightApplicationExtensions)
|
||||
|
||||
- (BrowserAppDelegate *)browserAppDelegate;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,544 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2016 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.
|
||||
*/
|
||||
|
||||
#import "AppDelegate.h"
|
||||
|
||||
#import "BrowserWindowController.h"
|
||||
#import <WebKit/WKNavigationActionPrivate.h>
|
||||
#import <WebKit/WKNavigationDelegatePrivate.h>
|
||||
#import <WebKit/WKPreferencesPrivate.h>
|
||||
#import <WebKit/WKProcessPoolPrivate.h>
|
||||
#import <WebKit/WKUserContentControllerPrivate.h>
|
||||
#import <WebKit/WKWebViewConfigurationPrivate.h>
|
||||
#import <WebKit/WKWebViewPrivate.h>
|
||||
#import <WebKit/WKWebpagePreferencesPrivate.h>
|
||||
#import <WebKit/WKWebsiteDataStorePrivate.h>
|
||||
#import <WebKit/WebNSURLExtras.h>
|
||||
#import <WebKit/WebKit.h>
|
||||
#import <WebKit/_WKDownload.h>
|
||||
#import <WebKit/_WKExperimentalFeature.h>
|
||||
#import <WebKit/_WKInternalDebugFeature.h>
|
||||
#import <WebKit/_WKProcessPoolConfiguration.h>
|
||||
#import <WebKit/_WKWebsiteDataStoreConfiguration.h>
|
||||
|
||||
@implementation NSApplication (PlaywrightApplicationExtensions)
|
||||
|
||||
- (BrowserAppDelegate *)browserAppDelegate
|
||||
{
|
||||
return (BrowserAppDelegate *)[self delegate];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@interface NSApplication (TouchBar)
|
||||
@property (getter=isAutomaticCustomizeTouchBarMenuItemEnabled) BOOL automaticCustomizeTouchBarMenuItemEnabled;
|
||||
|
||||
@property (readonly, nonatomic) WKWebViewConfiguration *defaultConfiguration;
|
||||
|
||||
@end
|
||||
|
||||
@implementation WebViewDialog
|
||||
- (void)dealloc
|
||||
{
|
||||
[_webView release];
|
||||
_webView = nil;
|
||||
[super dealloc];
|
||||
}
|
||||
@end
|
||||
|
||||
enum {
|
||||
_NSBackingStoreUnbuffered = 3
|
||||
};
|
||||
|
||||
NSString* const ActivityReason = @"Batch headless process";
|
||||
const NSActivityOptions ActivityOptions =
|
||||
(NSActivityUserInitiatedAllowingIdleSystemSleep |
|
||||
NSActivityLatencyCritical) &
|
||||
~(NSActivitySuddenTerminationDisabled |
|
||||
NSActivityAutomaticTerminationDisabled);
|
||||
|
||||
@implementation BrowserAppDelegate
|
||||
|
||||
- (id)init
|
||||
{
|
||||
self = [super init];
|
||||
|
||||
if (!self)
|
||||
return nil;
|
||||
|
||||
_initialURL = nil;
|
||||
_userDataDir = nil;
|
||||
_proxyServer = nil;
|
||||
_proxyBypassList = nil;
|
||||
NSArray *arguments = [[NSProcessInfo processInfo] arguments];
|
||||
NSRange subargs = NSMakeRange(1, [arguments count] - 1);
|
||||
NSArray *subArray = [arguments subarrayWithRange:subargs];
|
||||
|
||||
for (NSString *argument in subArray) {
|
||||
if (![argument hasPrefix:@"--"])
|
||||
_initialURL = [argument copy];
|
||||
if ([argument hasPrefix:@"--user-data-dir="]) {
|
||||
NSRange range = NSMakeRange(16, [argument length] - 16);
|
||||
_userDataDir = [[argument substringWithRange:range] copy];
|
||||
}
|
||||
if ([argument hasPrefix:@"--proxy="]) {
|
||||
NSRange range = NSMakeRange(8, [argument length] - 8);
|
||||
_proxyServer = [[argument substringWithRange:range] copy];
|
||||
}
|
||||
if ([argument hasPrefix:@"--proxy-bypass-list="]) {
|
||||
NSRange range = NSMakeRange(20, [argument length] - 20);
|
||||
_proxyBypassList = [[argument substringWithRange:range] copy];
|
||||
}
|
||||
}
|
||||
|
||||
_headless = [arguments containsObject: @"--headless"];
|
||||
_noStartupWindow = [arguments containsObject: @"--no-startup-window"];
|
||||
_inspectorPipe = [arguments containsObject: @"--inspector-pipe"];
|
||||
_browserContexts = [[NSMutableSet alloc] init];
|
||||
|
||||
if (_headless) {
|
||||
_headlessWindows = [[NSMutableSet alloc] init];
|
||||
[NSApp setActivationPolicy:NSApplicationActivationPolicyAccessory];
|
||||
[[NSProcessInfo processInfo] beginActivityWithOptions:ActivityOptions
|
||||
reason:ActivityReason];
|
||||
_dialogs = [[NSMutableSet alloc] init];
|
||||
} else {
|
||||
[NSApp activateIgnoringOtherApps:YES];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)awakeFromNib
|
||||
{
|
||||
if ([NSApp respondsToSelector:@selector(setAutomaticCustomizeTouchBarMenuItemEnabled:)])
|
||||
[NSApp setAutomaticCustomizeTouchBarMenuItemEnabled:YES];
|
||||
}
|
||||
|
||||
|
||||
- (NSDictionary *)proxyConfiguration:(NSString *)proxyServer WithBypassList:(NSString *)proxyBypassList
|
||||
{
|
||||
if (!proxyServer || ![proxyServer length])
|
||||
return nil;
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
|
||||
NSMutableDictionary *dictionary = [[[NSMutableDictionary alloc] init] autorelease];
|
||||
NSURL *proxyURL = [NSURL URLWithString:proxyServer];
|
||||
NSString *host = [proxyURL host];
|
||||
NSNumber *port = [proxyURL port];
|
||||
if ([proxyServer hasPrefix:@"socks5://"]) {
|
||||
[dictionary setObject:host forKey:(NSString *)kCFStreamPropertySOCKSProxyHost];
|
||||
if (port)
|
||||
[dictionary setObject:port forKey:(NSString *)kCFStreamPropertySOCKSProxyPort];
|
||||
} else {
|
||||
[dictionary setObject:host forKey:(NSString *)kCFStreamPropertyHTTPSProxyHost];
|
||||
[dictionary setObject:host forKey:(NSString *)kCFStreamPropertyHTTPProxyHost];
|
||||
if (port) {
|
||||
[dictionary setObject:port forKey:(NSString *)kCFStreamPropertyHTTPSProxyPort];
|
||||
[dictionary setObject:port forKey:(NSString *)kCFStreamPropertyHTTPProxyPort];
|
||||
}
|
||||
}
|
||||
|
||||
if (proxyBypassList && [proxyBypassList length]) {
|
||||
NSArray* bypassList = [proxyBypassList componentsSeparatedByString:@","];
|
||||
[dictionary setObject:bypassList forKey:@"ExceptionsList"];
|
||||
}
|
||||
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
return dictionary;
|
||||
}
|
||||
|
||||
- (WKWebsiteDataStore *)persistentDataStore
|
||||
{
|
||||
static WKWebsiteDataStore *dataStore;
|
||||
|
||||
if (!dataStore) {
|
||||
_WKWebsiteDataStoreConfiguration *configuration = [[[_WKWebsiteDataStoreConfiguration alloc] init] autorelease];
|
||||
if (_userDataDir) {
|
||||
// Local storage state should be stored in separate dirs for persistent contexts.
|
||||
[configuration setUnifiedOriginStorageLevel:_WKUnifiedOriginStorageLevelNone];
|
||||
|
||||
NSURL *cookieFile = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/cookie.db", _userDataDir]];
|
||||
[configuration _setCookieStorageFile:cookieFile];
|
||||
|
||||
NSURL *cacheStorageDirectory = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/CacheStorage", _userDataDir]];
|
||||
[configuration _setCacheStorageDirectory:cacheStorageDirectory];
|
||||
|
||||
NSURL *indexedDBDirectory = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/IndexedDB", _userDataDir]];
|
||||
[configuration _setIndexedDBDatabaseDirectory:indexedDBDirectory];
|
||||
|
||||
NSURL *localStorageDirectory = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/LocalStorage", _userDataDir]];
|
||||
[configuration _setWebStorageDirectory:localStorageDirectory];
|
||||
|
||||
NSURL *mediaCacheDirectory = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/MediaCache", _userDataDir]];
|
||||
[configuration setMediaCacheDirectory:mediaCacheDirectory];
|
||||
|
||||
NSURL *mediaKeysDirectory = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/MediaKeys", _userDataDir]];
|
||||
[configuration setMediaKeysStorageDirectory:mediaKeysDirectory];
|
||||
|
||||
NSURL *networkCacheDirectory = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/NetworkCache", _userDataDir]];
|
||||
[configuration setNetworkCacheDirectory:networkCacheDirectory];
|
||||
|
||||
NSURL *loadStatsDirectory = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/ResourceLoadStatistics", _userDataDir]];
|
||||
[configuration _setResourceLoadStatisticsDirectory:loadStatsDirectory];
|
||||
|
||||
NSURL *serviceWorkersDirectory = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/ServiceWorkers", _userDataDir]];
|
||||
[configuration _setServiceWorkerRegistrationDirectory:serviceWorkersDirectory];
|
||||
|
||||
NSURL *webSqlDirectory = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/WebSQL", _userDataDir]];
|
||||
[configuration _setWebSQLDatabaseDirectory:webSqlDirectory];
|
||||
}
|
||||
[configuration setProxyConfiguration:[self proxyConfiguration:_proxyServer WithBypassList:_proxyBypassList]];
|
||||
dataStore = [[WKWebsiteDataStore alloc] _initWithConfiguration:configuration];
|
||||
}
|
||||
|
||||
return dataStore;
|
||||
}
|
||||
|
||||
- (WKWebViewConfiguration *)defaultConfiguration
|
||||
{
|
||||
static WKWebViewConfiguration *configuration;
|
||||
|
||||
if (!configuration) {
|
||||
configuration = [[WKWebViewConfiguration alloc] init];
|
||||
configuration.websiteDataStore = [self persistentDataStore];
|
||||
configuration._controlledByAutomation = true;
|
||||
configuration.preferences.elementFullscreenEnabled = YES;
|
||||
configuration.preferences._developerExtrasEnabled = YES;
|
||||
configuration.preferences._mediaDevicesEnabled = YES;
|
||||
configuration.preferences._mockCaptureDevicesEnabled = YES;
|
||||
// Enable WebM support.
|
||||
configuration.preferences._hiddenPageDOMTimerThrottlingEnabled = NO;
|
||||
configuration.preferences._hiddenPageDOMTimerThrottlingAutoIncreases = NO;
|
||||
configuration.preferences._pageVisibilityBasedProcessSuppressionEnabled = NO;
|
||||
configuration.preferences._domTimersThrottlingEnabled = NO;
|
||||
// Do not auto play audio and video with sound.
|
||||
configuration.defaultWebpagePreferences._autoplayPolicy = _WKWebsiteAutoplayPolicyAllowWithoutSound;
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
_WKProcessPoolConfiguration *processConfiguration = [[[_WKProcessPoolConfiguration alloc] init] autorelease];
|
||||
processConfiguration.forceOverlayScrollbars = YES;
|
||||
configuration.processPool = [[[WKProcessPool alloc] _initWithConfiguration:processConfiguration] autorelease];
|
||||
#pragma clang diagnostic pop
|
||||
}
|
||||
return configuration;
|
||||
}
|
||||
|
||||
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
|
||||
{
|
||||
if (!_headless)
|
||||
[self _updateNewWindowKeyEquivalents];
|
||||
|
||||
if (_inspectorPipe)
|
||||
[_WKBrowserInspector initializeRemoteInspectorPipe:self headless:_headless];
|
||||
|
||||
if (_noStartupWindow)
|
||||
return;
|
||||
|
||||
// Force creation of the default browser context.
|
||||
[self defaultConfiguration];
|
||||
// Creating the first NSWindow immediately makes it invisible in headless mode,
|
||||
// so we postpone it for 50ms. Experiments show that 10ms is not enough, and 20ms is enough.
|
||||
// We give it 50ms just in case.
|
||||
[NSTimer scheduledTimerWithTimeInterval: 0.05
|
||||
repeats: NO
|
||||
block:(void *)^(NSTimer* timer)
|
||||
{
|
||||
[self createNewPage:0 withURL:_initialURL ? _initialURL : @"about:blank"];
|
||||
_initialURL = nil;
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)_updateNewWindowKeyEquivalents
|
||||
{
|
||||
NSString *normalWindowEquivalent = @"n";
|
||||
_newWebKit2WindowItem.keyEquivalentModifierMask = NSEventModifierFlagCommand;
|
||||
_newWebKit2WindowItem.keyEquivalent = normalWindowEquivalent;
|
||||
}
|
||||
|
||||
#pragma mark WKBrowserInspectorDelegate
|
||||
|
||||
- (WKWebViewConfiguration *) sessionConfiguration:(uint64_t)sessionID
|
||||
{
|
||||
for (_WKBrowserContext *browserContext in _browserContexts) {
|
||||
if ([[browserContext dataStore] sessionID] != sessionID)
|
||||
continue;
|
||||
WKWebViewConfiguration *configuration = [[[self defaultConfiguration] copy] autorelease];
|
||||
configuration.websiteDataStore = [browserContext dataStore];
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
configuration.processPool = [browserContext processPool];
|
||||
#pragma clang diagnostic pop
|
||||
return configuration;
|
||||
}
|
||||
return [self defaultConfiguration];
|
||||
}
|
||||
|
||||
- (WKWebView *)createNewPage:(uint64_t)sessionID
|
||||
{
|
||||
return [self createNewPage:sessionID withURL:@"about:blank"];
|
||||
}
|
||||
|
||||
- (WKWebView *)createNewPage:(uint64_t)sessionID withURL:(NSString*)urlString
|
||||
{
|
||||
WKWebViewConfiguration *configuration = [self sessionConfiguration:sessionID];
|
||||
if (_headless)
|
||||
return [self createHeadlessPage:configuration withURL:urlString];
|
||||
return [self createHeadfulPage:configuration withURL:urlString];
|
||||
}
|
||||
|
||||
- (WKWebView *)createHeadfulPage:(WKWebViewConfiguration *)configuration withURL:(NSString*)urlString
|
||||
{
|
||||
// WebView lifecycle will control the BrowserWindowController life times.
|
||||
BrowserWindowController *controller = [[BrowserWindowController alloc] initWithConfiguration:configuration];
|
||||
if (!controller)
|
||||
return nil;
|
||||
[controller loadURLString:urlString];
|
||||
NSWindow *window = controller.window;
|
||||
[window setIsVisible:YES];
|
||||
return [controller webView];
|
||||
}
|
||||
|
||||
- (WKWebView *)createHeadlessPage:(WKWebViewConfiguration *)configuration withURL:(NSString*)urlString
|
||||
{
|
||||
NSRect rect = NSMakeRect(0, 0, 1280, 720);
|
||||
|
||||
// https://github.com/microsoft/playwright/issues/36711
|
||||
// https://codereview.chromium.org/1380083005
|
||||
NSScreen *firstScreen = [[NSScreen screens] firstObject];
|
||||
|
||||
NSRect windowRect = firstScreen ? NSOffsetRect(rect, -10000, [firstScreen frame].size.height - rect.size.height + 10000) : rect;
|
||||
NSWindow* window = [[NSWindow alloc] initWithContentRect:windowRect styleMask:NSWindowStyleMaskBorderless backing:(NSBackingStoreType)_NSBackingStoreUnbuffered defer:YES];
|
||||
|
||||
WKWebView* webView = [[WKWebView alloc] initWithFrame:[window.contentView bounds] configuration:configuration];
|
||||
if (!webView)
|
||||
return nil;
|
||||
|
||||
webView._windowOcclusionDetectionEnabled = NO;
|
||||
webView.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable;
|
||||
[window.contentView addSubview:webView];
|
||||
[window setIsVisible:YES];
|
||||
if (urlString) {
|
||||
NSURL *url = [NSURL _webkit_URLWithUserTypedString:urlString];
|
||||
[webView loadRequest:[NSURLRequest requestWithURL:url]];
|
||||
}
|
||||
[_headlessWindows addObject:window];
|
||||
webView.navigationDelegate = self;
|
||||
webView.UIDelegate = self;
|
||||
return [webView autorelease];
|
||||
}
|
||||
|
||||
- (_WKBrowserContext *)createBrowserContext:(NSString *)proxyServer WithBypassList:(NSString *) proxyBypassList
|
||||
{
|
||||
_WKBrowserContext *browserContext = [[_WKBrowserContext alloc] init];
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
_WKProcessPoolConfiguration *processConfiguration = [[[_WKProcessPoolConfiguration alloc] init] autorelease];
|
||||
processConfiguration.forceOverlayScrollbars = YES;
|
||||
#pragma clang diagnostic pop
|
||||
_WKWebsiteDataStoreConfiguration *dataStoreConfiguration = [[[_WKWebsiteDataStoreConfiguration alloc] initNonPersistentConfiguration] autorelease];
|
||||
if (!proxyServer || ![proxyServer length])
|
||||
proxyServer = _proxyServer;
|
||||
if (!proxyBypassList || ![proxyBypassList length])
|
||||
proxyBypassList = _proxyBypassList;
|
||||
[dataStoreConfiguration setProxyConfiguration:[self proxyConfiguration:proxyServer WithBypassList:proxyBypassList]];
|
||||
browserContext.dataStore = [[[WKWebsiteDataStore alloc] _initWithConfiguration:dataStoreConfiguration] autorelease];
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
browserContext.processPool = [[[WKProcessPool alloc] _initWithConfiguration:processConfiguration] autorelease];
|
||||
#pragma clang diagnostic pop
|
||||
[_browserContexts addObject:browserContext];
|
||||
return browserContext;
|
||||
}
|
||||
|
||||
- (void)deleteBrowserContext:(uint64_t)sessionID
|
||||
{
|
||||
for (_WKBrowserContext *browserContext in _browserContexts) {
|
||||
if ([[browserContext dataStore] sessionID] != sessionID)
|
||||
continue;
|
||||
[_browserContexts removeObject:browserContext];
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)quit
|
||||
{
|
||||
[NSApp performSelector:@selector(terminate:) withObject:nil afterDelay:0.0];
|
||||
}
|
||||
|
||||
#pragma mark WKUIDelegate
|
||||
|
||||
- (void)webViewDidClose:(WKWebView *)webView {
|
||||
[self webView:webView handleJavaScriptDialog:false value:nil];
|
||||
for (NSWindow *window in _headlessWindows) {
|
||||
if (webView.window != window)
|
||||
continue;
|
||||
[webView removeFromSuperview];
|
||||
[window close];
|
||||
[_headlessWindows removeObject:window];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)_webView:(WKWebView *)webView getWindowFrameWithCompletionHandler:(void (^)(CGRect))completionHandler
|
||||
{
|
||||
completionHandler([webView.window frame]);
|
||||
}
|
||||
|
||||
- (void)webView:(WKWebView *)webView runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)(void))completionHandler
|
||||
{
|
||||
WebViewDialog* dialog = [[WebViewDialog alloc] autorelease];
|
||||
dialog.webView = webView;
|
||||
dialog.completionHandler = ^void (BOOL accept, NSString* value) {
|
||||
completionHandler();
|
||||
};
|
||||
[_dialogs addObject:dialog];
|
||||
}
|
||||
|
||||
- (void)webView:(WKWebView *)webView runJavaScriptConfirmPanelWithMessage:(NSString *)message initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)(BOOL result))completionHandler
|
||||
{
|
||||
WebViewDialog* dialog = [[WebViewDialog alloc] autorelease];
|
||||
dialog.webView = webView;
|
||||
dialog.completionHandler = ^void (BOOL accept, NSString* value) {
|
||||
completionHandler(accept);
|
||||
};
|
||||
[_dialogs addObject:dialog];
|
||||
}
|
||||
|
||||
- (void)webView:(WKWebView *)webView runJavaScriptTextInputPanelWithPrompt:(NSString *)prompt defaultText:(NSString *)defaultText initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)(NSString *result))completionHandler
|
||||
{
|
||||
WebViewDialog* dialog = [[WebViewDialog alloc] autorelease];
|
||||
dialog.webView = webView;
|
||||
dialog.completionHandler = ^void (BOOL accept, NSString* value) {
|
||||
completionHandler(accept && value ? value : nil);
|
||||
};
|
||||
[_dialogs addObject:dialog];
|
||||
}
|
||||
|
||||
- (void)_webView:(WKWebView *)webView runBeforeUnloadConfirmPanelWithMessage:(NSString *)message initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)(BOOL result))completionHandler
|
||||
{
|
||||
WebViewDialog* dialog = [[WebViewDialog alloc] autorelease];
|
||||
dialog.webView = webView;
|
||||
dialog.completionHandler = ^void (BOOL accept, NSString* value) {
|
||||
completionHandler(accept);
|
||||
};
|
||||
[_dialogs addObject:dialog];
|
||||
}
|
||||
|
||||
- (void)webView:(WKWebView *)webView handleJavaScriptDialog:(BOOL)accept value:(NSString *)value
|
||||
{
|
||||
for (WebViewDialog *dialog in _dialogs) {
|
||||
if (dialog.webView != webView)
|
||||
continue;
|
||||
dialog.completionHandler(accept, value);
|
||||
[_dialogs removeObject:dialog];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
- (nullable WKWebView *)webView:(WKWebView *)webView createWebViewWithConfiguration:(WKWebViewConfiguration *)configuration forNavigationAction:(WKNavigationAction *)navigationAction windowFeatures:(WKWindowFeatures *)windowFeatures
|
||||
{
|
||||
return [self createHeadlessPage:configuration withURL:nil];
|
||||
}
|
||||
|
||||
- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler
|
||||
{
|
||||
LOG(@"decidePolicyForNavigationAction");
|
||||
|
||||
if (navigationAction.shouldPerformDownload) {
|
||||
decisionHandler(WKNavigationActionPolicyDownload);
|
||||
return;
|
||||
}
|
||||
|
||||
if (navigationAction.buttonNumber == 1 &&
|
||||
(navigationAction.modifierFlags & (NSEventModifierFlagCommand | NSEventModifierFlagShift)) != 0) {
|
||||
WKWindowFeatures* windowFeatures = [[[WKWindowFeatures alloc] init] autorelease];
|
||||
WKWebView* newView = [self webView:webView createWebViewWithConfiguration:webView.configuration forNavigationAction:navigationAction windowFeatures:windowFeatures];
|
||||
[newView loadRequest:navigationAction.request];
|
||||
decisionHandler(WKNavigationActionPolicyCancel);
|
||||
return;
|
||||
}
|
||||
|
||||
if (navigationAction._canHandleRequest) {
|
||||
decisionHandler(WKNavigationActionPolicyAllow);
|
||||
return;
|
||||
}
|
||||
decisionHandler(WKNavigationActionPolicyCancel);
|
||||
}
|
||||
|
||||
- (void)webView:(WKWebView *)webView decidePolicyForNavigationResponse:(WKNavigationResponse *)navigationResponse decisionHandler:(void (^)(WKNavigationResponsePolicy))decisionHandler
|
||||
{
|
||||
if (![navigationResponse.response isKindOfClass:[NSHTTPURLResponse class]]) {
|
||||
decisionHandler(WKNavigationResponsePolicyAllow);
|
||||
return;
|
||||
}
|
||||
|
||||
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)navigationResponse.response;
|
||||
|
||||
NSString *contentType = [httpResponse valueForHTTPHeaderField:@"Content-Type"];
|
||||
if (!navigationResponse.canShowMIMEType && (contentType && [contentType length] > 0)) {
|
||||
decisionHandler(WKNavigationResponsePolicyDownload);
|
||||
return;
|
||||
}
|
||||
|
||||
if (contentType && ([contentType isEqualToString:@"application/pdf"] || [contentType isEqualToString:@"text/pdf"])) {
|
||||
decisionHandler(WKNavigationResponsePolicyDownload);
|
||||
return;
|
||||
}
|
||||
|
||||
NSString *disposition = [[httpResponse allHeaderFields] objectForKey:@"Content-Disposition"];
|
||||
if (disposition && [disposition hasPrefix:@"attachment"]) {
|
||||
decisionHandler(WKNavigationResponsePolicyDownload);
|
||||
return;
|
||||
}
|
||||
decisionHandler(WKNavigationResponsePolicyAllow);
|
||||
}
|
||||
|
||||
- (void)webView:(WKWebView *)webView navigationAction:(WKNavigationAction *)navigationAction didBecomeDownload:(WKDownload *)download
|
||||
{
|
||||
download.delegate = self;
|
||||
}
|
||||
|
||||
- (void)webView:(WKWebView *)webView navigationResponse:(WKNavigationResponse *)navigationResponse didBecomeDownload:(WKDownload *)download
|
||||
{
|
||||
download.delegate = self;
|
||||
}
|
||||
|
||||
// Always automatically accept requestStorageAccess dialog.
|
||||
- (void)_webView:(WKWebView *)webView requestStorageAccessPanelForDomain:(NSString *)requestingDomain underCurrentDomain:(NSString *)currentDomain completionHandler:(void (^)(BOOL result))completionHandler
|
||||
{
|
||||
completionHandler(true);
|
||||
}
|
||||
|
||||
#pragma mark WKDownloadDelegate
|
||||
|
||||
- (void)download:(WKDownload *)download decideDestinationUsingResponse:(NSURLResponse *)response suggestedFilename:(NSString *)suggestedFilename completionHandler:(void (^)(NSURL * _Nullable destination))completionHandler
|
||||
{
|
||||
completionHandler(nil);
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,187 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="16096" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
||||
<dependencies>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="16096"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<customObject id="-2" userLabel="File's Owner" customClass="BrowserWindowController">
|
||||
<connections>
|
||||
<outlet property="backButton" destination="40" id="46"/>
|
||||
<outlet property="containerView" destination="9" id="37"/>
|
||||
<outlet property="forwardButton" destination="42" id="47"/>
|
||||
<outlet property="lockButton" destination="mWN-r5-XQb" id="49"/>
|
||||
<outlet property="progressIndicator" destination="21" id="33"/>
|
||||
<outlet property="reloadButton" destination="23" id="34"/>
|
||||
<outlet property="share" destination="1hB-AH-eUl" id="si4-8e-DsM"/>
|
||||
<outlet property="toggleUseShrinkToFitButton" destination="82" id="9w7-AB-Ye3"/>
|
||||
<outlet property="toolbar" destination="48" id="67"/>
|
||||
<outlet property="urlText" destination="10" id="32"/>
|
||||
<outlet property="window" destination="1" id="3"/>
|
||||
</connections>
|
||||
</customObject>
|
||||
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
|
||||
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
|
||||
<window title="Window" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" frameAutosaveName="Main Window" animationBehavior="default" id="1" customClass="CustomWindow">
|
||||
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES" fullSizeContentView="YES"/>
|
||||
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
|
||||
<rect key="contentRect" x="517" y="330" width="776" height="608"/>
|
||||
<rect key="screenRect" x="0.0" y="0.0" width="2560" height="1417"/>
|
||||
<view key="contentView" id="2">
|
||||
<rect key="frame" x="0.0" y="0.0" width="776" height="608"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<customView fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="9">
|
||||
<rect key="frame" x="0.0" y="0.0" width="776" height="608"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
</customView>
|
||||
</subviews>
|
||||
</view>
|
||||
<toolbar key="toolbar" implicitIdentifier="994A0CB1-7575-4F39-A65B-7165AB1E8015" displayMode="iconOnly" sizeMode="regular" id="48">
|
||||
<allowedToolbarItems>
|
||||
<toolbarItem implicitItemIdentifier="73DE9F4B-73E2-4036-A134-2D9E029DA980" label="Go Back" paletteLabel="Go Back" image="NSGoLeftTemplate" id="56" customClass="MBToolbarItem">
|
||||
<nil key="toolTip"/>
|
||||
<size key="minSize" width="32" height="25"/>
|
||||
<size key="maxSize" width="32" height="25"/>
|
||||
<button key="view" verticalHuggingPriority="750" id="40">
|
||||
<rect key="frame" x="10" y="14" width="32" height="25"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<buttonCell key="cell" type="roundTextured" bezelStyle="texturedRounded" image="NSGoLeftTemplate" imagePosition="overlaps" alignment="center" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="41">
|
||||
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
</buttonCell>
|
||||
</button>
|
||||
<connections>
|
||||
<action selector="goBack:" target="-2" id="61"/>
|
||||
</connections>
|
||||
</toolbarItem>
|
||||
<toolbarItem implicitItemIdentifier="E1A9D32A-59E3-467B-9ABA-A95780416E69" label="Go Forward" paletteLabel="Go Forward" image="NSGoRightTemplate" id="57" customClass="MBToolbarItem">
|
||||
<nil key="toolTip"/>
|
||||
<size key="minSize" width="32" height="25"/>
|
||||
<size key="maxSize" width="32" height="27"/>
|
||||
<button key="view" verticalHuggingPriority="750" id="42">
|
||||
<rect key="frame" x="18" y="14" width="32" height="25"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<buttonCell key="cell" type="roundTextured" bezelStyle="texturedRounded" image="NSGoRightTemplate" imagePosition="overlaps" alignment="center" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="43">
|
||||
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
</buttonCell>
|
||||
</button>
|
||||
<connections>
|
||||
<action selector="goForward:" target="-2" id="62"/>
|
||||
</connections>
|
||||
</toolbarItem>
|
||||
<toolbarItem implicitItemIdentifier="88C16109-D40F-4682-BCE4-CBEE2EDE32D2" label="Refresh" paletteLabel="Refresh" image="NSRefreshTemplate" id="58" customClass="MBToolbarItem">
|
||||
<nil key="toolTip"/>
|
||||
<size key="minSize" width="29" height="25"/>
|
||||
<size key="maxSize" width="29" height="27"/>
|
||||
<button key="view" verticalHuggingPriority="750" id="23">
|
||||
<rect key="frame" x="10" y="14" width="29" height="25"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<buttonCell key="cell" type="roundTextured" bezelStyle="texturedRounded" image="NSRefreshTemplate" imagePosition="overlaps" alignment="center" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="24">
|
||||
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
</buttonCell>
|
||||
<connections>
|
||||
<action selector="reload:" target="-2" id="35"/>
|
||||
</connections>
|
||||
</button>
|
||||
</toolbarItem>
|
||||
<toolbarItem implicitItemIdentifier="F9C3B2C4-B22D-4E12-92BC-EA326711BBC1" label="Lock" paletteLabel="Lock" image="NSLockUnlockedTemplate" id="Ky3-6Y-3U1" userLabel="Lock" customClass="MBToolbarItem">
|
||||
<nil key="toolTip"/>
|
||||
<size key="minSize" width="29" height="25"/>
|
||||
<size key="maxSize" width="29" height="27"/>
|
||||
<button key="view" verticalHuggingPriority="750" id="mWN-r5-XQb">
|
||||
<rect key="frame" x="2" y="14" width="29" height="25"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<buttonCell key="cell" type="roundTextured" bezelStyle="texturedRounded" image="NSLockUnlockedTemplate" imagePosition="overlaps" alignment="center" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="iRv-ey-QZe">
|
||||
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
</buttonCell>
|
||||
<connections>
|
||||
<action selector="showCertificate:" target="-2" id="LjW-s0-oJ2"/>
|
||||
</connections>
|
||||
</button>
|
||||
</toolbarItem>
|
||||
<toolbarItem implicitItemIdentifier="76DCF2B0-1DDE-47D2-9212-705E6E310CCE" label="Use Shrink To Fit" paletteLabel="Use Shrink To Fit" image="NSEnterFullScreenTemplate" id="81" customClass="MBToolbarItem">
|
||||
<nil key="toolTip"/>
|
||||
<size key="minSize" width="29" height="25"/>
|
||||
<size key="maxSize" width="29" height="27"/>
|
||||
<button key="view" verticalHuggingPriority="750" id="82">
|
||||
<rect key="frame" x="34" y="14" width="29" height="25"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<buttonCell key="cell" type="roundTextured" bezelStyle="texturedRounded" image="NSEnterFullScreenTemplate" imagePosition="overlaps" alignment="center" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="83">
|
||||
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
</buttonCell>
|
||||
<connections>
|
||||
<action selector="toggleShrinkToFit:" target="-2" id="gp7-Vk-KTI"/>
|
||||
</connections>
|
||||
</button>
|
||||
</toolbarItem>
|
||||
<toolbarItem implicitItemIdentifier="F1738B7F-895C-48F7-955D-0915E150BE1B" label="Share" paletteLabel="Share" image="NSShareTemplate" id="dJx-dw-gcC" customClass="MBToolbarItem">
|
||||
<nil key="toolTip"/>
|
||||
<size key="minSize" width="29" height="25"/>
|
||||
<size key="maxSize" width="29" height="27"/>
|
||||
<button key="view" verticalHuggingPriority="750" id="1hB-AH-eUl">
|
||||
<rect key="frame" x="5" y="14" width="29" height="25"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<buttonCell key="cell" type="roundTextured" bezelStyle="texturedRounded" image="NSShareTemplate" imagePosition="overlaps" alignment="center" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="S1v-UD-QhI">
|
||||
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
<connections>
|
||||
<action selector="share:" target="-2" id="5e3-hg-bKN"/>
|
||||
</connections>
|
||||
</buttonCell>
|
||||
</button>
|
||||
</toolbarItem>
|
||||
<toolbarItem implicitItemIdentifier="255D29F2-C9AA-4B4B-BB43-B38FCD6A0BBB" label="Location" paletteLabel="Location" id="59">
|
||||
<nil key="toolTip"/>
|
||||
<size key="minSize" width="50" height="22"/>
|
||||
<size key="maxSize" width="100000" height="22"/>
|
||||
<textField key="view" verticalHuggingPriority="750" id="10">
|
||||
<rect key="frame" x="0.0" y="14" width="565" height="22"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
|
||||
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" state="on" borderStyle="bezel" drawsBackground="YES" id="11">
|
||||
<font key="font" metaFont="system"/>
|
||||
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
<connections>
|
||||
<action selector="fetch:" target="-2" id="36"/>
|
||||
</connections>
|
||||
</textField>
|
||||
</toolbarItem>
|
||||
<toolbarItem implicitItemIdentifier="86912BAA-B8D0-400F-BFEE-71FC166986E6" label="Progress" paletteLabel="Progress" tag="-1" sizingBehavior="auto" id="60">
|
||||
<nil key="toolTip"/>
|
||||
<progressIndicator key="view" horizontalHuggingPriority="750" verticalHuggingPriority="750" maxValue="1" displayedWhenStopped="NO" bezeled="NO" controlSize="small" style="spinning" id="21">
|
||||
<rect key="frame" x="19" y="14" width="16" height="16"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMinY="YES"/>
|
||||
</progressIndicator>
|
||||
</toolbarItem>
|
||||
</allowedToolbarItems>
|
||||
<defaultToolbarItems>
|
||||
<toolbarItem reference="56"/>
|
||||
<toolbarItem reference="57"/>
|
||||
<toolbarItem reference="58"/>
|
||||
<toolbarItem reference="Ky3-6Y-3U1"/>
|
||||
<toolbarItem reference="59"/>
|
||||
<toolbarItem reference="dJx-dw-gcC"/>
|
||||
<toolbarItem reference="60"/>
|
||||
</defaultToolbarItems>
|
||||
</toolbar>
|
||||
<connections>
|
||||
<outlet property="delegate" destination="-2" id="4"/>
|
||||
</connections>
|
||||
<point key="canvasLocation" x="-136" y="158"/>
|
||||
</window>
|
||||
</objects>
|
||||
<resources>
|
||||
<image name="NSEnterFullScreenTemplate" width="15" height="15"/>
|
||||
<image name="NSGoLeftTemplate" width="9" height="12"/>
|
||||
<image name="NSGoRightTemplate" width="9" height="12"/>
|
||||
<image name="NSLockUnlockedTemplate" width="10" height="14"/>
|
||||
<image name="NSRefreshTemplate" width="11" height="15"/>
|
||||
<image name="NSShareTemplate" width="11" height="16"/>
|
||||
</resources>
|
||||
</document>
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
@class WKWebView;
|
||||
|
||||
@interface CustomWindow : NSWindow
|
||||
|
||||
- (NSRect)constrainFrameRect:(NSRect)frameRect toScreen:(NSScreen *)screen;
|
||||
|
||||
@end
|
||||
|
||||
@interface BrowserWindowController : NSWindowController
|
||||
|
||||
- (IBAction)goBack:(id)sender;
|
||||
- (IBAction)goForward:(id)sender;
|
||||
- (IBAction)toggleFullWindowWebView:(id)sender;
|
||||
- (IBAction)reload:(id)sender;
|
||||
- (IBAction)saveAsPDF:(id)sender;
|
||||
- (IBAction)saveAsWebArchive:(id)sender;
|
||||
- (IBAction)zoomIn:(id)sender;
|
||||
- (IBAction)zoomOut:(id)sender;
|
||||
- (IBAction)resetZoom:(id)sender;
|
||||
- (IBAction)showHideWebInspector:(id)sender;
|
||||
|
||||
- (IBAction)setPageScale:(id)sender;
|
||||
- (IBAction)setViewScale:(id)sender;
|
||||
- (instancetype)initWithConfiguration:(WKWebViewConfiguration *)configuration;
|
||||
- (void)loadURLString:(NSString *)urlString;
|
||||
- (WKWebView *)webView;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,43 @@
|
||||
set(PLAYWRIGHT_DIR "${TOOLS_DIR}/Playwright/mac")
|
||||
|
||||
#FIXME: This should not need WEBCORE_EXPORT defined. This means we are including WebCore headers, and we should not.
|
||||
add_definitions("-include Playwright_Prefix.pch -DWEBCORE_EXPORT=")
|
||||
|
||||
set(Playwright_SOURCES
|
||||
${PLAYWRIGHT_DIR}/AppDelegate.m
|
||||
${PLAYWRIGHT_DIR}/BrowserWindowController.m
|
||||
${PLAYWRIGHT_DIR}/main.m
|
||||
${TOOLS_DIR}/Playwright/MBToolbarItem.m
|
||||
)
|
||||
|
||||
set(Playwright_INCLUDE_DIRECTORIES
|
||||
${CMAKE_SOURCE_DIR}/Source
|
||||
${FORWARDING_HEADERS_DIR}
|
||||
${PLAYWRIGHT_DIR}
|
||||
)
|
||||
|
||||
set(Playwright_LIBRARIES
|
||||
WebKit
|
||||
)
|
||||
|
||||
set(CMAKE_EXE_LINKER_FLAGS "-framework Cocoa")
|
||||
|
||||
set(EXECUTABLE_NAME Playwright)
|
||||
set(PRODUCT_NAME Playwright)
|
||||
|
||||
set(Playwright_Contents_Directory ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/Playwright.app/Contents)
|
||||
make_directory(${Playwright_Contents_Directory}/Resources)
|
||||
add_custom_command(OUTPUT ${Playwright_Contents_Directory}/Resources/BrowserWindow.nib
|
||||
COMMAND ibtool --compile ${Playwright_Contents_Directory}/Resources/BrowserWindow.nib ${PLAYWRIGHT_DIR}/BrowserWindow.xib VERBATIM)
|
||||
add_custom_command(OUTPUT ${Playwright_Contents_Directory}/Resources/MainMenu.nib
|
||||
COMMAND ibtool --compile ${Playwright_Contents_Directory}/Resources/MainMenu.nib ${PLAYWRIGHT_DIR}/MainMenu.xib VERBATIM)
|
||||
add_custom_target(PlaywrightNibs ALL DEPENDS
|
||||
${Playwright_Contents_Directory}/Resources/BrowserWindow.nib
|
||||
${Playwright_Contents_Directory}/Resources/MainMenu.nib
|
||||
)
|
||||
|
||||
include_directories(${Playwright_INCLUDE_DIRECTORIES})
|
||||
add_executable(Playwright MACOSX_BUNDLE ${Playwright_SOURCES})
|
||||
set_target_properties(Playwright PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${PLAYWRIGHT_DIR}/Info.plist)
|
||||
target_link_libraries(Playwright ${Playwright_LIBRARIES})
|
||||
add_dependencies(Playwright PlaywrightNibs)
|
||||
@@ -0,0 +1,54 @@
|
||||
<?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>CFBundleDocumentTypes</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>CFBundleTypeExtensions</key>
|
||||
<array>
|
||||
<string>html</string>
|
||||
</array>
|
||||
<key>CFBundleTypeMIMETypes</key>
|
||||
<array>
|
||||
<string>text/html</string>
|
||||
</array>
|
||||
<key>CFBundleTypeName</key>
|
||||
<string>HTML</string>
|
||||
<key>CFBundleTypeRole</key>
|
||||
<string>Editor</string>
|
||||
</dict>
|
||||
</array>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>${EXECUTABLE_NAME}</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>${PRODUCT_BUNDLE_IDENTIFIER}</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>${PRODUCT_NAME}</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1</string>
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
<string>${MACOSX_DEPLOYMENT_TARGET}</string>
|
||||
<key>NSAppTransportSecurity</key>
|
||||
<dict>
|
||||
<key>NSAllowsArbitraryLoads</key>
|
||||
<true/>
|
||||
</dict>
|
||||
<key>NSMainNibFile</key>
|
||||
<string>MainMenu</string>
|
||||
<key>NSPrincipalClass</key>
|
||||
<string>NSApplication</string>
|
||||
<key>NSSupportsAutomaticGraphicsSwitching</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -0,0 +1,333 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="15505" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
||||
<dependencies>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="15505"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<customObject id="-2" userLabel="File's Owner" customClass="NSApplication">
|
||||
<connections>
|
||||
<outlet property="delegate" destination="494" id="495"/>
|
||||
</connections>
|
||||
</customObject>
|
||||
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
|
||||
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
|
||||
<menu title="AMainMenu" systemMenu="main" id="29">
|
||||
<items>
|
||||
<menuItem title="Playwright" id="56">
|
||||
<menu key="submenu" title="Playwright" systemMenu="apple" id="57">
|
||||
<items>
|
||||
<menuItem title="About Playwright" id="58">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="orderFrontStandardAboutPanel:" target="-2" id="142"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem isSeparatorItem="YES" id="236">
|
||||
<modifierMask key="keyEquivalentModifierMask" command="YES"/>
|
||||
</menuItem>
|
||||
<menuItem title="Preferences…" keyEquivalent="," id="129"/>
|
||||
<menuItem isSeparatorItem="YES" id="143">
|
||||
<modifierMask key="keyEquivalentModifierMask" command="YES"/>
|
||||
</menuItem>
|
||||
<menuItem title="Services" id="131">
|
||||
<menu key="submenu" title="Services" systemMenu="services" id="130"/>
|
||||
</menuItem>
|
||||
<menuItem isSeparatorItem="YES" id="144">
|
||||
<modifierMask key="keyEquivalentModifierMask" command="YES"/>
|
||||
</menuItem>
|
||||
<menuItem title="Hide Playwright" keyEquivalent="h" id="134">
|
||||
<connections>
|
||||
<action selector="hide:" target="-1" id="367"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Hide Others" keyEquivalent="h" id="145">
|
||||
<modifierMask key="keyEquivalentModifierMask" option="YES" command="YES"/>
|
||||
<connections>
|
||||
<action selector="hideOtherApplications:" target="-1" id="368"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Show All" id="150">
|
||||
<connections>
|
||||
<action selector="unhideAllApplications:" target="-1" id="370"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem isSeparatorItem="YES" id="149">
|
||||
<modifierMask key="keyEquivalentModifierMask" command="YES"/>
|
||||
</menuItem>
|
||||
<menuItem title="Quit Playwright" keyEquivalent="q" id="136">
|
||||
<connections>
|
||||
<action selector="terminate:" target="-3" id="449"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
</items>
|
||||
</menu>
|
||||
</menuItem>
|
||||
<menuItem title="File" id="83">
|
||||
<menu key="submenu" title="File" id="81">
|
||||
<items>
|
||||
<menuItem title="Open Location " tag="1" keyEquivalent="l" id="82">
|
||||
<connections>
|
||||
<action selector="openLocation:" target="-1" id="575"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem isSeparatorItem="YES" id="79">
|
||||
<modifierMask key="keyEquivalentModifierMask" command="YES"/>
|
||||
</menuItem>
|
||||
<menuItem title="Close" keyEquivalent="w" id="73">
|
||||
<connections>
|
||||
<action selector="performClose:" target="-1" id="193"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Save" keyEquivalent="s" id="75">
|
||||
<connections>
|
||||
<action selector="saveDocument:" target="-1" id="362"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Save As…" keyEquivalent="S" id="80">
|
||||
<modifierMask key="keyEquivalentModifierMask" shift="YES" command="YES"/>
|
||||
<connections>
|
||||
<action selector="saveDocumentAs:" target="-1" id="363"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Save As PDF…" keyEquivalent="S" id="gmS-3Q-oLs">
|
||||
<modifierMask key="keyEquivalentModifierMask" option="YES" command="YES"/>
|
||||
<connections>
|
||||
<action selector="saveAsPDF:" target="-1" id="25T-Id-334"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Save As WebArchive..." id="112">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="saveAsWebArchive:" target="-1" id="AGx-3e-6Nt"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem isSeparatorItem="YES" id="74">
|
||||
<modifierMask key="keyEquivalentModifierMask" command="YES"/>
|
||||
</menuItem>
|
||||
<menuItem title="Page Setup..." keyEquivalent="P" id="77">
|
||||
<modifierMask key="keyEquivalentModifierMask" shift="YES" command="YES"/>
|
||||
<connections>
|
||||
<action selector="runPageLayout:" target="-1" id="87"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Print…" keyEquivalent="p" id="78">
|
||||
<connections>
|
||||
<action selector="printWebView:" target="-1" id="86"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
</items>
|
||||
</menu>
|
||||
</menuItem>
|
||||
<menuItem title="Edit" id="217">
|
||||
<menu key="submenu" title="Edit" id="205">
|
||||
<items>
|
||||
<menuItem title="Undo" keyEquivalent="z" id="207">
|
||||
<connections>
|
||||
<action selector="undo:" target="-1" id="223"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Redo" keyEquivalent="Z" id="215">
|
||||
<modifierMask key="keyEquivalentModifierMask" shift="YES" command="YES"/>
|
||||
<connections>
|
||||
<action selector="redo:" target="-1" id="231"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem isSeparatorItem="YES" id="206">
|
||||
<modifierMask key="keyEquivalentModifierMask" command="YES"/>
|
||||
</menuItem>
|
||||
<menuItem title="Cut" keyEquivalent="x" id="199">
|
||||
<connections>
|
||||
<action selector="cut:" target="-1" id="228"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Copy" keyEquivalent="c" id="197">
|
||||
<connections>
|
||||
<action selector="copy:" target="-1" id="224"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Paste" keyEquivalent="v" id="203">
|
||||
<connections>
|
||||
<action selector="paste:" target="-1" id="226"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Delete" id="202">
|
||||
<connections>
|
||||
<action selector="delete:" target="-1" id="235"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Select All" keyEquivalent="a" id="198">
|
||||
<connections>
|
||||
<action selector="selectAll:" target="-1" id="232"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem isSeparatorItem="YES" id="214">
|
||||
<modifierMask key="keyEquivalentModifierMask" command="YES"/>
|
||||
</menuItem>
|
||||
<menuItem title="Find" id="218">
|
||||
<menu key="submenu" title="Find" id="220">
|
||||
<items>
|
||||
<menuItem title="Find…" tag="1" keyEquivalent="f" id="209">
|
||||
<connections>
|
||||
<action selector="performTextFinderAction:" target="-1" id="241"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Find Next" tag="2" keyEquivalent="g" id="208">
|
||||
<connections>
|
||||
<action selector="performTextFinderAction:" target="-1" id="487"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Find Previous" tag="3" keyEquivalent="G" id="213">
|
||||
<modifierMask key="keyEquivalentModifierMask" shift="YES" command="YES"/>
|
||||
<connections>
|
||||
<action selector="performTextFinderAction:" target="-1" id="488"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Use Selection for Find" tag="7" keyEquivalent="e" id="221">
|
||||
<connections>
|
||||
<action selector="performTextFinderAction:" target="-1" id="489"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Jump to Selection" keyEquivalent="j" id="210">
|
||||
<connections>
|
||||
<action selector="centerSelectionInVisibleArea:" target="-1" id="245"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
</items>
|
||||
</menu>
|
||||
</menuItem>
|
||||
</items>
|
||||
</menu>
|
||||
</menuItem>
|
||||
<menuItem title="View" id="295">
|
||||
<menu key="submenu" title="View" id="296">
|
||||
<items>
|
||||
<menuItem title="Zoom In" keyEquivalent="+" id="555">
|
||||
<connections>
|
||||
<action selector="zoomIn:" target="-1" id="559"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Zoom Out" keyEquivalent="-" id="557">
|
||||
<connections>
|
||||
<action selector="zoomOut:" target="-1" id="560"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Reset Zoom" keyEquivalent="0" id="558">
|
||||
<connections>
|
||||
<action selector="resetZoom:" target="-1" id="561"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Zoom Text Only" id="562">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="toggleZoomMode:" target="-1" id="564"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Page Scale" id="Hzb-c3-Qfv">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<menu key="submenu" title="Page Scale" id="jdo-5V-3CM">
|
||||
<items>
|
||||
<menuItem title="100%" state="on" tag="1" keyEquivalent="1" id="wHb-mR-Fv0">
|
||||
<connections>
|
||||
<action selector="setPageScale:" target="-1" id="uMw-eY-289"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="125%" tag="2" keyEquivalent="2" id="u4i-F7-rPb">
|
||||
<connections>
|
||||
<action selector="setPageScale:" target="-1" id="IbE-Ep-hfc"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="150%" tag="3" keyEquivalent="3" id="fwT-Iy-oK9">
|
||||
<connections>
|
||||
<action selector="setPageScale:" target="-1" id="9c0-eN-0f5"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="200%" tag="4" keyEquivalent="4" id="R5e-ct-O2u">
|
||||
<connections>
|
||||
<action selector="setPageScale:" target="-1" id="mkk-gh-dlN"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
</items>
|
||||
</menu>
|
||||
</menuItem>
|
||||
<menuItem title="View Scale" id="8UY-Pj-H13">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<menu key="submenu" title="View Scale" id="Ml8-mk-ffu">
|
||||
<items>
|
||||
<menuItem title="100%" state="on" tag="1" id="EAm-Xn-VrC">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="setViewScale:" target="-1" id="dkW-CI-RG4"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="75%" tag="2" id="jcA-I1-Cbq">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="setViewScale:" target="-1" id="BAF-Ym-IqV"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="50%" tag="3" id="BRM-D5-YNO">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="setViewScale:" target="-1" id="nXy-2b-9Zz"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="25%" tag="4" id="gzk-YK-x0W">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="setViewScale:" target="-1" id="KXK-f6-24N"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
</items>
|
||||
</menu>
|
||||
</menuItem>
|
||||
<menuItem title="Reload Page" keyEquivalent="r" id="579">
|
||||
<connections>
|
||||
<action selector="reload:" target="-1" id="582"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
</items>
|
||||
</menu>
|
||||
</menuItem>
|
||||
<menuItem title="Debug" id="534">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<menu key="submenu" title="Debug" id="535">
|
||||
<items>
|
||||
<menuItem title="Show Web Inspector" keyEquivalent="i" id="xso-9z-R4u">
|
||||
<modifierMask key="keyEquivalentModifierMask" option="YES" command="YES"/>
|
||||
<connections>
|
||||
<action selector="showHideWebInspector:" target="-1" id="Cmx-g7-EPb"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
</items>
|
||||
</menu>
|
||||
</menuItem>
|
||||
<menuItem title="Window" id="19">
|
||||
<menu key="submenu" title="Window" systemMenu="window" id="24">
|
||||
<items>
|
||||
<menuItem title="Minimize" keyEquivalent="m" id="23">
|
||||
<connections>
|
||||
<action selector="performMiniaturize:" target="-1" id="37"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Zoom" id="239">
|
||||
<connections>
|
||||
<action selector="performZoom:" target="-1" id="240"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem isSeparatorItem="YES" id="92">
|
||||
<modifierMask key="keyEquivalentModifierMask" command="YES"/>
|
||||
</menuItem>
|
||||
<menuItem title="Bring All to Front" id="5">
|
||||
<connections>
|
||||
<action selector="arrangeInFront:" target="-1" id="39"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
</items>
|
||||
</menu>
|
||||
</menuItem>
|
||||
</items>
|
||||
<point key="canvasLocation" x="139" y="-50"/>
|
||||
</menu>
|
||||
<customObject id="494" customClass="BrowserAppDelegate"/>
|
||||
</objects>
|
||||
</document>
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifdef __OBJC__
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import <WebKit/WebKit.h>
|
||||
#endif
|
||||
|
||||
#define ENABLE_LOGGING 0
|
||||
|
||||
#if ENABLE_LOGGING
|
||||
#define LOG NSLog
|
||||
#else
|
||||
#define LOG(...) ((void)0)
|
||||
#endif
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"WebKitLinkedOnOrAfterEverything"];
|
||||
|
||||
return NSApplicationMain(argc, (const char **) argv);
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
set(Playwright_PRIVATE_INCLUDE_DIRECTORIES
|
||||
${CMAKE_BINARY_DIR}
|
||||
${WebCore_PRIVATE_FRAMEWORK_HEADERS_DIR}
|
||||
)
|
||||
|
||||
set(Playwright_SOURCES
|
||||
Common.cpp
|
||||
MainWindow.cpp
|
||||
PlaywrightLib.rc
|
||||
WebKitBrowserWindow.cpp
|
||||
WinMain.cpp
|
||||
stdafx.cpp
|
||||
)
|
||||
|
||||
set(Playwright_PRIVATE_DEFINITIONS _UNICODE)
|
||||
set(Playwright_PRIVATE_LIBRARIES
|
||||
WebKit::WTF
|
||||
comctl32
|
||||
shlwapi
|
||||
user32
|
||||
)
|
||||
|
||||
list(APPEND Playwright_PRIVATE_DEFINITIONS ENABLE_WEBKIT)
|
||||
list(APPEND Playwright_SOURCES
|
||||
WebKitBrowserWindow.cpp
|
||||
)
|
||||
list(APPEND Playwright_PRIVATE_LIBRARIES
|
||||
WebKit::WebKit
|
||||
)
|
||||
|
||||
WEBKIT_EXECUTABLE_DECLARE(Playwright)
|
||||
WEBKIT_EXECUTABLE(Playwright)
|
||||
|
||||
set_target_properties(Playwright PROPERTIES WIN32_EXECUTABLE ON)
|
||||
if (${WTF_PLATFORM_WIN_CAIRO})
|
||||
target_compile_definitions(Playwright PRIVATE WIN_CAIRO)
|
||||
endif ()
|
||||
@@ -0,0 +1,264 @@
|
||||
/*
|
||||
* Copyright (C) 2006, 2008, 2013-2015 Apple Inc. All rights reserved.
|
||||
* Copyright (C) 2009, 2011 Brent Fulgham. All rights reserved.
|
||||
* Copyright (C) 2009, 2010, 2011 Appcelerator, Inc. All rights reserved.
|
||||
* Copyright (C) 2013 Alex Christensen. 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. ``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
|
||||
* 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 "stdafx.h"
|
||||
#include "Common.h"
|
||||
|
||||
#include "DialogHelper.h"
|
||||
#include "PlaywrightLibResource.h"
|
||||
#include "PlaywrightReplace.h"
|
||||
#include <dbghelp.h>
|
||||
#include <shlobj.h>
|
||||
#include <wtf/StdLibExtras.h>
|
||||
#include <vector>
|
||||
|
||||
// Global Variables:
|
||||
HINSTANCE hInst;
|
||||
|
||||
// Support moving the transparent window
|
||||
POINT s_windowPosition = { 100, 100 };
|
||||
SIZE s_windowSize = { 500, 200 };
|
||||
|
||||
bool s_headless;
|
||||
|
||||
namespace WebCore {
|
||||
float deviceScaleFactorForWindow(HWND);
|
||||
}
|
||||
|
||||
void computeFullDesktopFrame()
|
||||
{
|
||||
RECT desktop;
|
||||
if (!::SystemParametersInfo(SPI_GETWORKAREA, 0, static_cast<void*>(&desktop), 0))
|
||||
return;
|
||||
|
||||
float scaleFactor = WebCore::deviceScaleFactorForWindow(nullptr);
|
||||
|
||||
s_windowPosition.x = 0;
|
||||
s_windowPosition.y = 0;
|
||||
s_windowSize.cx = scaleFactor * (desktop.right - desktop.left);
|
||||
s_windowSize.cy = scaleFactor * (desktop.bottom - desktop.top);
|
||||
}
|
||||
|
||||
bool getAppDataFolder(_bstr_t& directory)
|
||||
{
|
||||
wchar_t appDataDirectory[MAX_PATH];
|
||||
if (FAILED(SHGetFolderPathW(0, CSIDL_LOCAL_APPDATA | CSIDL_FLAG_CREATE, 0, 0, appDataDirectory)))
|
||||
return false;
|
||||
|
||||
wchar_t executablePath[MAX_PATH];
|
||||
if (!::GetModuleFileNameW(0, executablePath, MAX_PATH))
|
||||
return false;
|
||||
|
||||
::PathRemoveExtensionW(executablePath);
|
||||
|
||||
directory = _bstr_t(appDataDirectory) + L"\\" + ::PathFindFileNameW(executablePath);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void createCrashReport(EXCEPTION_POINTERS* exceptionPointers)
|
||||
{
|
||||
_bstr_t directory;
|
||||
|
||||
if (!getAppDataFolder(directory))
|
||||
return;
|
||||
|
||||
if (::SHCreateDirectoryEx(0, directory, 0) != ERROR_SUCCESS
|
||||
&& ::GetLastError() != ERROR_FILE_EXISTS
|
||||
&& ::GetLastError() != ERROR_ALREADY_EXISTS)
|
||||
return;
|
||||
|
||||
std::wstring fileName = std::wstring(static_cast<const wchar_t*>(directory)) + L"\\CrashReport.dmp";
|
||||
HANDLE miniDumpFile = ::CreateFile(fileName.c_str(), GENERIC_WRITE, 0, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
|
||||
|
||||
if (miniDumpFile && miniDumpFile != INVALID_HANDLE_VALUE) {
|
||||
|
||||
MINIDUMP_EXCEPTION_INFORMATION mdei;
|
||||
mdei.ThreadId = ::GetCurrentThreadId();
|
||||
mdei.ExceptionPointers = exceptionPointers;
|
||||
mdei.ClientPointers = 0;
|
||||
|
||||
#ifdef _DEBUG
|
||||
MINIDUMP_TYPE dumpType = MiniDumpWithFullMemory;
|
||||
#else
|
||||
MINIDUMP_TYPE dumpType = MiniDumpNormal;
|
||||
#endif
|
||||
|
||||
::MiniDumpWriteDump(::GetCurrentProcess(), ::GetCurrentProcessId(), miniDumpFile, dumpType, &mdei, 0, 0);
|
||||
::CloseHandle(miniDumpFile);
|
||||
processCrashReport(fileName.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
std::optional<Credential> askCredential(HWND hwnd, const std::wstring& realm)
|
||||
{
|
||||
struct AuthDialog : public Dialog {
|
||||
std::wstring realm;
|
||||
Credential credential;
|
||||
|
||||
protected:
|
||||
void setup()
|
||||
{
|
||||
setText(IDC_REALM_TEXT, realm);
|
||||
}
|
||||
|
||||
void ok() final
|
||||
{
|
||||
credential.username = getText(IDC_AUTH_USER);
|
||||
credential.password = getText(IDC_AUTH_PASSWORD);
|
||||
}
|
||||
};
|
||||
|
||||
AuthDialog dialog;
|
||||
dialog.realm = realm;
|
||||
|
||||
if (dialog.run(hInst, hwnd, IDD_AUTH))
|
||||
return dialog.credential;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
bool askServerTrustEvaluation(HWND hwnd, const std::wstring& text)
|
||||
{
|
||||
class ServerTrustEvaluationDialog : public Dialog {
|
||||
public:
|
||||
ServerTrustEvaluationDialog(const std::wstring& text)
|
||||
: m_text { text }
|
||||
{
|
||||
SendMessage(GetDlgItem(this->hDlg(), IDC_SERVER_TRUST_TEXT), WM_SETFONT, (WPARAM)GetStockObject(ANSI_FIXED_FONT), TRUE);
|
||||
}
|
||||
|
||||
protected:
|
||||
std::wstring m_text;
|
||||
|
||||
void setup()
|
||||
{
|
||||
setText(IDC_SERVER_TRUST_TEXT, m_text);
|
||||
}
|
||||
|
||||
void ok() final
|
||||
{
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
ServerTrustEvaluationDialog dialog { text };
|
||||
return dialog.run(hInst, hwnd, IDD_SERVER_TRUST);
|
||||
}
|
||||
|
||||
CommandLineOptions parseCommandLine()
|
||||
{
|
||||
CommandLineOptions options;
|
||||
|
||||
int argc = 0;
|
||||
WCHAR** argv = CommandLineToArgvW(GetCommandLineW(), &argc);
|
||||
for (int i = 1; i < argc; ++i) {
|
||||
if (!wcsicmp(argv[i], L"--desktop"))
|
||||
options.useFullDesktop = true;
|
||||
else if (!wcsicmp(argv[i], L"--inspector-pipe"))
|
||||
options.inspectorPipe = true;
|
||||
else if (!wcsncmp(argv[i], L"--user-data-dir=", 16))
|
||||
options.userDataDir = argv[i] + 16;
|
||||
else if (!wcsncmp(argv[i], L"--curl-proxy=", 13))
|
||||
options.curloptProxy = argv[i] + 13;
|
||||
else if (!wcsncmp(argv[i], L"--curl-noproxy=", 15))
|
||||
options.curloptNoproxy = argv[i] + 15;
|
||||
else if (!wcsicmp(argv[i], L"--headless"))
|
||||
options.headless = true;
|
||||
else if (!wcsicmp(argv[i], L"--no-startup-window"))
|
||||
options.noStartupWindow = true;
|
||||
else if (!wcsicmp(argv[i], L"--disable-accelerated-compositing"))
|
||||
options.disableAcceleratedCompositing = true;
|
||||
else if (!options.requestedURL)
|
||||
options.requestedURL = argv[i];
|
||||
}
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
std::wstring replaceString(std::wstring src, const std::wstring& oldValue, const std::wstring& newValue)
|
||||
{
|
||||
if (src.empty() || oldValue.empty())
|
||||
return src;
|
||||
|
||||
size_t pos = 0;
|
||||
while ((pos = src.find(oldValue, pos)) != src.npos) {
|
||||
src.replace(pos, oldValue.length(), newValue);
|
||||
pos += newValue.length();
|
||||
}
|
||||
|
||||
return src;
|
||||
}
|
||||
|
||||
std::wstring createString(WKStringRef wkString)
|
||||
{
|
||||
size_t maxSize = WKStringGetLength(wkString);
|
||||
|
||||
std::vector<WKChar> wkCharBuffer(maxSize);
|
||||
size_t actualLength = WKStringGetCharacters(wkString, wkCharBuffer.data(), maxSize);
|
||||
return std::wstring(wkCharBuffer.data(), actualLength);
|
||||
}
|
||||
|
||||
std::wstring createString(WKURLRef wkURL)
|
||||
{
|
||||
if (!wkURL)
|
||||
return { };
|
||||
WKRetainPtr<WKStringRef> url = adoptWK(WKURLCopyString(wkURL));
|
||||
return createString(url.get());
|
||||
}
|
||||
|
||||
std::string createUTF8String(const wchar_t* src, size_t srcLength)
|
||||
{
|
||||
int length = WideCharToMultiByte(CP_UTF8, 0, src, srcLength, 0, 0, nullptr, nullptr);
|
||||
std::vector<char> buffer(length);
|
||||
size_t actualLength = WideCharToMultiByte(CP_UTF8, 0, src, srcLength, buffer.data(), length, nullptr, nullptr);
|
||||
return { buffer.data(), actualLength };
|
||||
}
|
||||
|
||||
WKRetainPtr<WKStringRef> createWKString(_bstr_t str)
|
||||
{
|
||||
auto utf8 = createUTF8String(str, str.length());
|
||||
return adoptWK(WKStringCreateWithUTF8CString(utf8.data()));
|
||||
}
|
||||
|
||||
WKRetainPtr<WKStringRef> createWKString(const std::wstring& str)
|
||||
{
|
||||
auto utf8 = createUTF8String(str.c_str(), str.length());
|
||||
return adoptWK(WKStringCreateWithUTF8CString(utf8.data()));
|
||||
}
|
||||
|
||||
WKRetainPtr<WKURLRef> createWKURL(_bstr_t str)
|
||||
{
|
||||
auto utf8 = createUTF8String(str, str.length());
|
||||
return adoptWK(WKURLCreateWithUTF8CString(utf8.data()));
|
||||
}
|
||||
|
||||
WKRetainPtr<WKURLRef> createWKURL(const std::wstring& str)
|
||||
{
|
||||
auto utf8 = createUTF8String(str.c_str(), str.length());
|
||||
return adoptWK(WKURLCreateWithUTF8CString(utf8.data()));
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* Copyright (C) 2018 Sony Interactive Entertainment Inc.
|
||||
*
|
||||
* 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. ``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
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "stdafx.h"
|
||||
#include <optional>
|
||||
#include <WebKit/WKRetainPtr.h>
|
||||
#include <WebKit/WKString.h>
|
||||
#include <WebKit/WKURL.h>
|
||||
|
||||
struct CommandLineOptions {
|
||||
bool useFullDesktop { };
|
||||
bool inspectorPipe { };
|
||||
bool headless { };
|
||||
bool noStartupWindow { };
|
||||
bool disableAcceleratedCompositing { };
|
||||
_bstr_t requestedURL;
|
||||
_bstr_t userDataDir;
|
||||
_bstr_t curloptProxy;
|
||||
_bstr_t curloptNoproxy;
|
||||
|
||||
CommandLineOptions()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
struct Credential {
|
||||
std::wstring username;
|
||||
std::wstring password;
|
||||
};
|
||||
|
||||
void computeFullDesktopFrame();
|
||||
bool getAppDataFolder(_bstr_t& directory);
|
||||
CommandLineOptions parseCommandLine();
|
||||
void createCrashReport(EXCEPTION_POINTERS*);
|
||||
std::optional<Credential> askCredential(HWND, const std::wstring& realm);
|
||||
|
||||
bool askServerTrustEvaluation(HWND, const std::wstring& text);
|
||||
std::wstring replaceString(std::wstring src, const std::wstring& oldValue, const std::wstring& newValue);
|
||||
|
||||
extern HINSTANCE hInst;
|
||||
extern POINT s_windowPosition;
|
||||
extern SIZE s_windowSize;
|
||||
extern bool s_headless;
|
||||
|
||||
std::wstring createString(WKStringRef wkString);
|
||||
std::wstring createString(WKURLRef wkURL);
|
||||
std::string createUTF8String(const wchar_t* src, size_t srcLength);
|
||||
WKRetainPtr<WKStringRef> createWKString(_bstr_t str);
|
||||
WKRetainPtr<WKStringRef> createWKString(const std::wstring& str);
|
||||
WKRetainPtr<WKURLRef> createWKURL(_bstr_t str);
|
||||
WKRetainPtr<WKURLRef> createWKURL(const std::wstring& str);
|
||||
@@ -0,0 +1,153 @@
|
||||
/*
|
||||
* Copyright (C) 2018 Sony Interactive Entertainment Inc.
|
||||
*
|
||||
* 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. ``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
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "stdafx.h"
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class Dialog {
|
||||
public:
|
||||
bool run(HINSTANCE hInst, HWND hwnd, int dialogId)
|
||||
{
|
||||
auto result = DialogBoxParam(hInst, MAKEINTRESOURCE(dialogId), hwnd, doalogProc, reinterpret_cast<LPARAM>(this));
|
||||
return (result > 0);
|
||||
}
|
||||
|
||||
static INT_PTR CALLBACK doalogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
if (message == WM_INITDIALOG)
|
||||
SetWindowLongPtr(hDlg, DWLP_USER, lParam);
|
||||
else
|
||||
lParam = GetWindowLongPtr(hDlg, DWLP_USER);
|
||||
|
||||
auto* dialog = reinterpret_cast<Dialog*>(lParam);
|
||||
return dialog->handle(hDlg, message, wParam);
|
||||
}
|
||||
|
||||
protected:
|
||||
INT_PTR handle(HWND hDlg, UINT message, WPARAM wParam)
|
||||
{
|
||||
switch (message) {
|
||||
case WM_INITDIALOG: {
|
||||
m_hDlg = hDlg;
|
||||
setup();
|
||||
update();
|
||||
return TRUE;
|
||||
}
|
||||
case WM_COMMAND:
|
||||
int wmId = LOWORD(wParam);
|
||||
switch (wmId) {
|
||||
case IDOK:
|
||||
ok();
|
||||
close(true);
|
||||
return TRUE;
|
||||
case IDCANCEL:
|
||||
cancel();
|
||||
close(false);
|
||||
return TRUE;
|
||||
default:
|
||||
auto handled = command(wmId);
|
||||
update();
|
||||
return handled;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
virtual void setup() { }
|
||||
virtual void update() { updateOkButton(validate()); }
|
||||
virtual bool validate() { return true; }
|
||||
virtual void updateOkButton(bool isValid) { setEnabled(IDOK, isValid); }
|
||||
virtual bool command(int wmId) { return false; }
|
||||
virtual void ok() { }
|
||||
virtual void cancel() { }
|
||||
|
||||
void close(bool success) { EndDialog(m_hDlg, success); }
|
||||
|
||||
HWND hDlg() { return m_hDlg; }
|
||||
|
||||
HWND item(int itemId) { return GetDlgItem(m_hDlg, itemId); }
|
||||
|
||||
void setEnabled(int itemId, bool enabled)
|
||||
{
|
||||
EnableWindow(item(itemId), enabled);
|
||||
}
|
||||
|
||||
void setText(int itemId, const std::wstring& str)
|
||||
{
|
||||
SetDlgItemText(m_hDlg, itemId, _bstr_t(str.c_str()));
|
||||
}
|
||||
|
||||
std::wstring getText(int itemId)
|
||||
{
|
||||
auto length = getTextLength(itemId);
|
||||
std::vector<TCHAR> buffer(length + 1, 0);
|
||||
GetWindowText(item(itemId), buffer.data(), length + 1);
|
||||
return std::wstring { buffer.data() };
|
||||
}
|
||||
|
||||
int getTextLength(int itemId)
|
||||
{
|
||||
return GetWindowTextLength(item(itemId));
|
||||
}
|
||||
|
||||
class RadioGroup {
|
||||
public:
|
||||
RadioGroup(Dialog& dialog, int first, int last)
|
||||
: m_dialog(dialog)
|
||||
, m_first(first)
|
||||
, m_last(last)
|
||||
{
|
||||
}
|
||||
|
||||
void set(int item)
|
||||
{
|
||||
CheckRadioButton(m_dialog.hDlg(), m_first, m_last, item);
|
||||
}
|
||||
|
||||
int get()
|
||||
{
|
||||
for (int id = m_first; id <= m_last; id++) {
|
||||
if (IsDlgButtonChecked(m_dialog.hDlg(), id) == BST_CHECKED)
|
||||
return id;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private:
|
||||
Dialog& m_dialog;
|
||||
int m_first;
|
||||
int m_last;
|
||||
};
|
||||
|
||||
RadioGroup radioGroup(int first, int last)
|
||||
{
|
||||
return RadioGroup(*this, first, last);
|
||||
}
|
||||
|
||||
HWND m_hDlg { };
|
||||
};
|
||||
@@ -0,0 +1,464 @@
|
||||
/*
|
||||
* Copyright (C) 2018 Sony Interactive Entertainment Inc.
|
||||
*
|
||||
* 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. ``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
|
||||
* 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 "stdafx.h"
|
||||
#include "Common.h"
|
||||
#include "MainWindow.h"
|
||||
#include "PlaywrightLibResource.h"
|
||||
#include "WebKitBrowserWindow.h"
|
||||
#include <WebKit/WKPreferencesRefPrivate.h>
|
||||
#include <sstream>
|
||||
|
||||
namespace WebCore {
|
||||
float deviceScaleFactorForWindow(HWND);
|
||||
}
|
||||
|
||||
static const wchar_t* kPlaywrightRegistryKey = L"Software\\WebKit\\Playwright";
|
||||
|
||||
static constexpr int kToolbarImageSize = 24;
|
||||
static constexpr int kToolbarURLBarIndex = 3;
|
||||
|
||||
static WNDPROC DefEditProc = nullptr;
|
||||
|
||||
static LRESULT CALLBACK EditProc(HWND, UINT, WPARAM, LPARAM);
|
||||
static INT_PTR CALLBACK About(HWND, UINT, WPARAM, LPARAM);
|
||||
|
||||
std::wstring MainWindow::s_windowClass;
|
||||
size_t MainWindow::s_numInstances;
|
||||
|
||||
bool MainWindow::s_controlledRemotely = false;
|
||||
bool MainWindow::s_disableAcceleratedCompositing = false;
|
||||
|
||||
void MainWindow::configure(bool controlledRemotely, bool disableAcceleratedCompositing) {
|
||||
s_controlledRemotely = controlledRemotely;
|
||||
s_disableAcceleratedCompositing = disableAcceleratedCompositing;
|
||||
}
|
||||
|
||||
static std::wstring loadString(int id)
|
||||
{
|
||||
constexpr size_t length = 100;
|
||||
wchar_t buff[length];
|
||||
LoadString(hInst, id, buff, length);
|
||||
return buff;
|
||||
}
|
||||
|
||||
void MainWindow::registerClass(HINSTANCE hInstance)
|
||||
{
|
||||
static bool initialized = false;
|
||||
if (initialized)
|
||||
return;
|
||||
initialized = true;
|
||||
|
||||
s_windowClass = loadString(IDC_PLAYWRIGHT);
|
||||
|
||||
WNDCLASSEX wcex;
|
||||
wcex.cbSize = sizeof(WNDCLASSEX);
|
||||
wcex.style = CS_HREDRAW | CS_VREDRAW;
|
||||
wcex.lpfnWndProc = WndProc;
|
||||
wcex.cbClsExtra = 0;
|
||||
wcex.cbWndExtra = 0;
|
||||
wcex.hInstance = hInstance;
|
||||
wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_PLAYWRIGHT));
|
||||
wcex.hCursor = LoadCursor(0, IDC_ARROW);
|
||||
wcex.hbrBackground = 0;
|
||||
wcex.lpszMenuName = MAKEINTRESOURCE(IDC_PLAYWRIGHT);
|
||||
wcex.lpszClassName = s_windowClass.c_str();
|
||||
wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_PLAYWRIGHT));
|
||||
|
||||
RegisterClassEx(&wcex);
|
||||
}
|
||||
|
||||
bool MainWindow::isInstance(HWND hwnd)
|
||||
{
|
||||
wchar_t buff[64];
|
||||
if (!GetClassName(hwnd, buff, _countof(buff)))
|
||||
return false;
|
||||
return s_windowClass == buff;
|
||||
}
|
||||
|
||||
MainWindow::MainWindow()
|
||||
{
|
||||
s_numInstances++;
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
s_numInstances--;
|
||||
}
|
||||
|
||||
void MainWindow::createToolbar(HINSTANCE hInstance)
|
||||
{
|
||||
m_hToolbarWnd = CreateWindowEx(0, TOOLBARCLASSNAME, nullptr,
|
||||
WS_CHILD | WS_BORDER | TBSTYLE_FLAT | TBSTYLE_LIST | TBSTYLE_TOOLTIPS, 0, 0, 0, 0,
|
||||
m_hMainWnd, nullptr, hInstance, nullptr);
|
||||
|
||||
if (!m_hToolbarWnd)
|
||||
return;
|
||||
|
||||
const int ImageListID = 0;
|
||||
|
||||
HIMAGELIST hImageList;
|
||||
hImageList = ImageList_LoadImage(hInstance, MAKEINTRESOURCE(IDB_TOOLBAR), kToolbarImageSize, 0, CLR_DEFAULT, IMAGE_BITMAP, 0);
|
||||
|
||||
SendMessage(m_hToolbarWnd, TB_SETIMAGELIST, ImageListID, reinterpret_cast<LPARAM>(hImageList));
|
||||
SendMessage(m_hToolbarWnd, TB_SETEXTENDEDSTYLE, 0, TBSTYLE_EX_MIXEDBUTTONS);
|
||||
|
||||
const DWORD buttonStyles = BTNS_AUTOSIZE;
|
||||
|
||||
TBBUTTON tbButtons[] = {
|
||||
{ MAKELONG(0, ImageListID), IDM_HISTORY_BACKWARD, TBSTATE_ENABLED, buttonStyles, { }, 0, (INT_PTR)L"Back" },
|
||||
{ MAKELONG(1, ImageListID), IDM_HISTORY_FORWARD, TBSTATE_ENABLED, buttonStyles, { }, 0, (INT_PTR)L"Forward"},
|
||||
{ MAKELONG(2, ImageListID), IDM_RELOAD, TBSTATE_ENABLED, buttonStyles, { }, 0, (INT_PTR)L"Reload"},
|
||||
{ 0, 0, TBSTATE_ENABLED, BTNS_SEP, { }, 0, 0}, // URL bar
|
||||
};
|
||||
|
||||
SendMessage(m_hToolbarWnd, TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON), 0);
|
||||
SendMessage(m_hToolbarWnd, TB_ADDBUTTONS, _countof(tbButtons), reinterpret_cast<LPARAM>(&tbButtons));
|
||||
ShowWindow(m_hToolbarWnd, true);
|
||||
|
||||
m_hURLBarWnd = CreateWindow(L"EDIT", 0, WS_CHILD | WS_VISIBLE | WS_BORDER | ES_LEFT | ES_AUTOHSCROLL, 0, 0, 0, 0, m_hToolbarWnd, 0, hInstance, 0);
|
||||
|
||||
DefEditProc = reinterpret_cast<WNDPROC>(GetWindowLongPtr(m_hURLBarWnd, GWLP_WNDPROC));
|
||||
SetWindowLongPtr(m_hURLBarWnd, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(EditProc));
|
||||
}
|
||||
|
||||
void MainWindow::resizeToolbar(int parentWidth)
|
||||
{
|
||||
TBBUTTONINFO info { sizeof(TBBUTTONINFO), TBIF_BYINDEX | TBIF_SIZE };
|
||||
info.cx = parentWidth - m_toolbarItemsWidth;
|
||||
SendMessage(m_hToolbarWnd, TB_SETBUTTONINFO, kToolbarURLBarIndex, reinterpret_cast<LPARAM>(&info));
|
||||
SendMessage(m_hToolbarWnd, TB_AUTOSIZE, 0, 0);
|
||||
|
||||
RECT rect;
|
||||
SendMessage(m_hToolbarWnd, TB_GETITEMRECT, kToolbarURLBarIndex, reinterpret_cast<LPARAM>(&rect));
|
||||
MoveWindow(m_hURLBarWnd, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, true);
|
||||
}
|
||||
|
||||
void MainWindow::rescaleToolbar()
|
||||
{
|
||||
const float scaleFactor = WebCore::deviceScaleFactorForWindow(m_hMainWnd);
|
||||
const int scaledImageSize = kToolbarImageSize * scaleFactor;
|
||||
|
||||
TBBUTTONINFO info { sizeof(TBBUTTONINFO), TBIF_BYINDEX | TBIF_SIZE };
|
||||
|
||||
info.cx = 0;
|
||||
SendMessage(m_hToolbarWnd, TB_SETBUTTONINFO, kToolbarURLBarIndex, reinterpret_cast<LPARAM>(&info));
|
||||
SendMessage(m_hToolbarWnd, TB_AUTOSIZE, 0, 0);
|
||||
|
||||
int numItems = SendMessage(m_hToolbarWnd, TB_BUTTONCOUNT, 0, 0);
|
||||
|
||||
RECT rect;
|
||||
SendMessage(m_hToolbarWnd, TB_GETITEMRECT, numItems-1, reinterpret_cast<LPARAM>(&rect));
|
||||
m_toolbarItemsWidth = rect.right;
|
||||
}
|
||||
|
||||
bool MainWindow::init(HINSTANCE hInstance, WKPageConfigurationRef conf)
|
||||
{
|
||||
auto prefs = adoptWK(WKPreferencesCreate());
|
||||
|
||||
WKPageConfigurationSetPreferences(conf, prefs.get());
|
||||
WKPreferencesSetMediaCapabilitiesEnabled(prefs.get(), false);
|
||||
WKPreferencesSetDeveloperExtrasEnabled(prefs.get(), true);
|
||||
if (s_disableAcceleratedCompositing)
|
||||
WKPreferencesSetAcceleratedCompositingEnabled(prefs.get(), false);
|
||||
|
||||
m_configuration = conf;
|
||||
|
||||
registerClass(hInstance);
|
||||
|
||||
auto title = loadString(IDS_APP_TITLE);
|
||||
|
||||
m_hMainWnd = CreateWindowExW(s_headless ? WS_EX_NOACTIVATE : 0, s_windowClass.c_str(), title.c_str(),
|
||||
WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, 0, 0, hInstance, this);
|
||||
|
||||
if (!m_hMainWnd)
|
||||
return false;
|
||||
|
||||
if (!s_headless) {
|
||||
createToolbar(hInstance);
|
||||
if (!m_hToolbarWnd)
|
||||
return false;
|
||||
}
|
||||
|
||||
m_browserWindow.reset(new WebKitBrowserWindow(*this, m_hMainWnd, conf));
|
||||
|
||||
updateDeviceScaleFactor();
|
||||
resizeSubViews();
|
||||
|
||||
if (s_headless) {
|
||||
auto menu = GetMenu(m_hMainWnd);
|
||||
SetMenu(m_hMainWnd, NULL);
|
||||
DestroyMenu(menu);
|
||||
} else {
|
||||
SetFocus(m_hURLBarWnd);
|
||||
ShowWindow(m_hMainWnd, SW_SHOW);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void MainWindow::resizeSubViews()
|
||||
{
|
||||
RECT rcClient;
|
||||
GetClientRect(m_hMainWnd, &rcClient);
|
||||
if (s_headless) {
|
||||
MoveWindow(m_browserWindow->hwnd(), 0, 0, rcClient.right, rcClient.bottom, true);
|
||||
return;
|
||||
}
|
||||
|
||||
resizeToolbar(rcClient.right);
|
||||
|
||||
RECT rect;
|
||||
GetWindowRect(m_hToolbarWnd, &rect);
|
||||
POINT toolbarBottom = { 0, rect.bottom };
|
||||
ScreenToClient(m_hMainWnd, &toolbarBottom);
|
||||
auto height = toolbarBottom.y;
|
||||
MoveWindow(m_browserWindow->hwnd(), 0, height, rcClient.right, rcClient.bottom - height, true);
|
||||
}
|
||||
|
||||
LRESULT CALLBACK MainWindow::WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
LRESULT result = 0;
|
||||
MainWindow* thisWindow = reinterpret_cast<MainWindow*>(GetWindowLongPtr(hWnd, GWLP_USERDATA));
|
||||
if (!thisWindow && message != WM_CREATE)
|
||||
return DefWindowProc(hWnd, message, wParam, lParam);
|
||||
|
||||
switch (message) {
|
||||
case WM_ACTIVATE:
|
||||
switch (LOWORD(wParam)) {
|
||||
case WA_ACTIVE:
|
||||
case WA_CLICKACTIVE:
|
||||
SetFocus(thisWindow->browserWindow()->hwnd());
|
||||
}
|
||||
break;
|
||||
case WM_CREATE:
|
||||
SetWindowLongPtr(hWnd, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(reinterpret_cast<LPCREATESTRUCT>(lParam)->lpCreateParams));
|
||||
break;
|
||||
case WM_APPCOMMAND: {
|
||||
auto cmd = GET_APPCOMMAND_LPARAM(lParam);
|
||||
switch (cmd) {
|
||||
case APPCOMMAND_BROWSER_BACKWARD:
|
||||
thisWindow->browserWindow()->navigateForwardOrBackward(false);
|
||||
result = 1;
|
||||
break;
|
||||
case APPCOMMAND_BROWSER_FORWARD:
|
||||
thisWindow->browserWindow()->navigateForwardOrBackward(true);
|
||||
result = 1;
|
||||
break;
|
||||
case APPCOMMAND_BROWSER_REFRESH:
|
||||
thisWindow->browserWindow()->reload();
|
||||
result = 1;
|
||||
break;
|
||||
case APPCOMMAND_BROWSER_STOP:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case WM_COMMAND: {
|
||||
int wmId = LOWORD(wParam);
|
||||
int wmEvent = HIWORD(wParam);
|
||||
switch (wmEvent) {
|
||||
case 0: // Menu or BN_CLICKED
|
||||
case 1: // Accelerator
|
||||
break;
|
||||
default:
|
||||
return DefWindowProc(hWnd, message, wParam, lParam);
|
||||
}
|
||||
// Parse the menu selections:
|
||||
switch (wmId) {
|
||||
case IDC_URL_BAR:
|
||||
thisWindow->onURLBarEnter();
|
||||
break;
|
||||
case IDM_NEW_WINDOW: {
|
||||
auto* newWindow = new MainWindow();
|
||||
newWindow->init(hInst, thisWindow->m_configuration.get());
|
||||
break;
|
||||
}
|
||||
case IDM_CLOSE_WINDOW:
|
||||
PostMessage(hWnd, WM_CLOSE, 0, 0);
|
||||
break;
|
||||
case IDM_ABOUT:
|
||||
DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
|
||||
break;
|
||||
case IDM_WEB_INSPECTOR:
|
||||
thisWindow->browserWindow()->launchInspector();
|
||||
break;
|
||||
case IDM_HISTORY_BACKWARD:
|
||||
case IDM_HISTORY_FORWARD:
|
||||
thisWindow->browserWindow()->navigateForwardOrBackward(wmId == IDM_HISTORY_FORWARD);
|
||||
break;
|
||||
case IDM_ACTUAL_SIZE:
|
||||
thisWindow->browserWindow()->resetZoom();
|
||||
break;
|
||||
case IDM_RELOAD:
|
||||
thisWindow->browserWindow()->reload();
|
||||
break;
|
||||
case IDM_ZOOM_IN:
|
||||
thisWindow->browserWindow()->zoomIn();
|
||||
break;
|
||||
case IDM_ZOOM_OUT:
|
||||
thisWindow->browserWindow()->zoomOut();
|
||||
break;
|
||||
default:
|
||||
if (!thisWindow->toggleMenuItem(wmId))
|
||||
return DefWindowProc(hWnd, message, wParam, lParam);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case WM_NCDESTROY:
|
||||
SetWindowLongPtr(hWnd, GWLP_USERDATA, 0);
|
||||
delete thisWindow;
|
||||
if (s_controlledRemotely || s_numInstances > 0)
|
||||
return 0;
|
||||
PostQuitMessage(0);
|
||||
break;
|
||||
case WM_SIZE:
|
||||
thisWindow->resizeSubViews();
|
||||
break;
|
||||
case WM_DPICHANGED: {
|
||||
thisWindow->updateDeviceScaleFactor();
|
||||
auto& rect = *reinterpret_cast<RECT*>(lParam);
|
||||
SetWindowPos(hWnd, nullptr, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, SWP_NOZORDER | SWP_NOACTIVATE);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return DefWindowProc(hWnd, message, wParam, lParam);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static bool menuItemIsChecked(const MENUITEMINFO& info)
|
||||
{
|
||||
return info.fState & MFS_CHECKED;
|
||||
}
|
||||
|
||||
bool MainWindow::toggleMenuItem(UINT menuID)
|
||||
{
|
||||
if (s_headless)
|
||||
return (INT_PTR)FALSE;
|
||||
|
||||
HMENU menu = ::GetMenu(hwnd());
|
||||
|
||||
MENUITEMINFO info = { };
|
||||
info.cbSize = sizeof(info);
|
||||
info.fMask = MIIM_STATE;
|
||||
|
||||
if (!::GetMenuItemInfo(menu, menuID, FALSE, &info))
|
||||
return false;
|
||||
|
||||
BOOL newState = !menuItemIsChecked(info);
|
||||
info.fState = (newState) ? MFS_CHECKED : MFS_UNCHECKED;
|
||||
::SetMenuItemInfo(menu, menuID, FALSE, &info);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
LRESULT CALLBACK EditProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch (message) {
|
||||
case WM_SETFOCUS:
|
||||
PostMessage(hWnd, EM_SETSEL, 0, -1);
|
||||
break;
|
||||
case WM_CHAR:
|
||||
if (wParam == 13) {
|
||||
// Enter Key
|
||||
::PostMessage(GetParent(hWnd), static_cast<UINT>(WM_COMMAND), MAKELPARAM(IDC_URL_BAR, 0), 0);
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return CallWindowProc(DefEditProc, hWnd, message, wParam, lParam);
|
||||
}
|
||||
|
||||
// Message handler for about box.
|
||||
INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(lParam);
|
||||
switch (message) {
|
||||
case WM_INITDIALOG:
|
||||
return (INT_PTR)TRUE;
|
||||
|
||||
case WM_COMMAND:
|
||||
if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) {
|
||||
EndDialog(hDlg, LOWORD(wParam));
|
||||
return (INT_PTR)TRUE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return (INT_PTR)FALSE;
|
||||
}
|
||||
|
||||
void MainWindow::loadURL(std::wstring url)
|
||||
{
|
||||
if (::PathFileExists(url.c_str()) || ::PathIsUNC(url.c_str())) {
|
||||
wchar_t fileURL[INTERNET_MAX_URL_LENGTH];
|
||||
DWORD fileURLLength = _countof(fileURL);
|
||||
|
||||
if (SUCCEEDED(::UrlCreateFromPath(url.c_str(), fileURL, &fileURLLength, 0)))
|
||||
url = fileURL;
|
||||
}
|
||||
if (url.find(L"://") == url.npos && url.find(L"about:blank") == url.npos)
|
||||
url = L"http://" + url;
|
||||
|
||||
if (FAILED(m_browserWindow->loadURL(_bstr_t(url.c_str()))))
|
||||
return;
|
||||
|
||||
if (!s_headless)
|
||||
SetFocus(m_browserWindow->hwnd());
|
||||
}
|
||||
|
||||
void MainWindow::onURLBarEnter()
|
||||
{
|
||||
if (s_headless)
|
||||
return;
|
||||
wchar_t url[INTERNET_MAX_URL_LENGTH];
|
||||
GetWindowText(m_hURLBarWnd, url, INTERNET_MAX_URL_LENGTH);
|
||||
loadURL(url);
|
||||
}
|
||||
|
||||
void MainWindow::updateDeviceScaleFactor()
|
||||
{
|
||||
if (s_headless)
|
||||
return;
|
||||
if (m_hURLBarFont)
|
||||
::DeleteObject(m_hURLBarFont);
|
||||
|
||||
rescaleToolbar();
|
||||
|
||||
RECT rect;
|
||||
GetClientRect(m_hToolbarWnd, &rect);
|
||||
int fontHeight = 20;
|
||||
|
||||
m_hURLBarFont = ::CreateFont(fontHeight, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, DEFAULT_CHARSET,
|
||||
OUT_TT_ONLY_PRECIS, CLIP_DEFAULT_PRECIS, CLEARTYPE_QUALITY, FF_DONTCARE, L"Tahoma");
|
||||
::SendMessage(m_hURLBarWnd, static_cast<UINT>(WM_SETFONT), reinterpret_cast<WPARAM>(m_hURLBarFont), TRUE);
|
||||
}
|
||||
|
||||
void MainWindow::activeURLChanged(std::wstring url)
|
||||
{
|
||||
if (s_headless)
|
||||
return;
|
||||
SetWindowText(m_hURLBarWnd, url.c_str());
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Copyright (C) 2018 Sony Interactive Entertainment Inc.
|
||||
*
|
||||
* 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. ``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
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "WebKitBrowserWindow.h"
|
||||
|
||||
#include <WebKit/WKBase.h>
|
||||
#include <WebKit/WKRetainPtr.h>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
class MainWindow : public BrowserWindowClient {
|
||||
public:
|
||||
static void configure(bool controlledRemotely, bool disableAcceleratedCompositing);
|
||||
|
||||
MainWindow();
|
||||
|
||||
~MainWindow();
|
||||
bool init(HINSTANCE hInstance, WKPageConfigurationRef);
|
||||
|
||||
void resizeSubViews();
|
||||
HWND hwnd() const { return m_hMainWnd; }
|
||||
WebKitBrowserWindow* browserWindow() const { return m_browserWindow.get(); }
|
||||
|
||||
void loadURL(std::wstring);
|
||||
|
||||
static bool isInstance(HWND);
|
||||
|
||||
private:
|
||||
static LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
|
||||
static void registerClass(HINSTANCE hInstance);
|
||||
static std::wstring s_windowClass;
|
||||
static size_t s_numInstances;
|
||||
static bool s_controlledRemotely;
|
||||
static bool s_disableAcceleratedCompositing;
|
||||
|
||||
bool toggleMenuItem(UINT menuID);
|
||||
void onURLBarEnter();
|
||||
void updateDeviceScaleFactor();
|
||||
|
||||
void createToolbar(HINSTANCE);
|
||||
void resizeToolbar(int);
|
||||
void rescaleToolbar();
|
||||
|
||||
// BrowserWindowClient
|
||||
void activeURLChanged(std::wstring) final;
|
||||
|
||||
HWND m_hMainWnd { nullptr };
|
||||
HWND m_hToolbarWnd { nullptr };
|
||||
HWND m_hURLBarWnd { nullptr };
|
||||
HWND m_hProgressIndicator { nullptr };
|
||||
HWND m_hCacheWnd { nullptr };
|
||||
HGDIOBJ m_hURLBarFont { nullptr };
|
||||
// WKPageConfigurationRef retains page and WebKitBrowserWindow retains page via view
|
||||
// make sure view is deleted after the page.
|
||||
std::unique_ptr<WebKitBrowserWindow> m_browserWindow;
|
||||
WKRetainPtr<WKPageConfigurationRef> m_configuration;
|
||||
int m_toolbarItemsWidth { };
|
||||
};
|
||||
|
After Width: | Height: | Size: 111 KiB |
@@ -0,0 +1,354 @@
|
||||
// Microsoft Visual C++ generated resource script.
|
||||
//
|
||||
#include "PlaywrightLibResource.h"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 2 resource.
|
||||
//
|
||||
#define APSTUDIO_HIDDEN_SYMBOLS
|
||||
#include "windows.h"
|
||||
#undef APSTUDIO_HIDDEN_SYMBOLS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// English (United States) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
|
||||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||
#pragma code_page(1252)
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Icon
|
||||
//
|
||||
|
||||
// Icon with lowest ID value placed first to ensure application icon
|
||||
// remains consistent on all systems.
|
||||
IDI_PLAYWRIGHT ICON "Playwright.ico"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Menu
|
||||
//
|
||||
|
||||
IDC_PLAYWRIGHT MENU
|
||||
BEGIN
|
||||
POPUP "&File"
|
||||
BEGIN
|
||||
MENUITEM "New Window\tCtrl-N" IDM_NEW_WINDOW
|
||||
MENUITEM "Close\tCtrl-W", IDM_CLOSE_WINDOW
|
||||
END
|
||||
POPUP "&View"
|
||||
BEGIN
|
||||
MENUITEM "Actual Size\tCtrl+0", IDM_ACTUAL_SIZE
|
||||
MENUITEM "Zoom In\tCtrl++", IDM_ZOOM_IN
|
||||
MENUITEM "Zoom Out\tCtrl+-", IDM_ZOOM_OUT
|
||||
MENUITEM "Invert Colors", IDM_INVERT_COLORS
|
||||
END
|
||||
POPUP "&History"
|
||||
BEGIN
|
||||
MENUITEM "Reload\tCtrl-R", IDM_RELOAD
|
||||
MENUITEM "Back", IDM_HISTORY_BACKWARD
|
||||
MENUITEM "Forward", IDM_HISTORY_FORWARD
|
||||
END
|
||||
POPUP "D&evelop"
|
||||
BEGIN
|
||||
MENUITEM "Show Web Inspector", IDM_WEB_INSPECTOR
|
||||
END
|
||||
POPUP "&Help"
|
||||
BEGIN
|
||||
MENUITEM "&About ...", IDM_ABOUT
|
||||
END
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Accelerator
|
||||
//
|
||||
|
||||
IDC_PLAYWRIGHT ACCELERATORS
|
||||
BEGIN
|
||||
"/", IDM_ABOUT, ASCII, ALT, NOINVERT
|
||||
"0", IDM_ACTUAL_SIZE, VIRTKEY, CONTROL, NOINVERT
|
||||
"?", IDM_ABOUT, ASCII, ALT, NOINVERT
|
||||
"R", IDM_RELOAD, VIRTKEY, CONTROL, NOINVERT
|
||||
"N", IDM_NEW_WINDOW, VIRTKEY, CONTROL, NOINVERT
|
||||
VK_ADD, IDM_ZOOM_IN, VIRTKEY, CONTROL, NOINVERT
|
||||
VK_OEM_MINUS, IDM_ZOOM_OUT, VIRTKEY, CONTROL, NOINVERT
|
||||
VK_OEM_PLUS, IDM_ZOOM_IN, VIRTKEY, CONTROL, NOINVERT
|
||||
VK_SUBTRACT, IDM_ZOOM_OUT, VIRTKEY, CONTROL, NOINVERT
|
||||
END
|
||||
|
||||
IDR_ACCELERATORS_PRE ACCELERATORS
|
||||
BEGIN
|
||||
"W", IDM_CLOSE_WINDOW, VIRTKEY, CONTROL, NOINVERT
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Dialog
|
||||
//
|
||||
|
||||
IDD_ABOUTBOX DIALOGEX 22, 17, 230, 41
|
||||
STYLE DS_SETFONT | DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "About"
|
||||
FONT 8, "MS Shell Dlg", 0, 0, 0x0
|
||||
BEGIN
|
||||
ICON IDI_PLAYWRIGHT,IDC_MYICON,14,9,20,20
|
||||
LTEXT "Playwright Version 1.1",IDC_STATIC,49,10,119,8
|
||||
LTEXT "Copyright (C) 2015-2019",IDC_STATIC,49,20,119,8
|
||||
DEFPUSHBUTTON "OK",IDOK,186,10,30,11,WS_GROUP
|
||||
END
|
||||
|
||||
IDD_CACHES DIALOGEX 0, 0, 401, 456
|
||||
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Dialog"
|
||||
FONT 8, "MS Shell Dlg", 400, 0, 0x1
|
||||
BEGIN
|
||||
DEFPUSHBUTTON "OK",IDOK,287,435,50,14
|
||||
PUSHBUTTON "Cancel",IDCANCEL,344,435,50,14
|
||||
GROUPBOX "FastMalloc",IDC_STATIC,208,14,186,67
|
||||
GROUPBOX "WebCore Cache",IDC_STATIC,17,83,376,105
|
||||
GROUPBOX "JavaScript Heap",IDC_STATIC,18,193,376,168
|
||||
GROUPBOX "Site Icon Database",IDC_STATIC,18,366,142,65
|
||||
GROUPBOX "Font and Glyph Caches",IDC_STATIC,168,366,226,66
|
||||
GROUPBOX "CFURLCache",IDC_STATIC,7,14,197,67
|
||||
PUSHBUTTON "Empty URLCache",IDC_EMPTY_URL_CACHE,131,63,69,14,WS_DISABLED
|
||||
PUSHBUTTON "Return Free Memory",IDC_RETURN_FREE_MEMORY,308,63,76,14,WS_DISABLED
|
||||
PUSHBUTTON "Empty WebCore Cache",IDC_EMPTY_WEBCORE_CACHE,21,170,83,14,WS_DISABLED
|
||||
CONTROL "Disable WebCore Cache",IDC_CHECK1,"Button",BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP,119,172,93,10
|
||||
PUSHBUTTON "Garbage Collect JavaScript Objects",IDC_GC_JSC,253,343,135,14,WS_DISABLED
|
||||
RTEXT "Reserved VM",IDC_STATIC,212,26,67,9
|
||||
RTEXT "0",IDC_RESERVED_VM,290,26,94,8
|
||||
RTEXT "Committed VM",IDC_STATIC,211,39,67,8
|
||||
RTEXT "0",IDC_COMMITTED_VM,290,39,94,8
|
||||
RTEXT "Free List Bytes",IDC_STATIC,211,52,67,8
|
||||
RTEXT "0",IDC_FREE_LIST_BYTES,290,52,94,8
|
||||
RTEXT "Images",IDC_STATIC,37,106,24,8
|
||||
RTEXT "CSS",IDC_STATIC,47,116,14,8
|
||||
RTEXT "XSL",IDC_STATIC,49,126,12,8
|
||||
RTEXT "JavaScript",IDC_STATIC,27,135,34,8
|
||||
RTEXT "Total",IDC_STATIC,43,146,17,8
|
||||
LTEXT "Objects",IDC_STATIC,111,96,26,8
|
||||
LTEXT "Bytes",IDC_STATIC,175,96,19,8
|
||||
LTEXT "Live",IDC_STATIC,232,96,14,8
|
||||
LTEXT "Decoded",IDC_STATIC,284,96,29,8
|
||||
LTEXT "Purgeable",IDC_STATIC,351,96,33,8
|
||||
RTEXT "0",IDC_IMAGES_OBJECT_COUNT,100,106,32,8
|
||||
RTEXT "0",IDC_CSS_OBJECT_COUNT,100,116,32,8
|
||||
RTEXT "0",IDC_XSL_OBJECT_COUNT,100,126,32,8
|
||||
RTEXT "0",IDC_JSC_OBJECT_COUNT,100,135,32,8
|
||||
RTEXT "0",IDC_TOTAL_OBJECT_COUNT,100,146,32,8
|
||||
RTEXT "0",IDC_IMAGES_BYTES,162,106,32,8
|
||||
RTEXT "0",IDC_CSS_BYTES,162,116,32,8
|
||||
RTEXT "0",IDC_XSL_BYTES,162,126,32,8
|
||||
RTEXT "0",IDC_JSC_BYTES,162,135,32,8
|
||||
RTEXT "0",IDC_TOTAL_BYTES,162,146,32,8
|
||||
RTEXT "0",IDC_IMAGES_LIVE_COUNT,221,106,32,8
|
||||
RTEXT "0",IDC_CSS_LIVE_COUNT,221,116,32,8
|
||||
RTEXT "0",IDC_XSL_LIVE_COUNT,221,126,32,8
|
||||
RTEXT "0",IDC_JSC_LIVE_COUNT,221,135,32,8
|
||||
RTEXT "0",IDC_TOTAL_LIVE_COUNT,221,146,32,8
|
||||
RTEXT "0",IDC_IMAGES_DECODED_COUNT,284,106,32,8
|
||||
RTEXT "0",IDC_CSS_DECODED_COUNT,284,116,32,8
|
||||
RTEXT "0",IDC_XSL_DECODED_COUNT,284,126,32,8
|
||||
RTEXT "0",IDC_JSC_DECODED_COUNT,284,135,32,8
|
||||
RTEXT "0",IDC_TOTAL_DECODED,284,146,32,8
|
||||
RTEXT "0",IDC_IMAGES_PURGEABLE_COUNT,354,106,32,8
|
||||
RTEXT "0",IDC_CSS_PURGEABLE_COUNT,354,116,32,8
|
||||
RTEXT "0",IDC_XSL_PURGEABLE_COUNT,354,126,32,8
|
||||
RTEXT "0",IDC_JSC_PURGEABLE_COUNT,354,135,32,8
|
||||
RTEXT "0",IDC_TOTAL_PURGEABLE,354,146,32,8
|
||||
RTEXT "Total Objects",IDC_STATIC,63,207,44,8
|
||||
RTEXT "Global Objects",IDC_STATIC,56,217,51,8
|
||||
RTEXT "Protected Objects",IDC_STATIC,48,227,59,8
|
||||
RTEXT "0",IDC_TOTAL_JSC_HEAP_OBJECTS,127,207,56,8
|
||||
RTEXT "0",IDC_GLOBAL_JSC_HEAP_OBJECTS,127,217,56,8
|
||||
RTEXT "0",IDC_PROTECTED_JSC_HEAP_OBJECTS,127,227,56,8
|
||||
RTEXT "Size",IDC_STATIC56,223,207,14,8
|
||||
RTEXT "Free",IDC_STATIC57,222,217,16,8
|
||||
RTEXT "0",IDC_JSC_HEAP_SIZE,270,207,56,8
|
||||
RTEXT "0",IDC_JSC_HEAP_FREE,270,217,56,8
|
||||
PUSHBUTTON "Purge Inactive Font Data",IDC_BUTTON5,293,415,95,14,WS_DISABLED
|
||||
LTEXT "Total Font Data Objects",IDC_STATIC,208,379,78,8
|
||||
LTEXT "Inactive Font Data Objects",IDC_STATIC,198,390,88,8
|
||||
LTEXT "Glyph Pages",IDC_STATIC,246,402,40,8
|
||||
RTEXT "0",IDC_TOTAL_FONT_OBJECTS,329,379,56,8
|
||||
RTEXT "0",IDC_INACTIVE_FONT_OBJECTS,329,390,56,8
|
||||
RTEXT "0",IDC_GLYPH_PAGES,329,402,56,8
|
||||
LTEXT "Page URL Mappings",IDC_STATIC,33,380,64,8
|
||||
LTEXT "Retained Page URLs",IDC_STATIC,31,390,66,8
|
||||
LTEXT "Site Icon Records",IDC_STATIC,40,400,57,8
|
||||
LTEXT "Site Icons with Data",IDC_STATIC,32,410,65,8
|
||||
RTEXT "0",IDC_PAGE_URL_MAPPINGS,101,380,52,8
|
||||
RTEXT "0",IDC_RETAINED_PAGE_URLS,101,390,52,8
|
||||
RTEXT "0",IDC_SITE_ICON_RECORDS,101,400,52,8
|
||||
RTEXT "0",IDC_SITE_ICONS_WITH_DATA,101,410,52,8
|
||||
END
|
||||
|
||||
IDD_AUTH DIALOGEX 0, 0, 231, 119
|
||||
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Authentication Required"
|
||||
FONT 8, "MS Shell Dlg", 400, 0, 0x1
|
||||
BEGIN
|
||||
DEFPUSHBUTTON "Sign In",IDOK,116,98,50,14
|
||||
PUSHBUTTON "Cancel",IDCANCEL,174,98,50,14
|
||||
LTEXT "Realm",IDC_REALM_TEXT,67,21,157,8
|
||||
RTEXT "User Name:",IDC_STATIC,7,41,57,8
|
||||
EDITTEXT IDC_AUTH_USER,67,39,157,14,ES_AUTOHSCROLL
|
||||
RTEXT "Password:",IDC_STATIC,7,66,57,8
|
||||
EDITTEXT IDC_AUTH_PASSWORD,67,64,157,14,ES_PASSWORD | ES_AUTOHSCROLL
|
||||
END
|
||||
|
||||
IDD_PROXY DIALOGEX 0, 0, 310, 176
|
||||
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Proxy Configuration"
|
||||
FONT 8, "MS Shell Dlg", 400, 0, 0x1
|
||||
BEGIN
|
||||
DEFPUSHBUTTON "OK",IDOK,199,155,50,14
|
||||
PUSHBUTTON "Cancel",IDCANCEL,253,155,50,14
|
||||
CONTROL "Use system default proxy configuration.",IDC_PROXY_DEFAULT,
|
||||
"Button",BS_AUTORADIOBUTTON | WS_GROUP,22,15,226,10
|
||||
CONTROL "Use custom proxy configuration:",IDC_PROXY_CUSTOM,
|
||||
"Button",BS_AUTORADIOBUTTON,22,33,226,10
|
||||
CONTROL "Don't use proxy.",IDC_PROXY_DISABLE,"Button",BS_AUTORADIOBUTTON,22,117,226,10
|
||||
EDITTEXT IDC_PROXY_URL,76,52,193,14,ES_AUTOHSCROLL
|
||||
EDITTEXT IDC_PROXY_EXCLUDE,76,85,193,14,ES_AUTOHSCROLL
|
||||
LTEXT "URL:",IDC_STATIC,30,55,43,8,0,WS_EX_RIGHT
|
||||
LTEXT "Excude list:",IDC_STATIC,30,88,43,8,0,WS_EX_RIGHT
|
||||
LTEXT "Example: http://192.168.0.2:8000",IDC_STATIC,80,68,194,8
|
||||
LTEXT "Comma separated hostnames.",IDC_STATIC,80,101,194,8
|
||||
END
|
||||
|
||||
IDD_SERVER_TRUST DIALOGEX 0, 0, 319, 184
|
||||
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Server Trust Evaluation Request"
|
||||
FONT 8, "MS Shell Dlg", 400, 0, 0x1
|
||||
BEGIN
|
||||
DEFPUSHBUTTON "Yes",IDOK,197,163,50,14
|
||||
PUSHBUTTON "No",IDCANCEL,262,163,50,14
|
||||
LTEXT "Certificate information",IDC_STATIC,7,7,294,17
|
||||
EDITTEXT IDC_SERVER_TRUST_TEXT,7,24,305,130,ES_MULTILINE | ES_READONLY | WS_VSCROLL | WS_HSCROLL | NOT WS_TABSTOP
|
||||
END
|
||||
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TEXTINCLUDE
|
||||
//
|
||||
|
||||
1 TEXTINCLUDE
|
||||
BEGIN
|
||||
"PlaywrightLibResource.h\0"
|
||||
END
|
||||
|
||||
2 TEXTINCLUDE
|
||||
BEGIN
|
||||
"#define APSTUDIO_HIDDEN_SYMBOLS\r\n"
|
||||
"#include ""windows.h""\r\n"
|
||||
"#undef APSTUDIO_HIDDEN_SYMBOLS\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
3 TEXTINCLUDE
|
||||
BEGIN
|
||||
"\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DESIGNINFO
|
||||
//
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
GUIDELINES DESIGNINFO
|
||||
BEGIN
|
||||
IDD_ABOUTBOX, DIALOG
|
||||
BEGIN
|
||||
END
|
||||
|
||||
IDD_CACHES, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 394
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 449
|
||||
END
|
||||
|
||||
IDD_AUTH, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 224
|
||||
VERTGUIDE, 64
|
||||
VERTGUIDE, 67
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 92
|
||||
HORZGUIDE, 25
|
||||
HORZGUIDE, 50
|
||||
END
|
||||
|
||||
IDD_PROXY, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 303
|
||||
VERTGUIDE, 22
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 169
|
||||
END
|
||||
|
||||
IDD_SERVER_TRUST, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 312
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 177
|
||||
END
|
||||
END
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Bitmap
|
||||
//
|
||||
|
||||
IDB_TOOLBAR BITMAP "toolbar.bmp"
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// String Table
|
||||
//
|
||||
|
||||
STRINGTABLE
|
||||
BEGIN
|
||||
IDS_APP_TITLE "Playwright"
|
||||
IDC_PLAYWRIGHT "Playwright"
|
||||
END
|
||||
|
||||
#endif // English (United States) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 3 resource.
|
||||
//
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#endif // not APSTUDIO_INVOKED
|
||||
|
||||
@@ -0,0 +1,115 @@
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Visual C++ generated include file.
|
||||
// Used by PlaywrightLib.rc
|
||||
//
|
||||
#define IDC_MYICON 2
|
||||
#define IDD_PLAYWRIGHT_DIALOG 102
|
||||
#define IDS_APP_TITLE 103
|
||||
#define IDD_ABOUTBOX 103
|
||||
#define IDM_ABOUT 104
|
||||
#define IDI_PLAYWRIGHT 107
|
||||
#define IDC_PLAYWRIGHT 109
|
||||
#define IDM_WEB_INSPECTOR 120
|
||||
#define IDM_INVERT_COLORS 125
|
||||
#define IDR_MAINFRAME 128
|
||||
#define IDD_CACHES 129
|
||||
#define IDM_HISTORY_BACKWARD 130
|
||||
#define IDD_USER_AGENT 130
|
||||
#define IDM_HISTORY_FORWARD 131
|
||||
#define IDM_HISTORY_LINK0 150
|
||||
#define IDM_HISTORY_LINK1 151
|
||||
#define IDM_HISTORY_LINK2 152
|
||||
#define IDM_HISTORY_LINK3 153
|
||||
#define IDM_HISTORY_LINK4 154
|
||||
#define IDM_HISTORY_LINK5 155
|
||||
#define IDM_HISTORY_LINK6 156
|
||||
#define IDM_HISTORY_LINK7 157
|
||||
#define IDM_HISTORY_LINK8 158
|
||||
#define IDM_HISTORY_LINK9 159
|
||||
#define IDT_UPDATE_STATS 160
|
||||
#define IDM_ACTUAL_SIZE 172
|
||||
#define IDM_ZOOM_IN 173
|
||||
#define IDM_ZOOM_OUT 174
|
||||
#define IDD_AUTH 176
|
||||
#define IDD_PROXY 178
|
||||
#define IDD_SERVER_TRUST 179
|
||||
#define IDR_ACCELERATORS_PRE 180
|
||||
#define IDB_TOOLBAR 181
|
||||
#define IDC_EMPTY_URL_CACHE 1000
|
||||
#define IDC_RETURN_FREE_MEMORY 1001
|
||||
#define IDC_EMPTY_WEBCORE_CACHE 1002
|
||||
#define IDC_CHECK1 1003
|
||||
#define IDC_HEAP_OBJECTS 1005
|
||||
#define IDC_GC_JSC 1006
|
||||
#define IDC_RESERVED_VM 1007
|
||||
#define IDC_COMMITTED_VM 1008
|
||||
#define IDC_FREE_LIST_BYTES 1009
|
||||
#define IDC_IMAGES_OBJECT_COUNT 1011
|
||||
#define IDC_CSS_OBJECT_COUNT 1012
|
||||
#define IDC_XSL_OBJECT_COUNT 1013
|
||||
#define IDC_JSC_OBJECT_COUNT 1014
|
||||
#define IDC_TOTAL_OBJECT_COUNT 1015
|
||||
#define IDC_IMAGES_BYTES 1016
|
||||
#define IDC_CSS_BYTES 1017
|
||||
#define IDC_XSL_BYTES 1018
|
||||
#define IDC_JSC_BYTES 1019
|
||||
#define IDC_TOTAL_BYTES 1020
|
||||
#define IDC_IMAGES_LIVE_COUNT 1021
|
||||
#define IDC_CSS_LIVE_COUNT 1022
|
||||
#define IDC_XSL_LIVE_COUNT 1023
|
||||
#define IDC_JSC_LIVE_COUNT 1024
|
||||
#define IDC_TOTAL_LIVE_COUNT 1025
|
||||
#define IDC_IMAGES_DECODED_COUNT 1026
|
||||
#define IDC_CSS_DECODED_COUNT 1027
|
||||
#define IDC_XSL_DECODED_COUNT 1028
|
||||
#define IDC_JSC_DECODED_COUNT 1029
|
||||
#define IDC_TOTAL_DECODED 1030
|
||||
#define IDC_IMAGES_PURGEABLE_COUNT 1031
|
||||
#define IDC_CSS_PURGEABLE_COUNT 1032
|
||||
#define IDC_XSL_PURGEABLE_COUNT 1033
|
||||
#define IDC_JSC_PURGEABLE_COUNT 1034
|
||||
#define IDC_TOTAL_PURGEABLE 1035
|
||||
#define IDC_TOTAL_JSC_HEAP_OBJECTS 1036
|
||||
#define IDC_GLOBAL_JSC_HEAP_OBJECTS 1037
|
||||
#define IDC_PROTECTED_JSC_HEAP_OBJECTS 1038
|
||||
#define IDC_STATIC56 1039
|
||||
#define IDC_STATIC57 1040
|
||||
#define IDC_JSC_HEAP_SIZE 1041
|
||||
#define IDC_JSC_HEAP_FREE 1042
|
||||
#define IDC_BUTTON5 1043
|
||||
#define IDC_TOTAL_FONT_OBJECTS 1044
|
||||
#define IDC_Message 1044
|
||||
#define IDC_INACTIVE_FONT_OBJECTS 1045
|
||||
#define IDC_GLYPH_PAGES 1046
|
||||
#define IDC_PAGE_URL_MAPPINGS 1047
|
||||
#define IDC_RETAINED_PAGE_URLS 1048
|
||||
#define IDC_SITE_ICON_RECORDS 1049
|
||||
#define IDC_TOTAL_FONT_OBJECTS5 1050
|
||||
#define IDC_SITE_ICONS_WITH_DATA 1051
|
||||
#define IDC_USER_AGENT_INPUT 1052
|
||||
#define IDC_AUTH_USER 1053
|
||||
#define IDC_AUTH_PASSWORD 1054
|
||||
#define IDC_URL_BAR 1055
|
||||
#define IDC_REALM_TEXT 1056
|
||||
#define IDC_PROXY_URL 1057
|
||||
#define IDC_PROXY_DEFAULT 1058
|
||||
#define IDC_PROXY_CUSTOM 1059
|
||||
#define IDC_PROXY_EXCLUDE 1060
|
||||
#define IDC_PROXY_DISABLE 1061
|
||||
#define IDC_SERVER_TRUST_TEXT 1062
|
||||
#define IDM_NEW_WINDOW 32776
|
||||
#define IDM_RELOAD 32779
|
||||
#define IDM_CLOSE_WINDOW 32780
|
||||
#define IDC_STATIC -1
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NO_MFC 1
|
||||
#define _APS_NEXT_RESOURCE_VALUE 182
|
||||
#define _APS_NEXT_COMMAND_VALUE 32783
|
||||
#define _APS_NEXT_CONTROL_VALUE 1063
|
||||
#define _APS_NEXT_SYMED_VALUE 110
|
||||
#endif
|
||||
#endif
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright (C) 2013 Alex Christensen. 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.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
// This file is to make it easier for users to manage changes to the internals of Playwright
|
||||
|
||||
static void processCrashReport(const wchar_t* fileName) { ::MessageBox(0, fileName, L"Crash Report", MB_OK); }
|
||||
@@ -0,0 +1,20 @@
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Visual C++ generated include file.
|
||||
// Used by PlaywrightLauncher.rc
|
||||
//
|
||||
#define IDD_PLAYWRIGHT_DIALOG 102
|
||||
#define IDI_PLAYWRIGHT 107
|
||||
#define IDR_MAINFRAME 128
|
||||
#define IDC_STATIC -1
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NO_MFC 1
|
||||
#define _APS_NEXT_RESOURCE_VALUE 129
|
||||
#define _APS_NEXT_COMMAND_VALUE 32771
|
||||
#define _APS_NEXT_CONTROL_VALUE 1000
|
||||
#define _APS_NEXT_SYMED_VALUE 110
|
||||
#endif
|
||||
#endif
|
||||
@@ -0,0 +1,416 @@
|
||||
/*
|
||||
* Copyright (C) 2018 Sony Interactive Entertainment Inc.
|
||||
*
|
||||
* 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. ``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
|
||||
* 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 "stdafx.h"
|
||||
#include "Common.h"
|
||||
#include "MainWindow.h"
|
||||
#include "PlaywrightLibResource.h"
|
||||
#include "WebKitBrowserWindow.h"
|
||||
#include <WebCore/GDIUtilities.h>
|
||||
#include <WebKit/WKAuthenticationChallenge.h>
|
||||
#include <WebKit/WKAuthenticationDecisionListener.h>
|
||||
#include <WebKit/WKCertificateInfoCurl.h>
|
||||
#include <WebKit/WKCredential.h>
|
||||
#include <WebKit/WKFramePolicyListener.h>
|
||||
#include <WebKit/WKInspector.h>
|
||||
#include <WebKit/WKPagePrivate.h>
|
||||
#include <WebKit/WKProtectionSpace.h>
|
||||
#include <WebKit/WKProtectionSpaceCurl.h>
|
||||
#include <WebKit/WKWebsiteDataStoreRef.h>
|
||||
#include <WebKit/WKWebsiteDataStoreRefCurl.h>
|
||||
#include <vector>
|
||||
|
||||
std::wstring createPEMString(WKProtectionSpaceRef protectionSpace)
|
||||
{
|
||||
auto chain = adoptWK(WKProtectionSpaceCopyCertificateChain(protectionSpace));
|
||||
|
||||
std::wstring pems;
|
||||
|
||||
for (size_t i = 0; i < WKArrayGetSize(chain.get()); i++) {
|
||||
auto item = WKArrayGetItemAtIndex(chain.get(), i);
|
||||
assert(WKGetTypeID(item) == WKDataGetTypeID());
|
||||
auto certificate = static_cast<WKDataRef>(item);
|
||||
auto size = WKDataGetSize(certificate);
|
||||
auto data = WKDataGetBytes(certificate);
|
||||
|
||||
for (size_t i = 0; i < size; i++)
|
||||
pems.push_back(data[i]);
|
||||
}
|
||||
|
||||
return replaceString(pems, L"\n", L"\r\n");
|
||||
}
|
||||
|
||||
WebKitBrowserWindow::WebKitBrowserWindow(BrowserWindowClient& client, HWND mainWnd, WKPageConfigurationRef conf)
|
||||
: m_client(client)
|
||||
, m_hMainWnd(mainWnd)
|
||||
{
|
||||
RECT rect = { };
|
||||
m_view = adoptWK(WKViewCreate(rect, conf, mainWnd));
|
||||
WKViewSetIsInWindow(m_view.get(), true);
|
||||
|
||||
auto page = WKViewGetPage(m_view.get());
|
||||
|
||||
WKPageNavigationClientV0 navigationClient = { };
|
||||
navigationClient.base.version = 0;
|
||||
navigationClient.base.clientInfo = this;
|
||||
navigationClient.didReceiveAuthenticationChallenge = didReceiveAuthenticationChallenge;
|
||||
WKPageSetPageNavigationClient(page, &navigationClient.base);
|
||||
|
||||
WKPageUIClientV14 uiClient = { };
|
||||
uiClient.base.version = 14;
|
||||
uiClient.base.clientInfo = this;
|
||||
uiClient.createNewPage = createNewPage;
|
||||
uiClient.didNotHandleKeyEvent = didNotHandleKeyEvent;
|
||||
uiClient.close = closeWindow;
|
||||
uiClient.runJavaScriptAlert = runJavaScriptAlert;
|
||||
uiClient.runJavaScriptConfirm = runJavaScriptConfirm;
|
||||
uiClient.runJavaScriptPrompt = runJavaScriptPrompt;
|
||||
uiClient.runBeforeUnloadConfirmPanel = runBeforeUnloadConfirmPanel;
|
||||
uiClient.handleJavaScriptDialog = handleJavaScriptDialog;
|
||||
uiClient.getWindowFrame = getWindowFrame;
|
||||
WKPageSetPageUIClient(page, &uiClient.base);
|
||||
|
||||
WKPageStateClientV0 stateClient = { };
|
||||
stateClient.base.version = 0;
|
||||
stateClient.base.clientInfo = this;
|
||||
stateClient.didChangeTitle = didChangeTitle;
|
||||
stateClient.didChangeIsLoading = didChangeIsLoading;
|
||||
stateClient.didChangeActiveURL = didChangeActiveURL;
|
||||
WKPageSetPageStateClient(page, &stateClient.base);
|
||||
|
||||
WKPagePolicyClientV1 policyClient = { };
|
||||
policyClient.base.version = 1;
|
||||
policyClient.base.clientInfo = this;
|
||||
policyClient.decidePolicyForResponse = decidePolicyForResponse;
|
||||
policyClient.decidePolicyForNavigationAction = decidePolicyForNavigationAction;
|
||||
WKPageSetPagePolicyClient(page, &policyClient.base);
|
||||
|
||||
WKPageSetControlledByAutomation(page, true);
|
||||
resetZoom();
|
||||
}
|
||||
|
||||
WebKitBrowserWindow::~WebKitBrowserWindow()
|
||||
{
|
||||
if (m_alertDialog) {
|
||||
WKRelease(m_alertDialog);
|
||||
m_alertDialog = NULL;
|
||||
}
|
||||
|
||||
if (m_confirmDialog) {
|
||||
WKRelease(m_confirmDialog);
|
||||
m_confirmDialog = NULL;
|
||||
}
|
||||
|
||||
if (m_promptDialog) {
|
||||
WKRelease(m_promptDialog);
|
||||
m_promptDialog = NULL;
|
||||
}
|
||||
|
||||
if (m_beforeUnloadDialog) {
|
||||
WKRelease(m_beforeUnloadDialog);
|
||||
m_beforeUnloadDialog = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
HWND WebKitBrowserWindow::hwnd()
|
||||
{
|
||||
return WKViewGetWindow(m_view.get());
|
||||
}
|
||||
|
||||
HRESULT WebKitBrowserWindow::loadURL(const BSTR& url)
|
||||
{
|
||||
auto page = WKViewGetPage(m_view.get());
|
||||
WKPageLoadURL(page, createWKURL(_bstr_t(url)).get());
|
||||
return true;
|
||||
}
|
||||
|
||||
void WebKitBrowserWindow::reload()
|
||||
{
|
||||
auto page = WKViewGetPage(m_view.get());
|
||||
WKPageReload(page);
|
||||
}
|
||||
|
||||
void WebKitBrowserWindow::navigateForwardOrBackward(bool forward)
|
||||
{
|
||||
auto page = WKViewGetPage(m_view.get());
|
||||
if (forward)
|
||||
WKPageGoForward(page);
|
||||
else
|
||||
WKPageGoBack(page);
|
||||
}
|
||||
|
||||
void WebKitBrowserWindow::launchInspector()
|
||||
{
|
||||
auto page = WKViewGetPage(m_view.get());
|
||||
auto inspector = WKPageGetInspector(page);
|
||||
WKInspectorShow(inspector);
|
||||
}
|
||||
|
||||
void WebKitBrowserWindow::setUserAgent(_bstr_t& customUAString)
|
||||
{
|
||||
auto page = WKViewGetPage(m_view.get());
|
||||
auto ua = createWKString(customUAString);
|
||||
WKPageSetCustomUserAgent(page, ua.get());
|
||||
}
|
||||
|
||||
_bstr_t WebKitBrowserWindow::userAgent()
|
||||
{
|
||||
auto page = WKViewGetPage(m_view.get());
|
||||
auto ua = adoptWK(WKPageCopyUserAgent(page));
|
||||
return createString(ua.get()).c_str();
|
||||
}
|
||||
|
||||
void WebKitBrowserWindow::resetZoom()
|
||||
{
|
||||
auto page = WKViewGetPage(m_view.get());
|
||||
WKPageSetPageZoomFactor(page, WebCore::deviceScaleFactorForWindow(hwnd()));
|
||||
}
|
||||
|
||||
void WebKitBrowserWindow::zoomIn()
|
||||
{
|
||||
auto page = WKViewGetPage(m_view.get());
|
||||
double s = WKPageGetPageZoomFactor(page);
|
||||
WKPageSetPageZoomFactor(page, s * 1.25);
|
||||
}
|
||||
|
||||
void WebKitBrowserWindow::zoomOut()
|
||||
{
|
||||
auto page = WKViewGetPage(m_view.get());
|
||||
double s = WKPageGetPageZoomFactor(page);
|
||||
WKPageSetPageZoomFactor(page, s * 0.8);
|
||||
}
|
||||
|
||||
static WebKitBrowserWindow& toWebKitBrowserWindow(const void *clientInfo)
|
||||
{
|
||||
return *const_cast<WebKitBrowserWindow*>(static_cast<const WebKitBrowserWindow*>(clientInfo));
|
||||
}
|
||||
|
||||
void WebKitBrowserWindow::didChangeTitle(const void* clientInfo)
|
||||
{
|
||||
auto& thisWindow = toWebKitBrowserWindow(clientInfo);
|
||||
auto page = WKViewGetPage(thisWindow.m_view.get());
|
||||
WKRetainPtr<WKStringRef> title = adoptWK(WKPageCopyTitle(page));
|
||||
std::wstring titleString = createString(title.get()) + L" [WebKit]";
|
||||
SetWindowText(thisWindow.m_hMainWnd, titleString.c_str());
|
||||
}
|
||||
|
||||
void WebKitBrowserWindow::didChangeIsLoading(const void* clientInfo)
|
||||
{
|
||||
auto& thisWindow = toWebKitBrowserWindow(clientInfo);
|
||||
}
|
||||
|
||||
void WebKitBrowserWindow::didChangeActiveURL(const void* clientInfo)
|
||||
{
|
||||
auto& thisWindow = toWebKitBrowserWindow(clientInfo);
|
||||
auto page = WKViewGetPage(thisWindow.m_view.get());
|
||||
WKRetainPtr<WKURLRef> url = adoptWK(WKPageCopyActiveURL(page));
|
||||
thisWindow.m_client.activeURLChanged(createString(url.get()));
|
||||
}
|
||||
|
||||
void WebKitBrowserWindow::didReceiveAuthenticationChallenge(WKPageRef page, WKAuthenticationChallengeRef challenge, const void* clientInfo)
|
||||
{
|
||||
auto& thisWindow = toWebKitBrowserWindow(clientInfo);
|
||||
auto protectionSpace = WKAuthenticationChallengeGetProtectionSpace(challenge);
|
||||
auto decisionListener = WKAuthenticationChallengeGetDecisionListener(challenge);
|
||||
auto authenticationScheme = WKProtectionSpaceGetAuthenticationScheme(protectionSpace);
|
||||
|
||||
if (authenticationScheme == kWKProtectionSpaceAuthenticationSchemeServerTrustEvaluationRequested) {
|
||||
if (thisWindow.canTrustServerCertificate(protectionSpace)) {
|
||||
WKRetainPtr<WKStringRef> username = createWKString("accept server trust");
|
||||
WKRetainPtr<WKStringRef> password = createWKString("");
|
||||
WKRetainPtr<WKCredentialRef> wkCredential = adoptWK(WKCredentialCreate(username.get(), password.get(), kWKCredentialPersistenceForSession));
|
||||
WKAuthenticationDecisionListenerUseCredential(decisionListener, wkCredential.get());
|
||||
return;
|
||||
}
|
||||
} else if (!s_headless) {
|
||||
WKRetainPtr<WKStringRef> realm(WKProtectionSpaceCopyRealm(protectionSpace));
|
||||
|
||||
if (auto credential = askCredential(thisWindow.hwnd(), createString(realm.get()))) {
|
||||
WKRetainPtr<WKStringRef> username = createWKString(credential->username);
|
||||
WKRetainPtr<WKStringRef> password = createWKString(credential->password);
|
||||
WKRetainPtr<WKCredentialRef> wkCredential = adoptWK(WKCredentialCreate(username.get(), password.get(), kWKCredentialPersistenceForSession));
|
||||
WKAuthenticationDecisionListenerUseCredential(decisionListener, wkCredential.get());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
WKAuthenticationDecisionListenerUseCredential(decisionListener, nullptr);
|
||||
}
|
||||
|
||||
bool WebKitBrowserWindow::canTrustServerCertificate(WKProtectionSpaceRef protectionSpace)
|
||||
{
|
||||
auto host = createString(adoptWK(WKProtectionSpaceCopyHost(protectionSpace)).get());
|
||||
auto verificationError = WKProtectionSpaceGetCertificateVerificationError(protectionSpace);
|
||||
auto description = createString(adoptWK(WKProtectionSpaceCopyCertificateVerificationErrorDescription(protectionSpace)).get());
|
||||
auto pem = createPEMString(protectionSpace);
|
||||
|
||||
auto it = m_acceptedServerTrustCerts.find(host);
|
||||
if (it != m_acceptedServerTrustCerts.end() && it->second == pem)
|
||||
return true;
|
||||
|
||||
std::wstring textString = L"[HOST] " + host + L"\r\n";
|
||||
textString.append(L"[ERROR] " + std::to_wstring(verificationError) + L"\r\n");
|
||||
textString.append(L"[DESCRIPTION] " + description + L"\r\n");
|
||||
textString.append(pem);
|
||||
|
||||
if (s_headless)
|
||||
return false;
|
||||
|
||||
if (askServerTrustEvaluation(hwnd(), textString)) {
|
||||
m_acceptedServerTrustCerts.emplace(host, pem);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void WebKitBrowserWindow::closeWindow(WKPageRef page, const void* clientInfo)
|
||||
{
|
||||
auto& thisWindow = toWebKitBrowserWindow(clientInfo);
|
||||
PostMessage(thisWindow.m_hMainWnd, WM_CLOSE, 0, 0);
|
||||
}
|
||||
|
||||
void WebKitBrowserWindow::runJavaScriptAlert(WKPageRef page, WKStringRef alertText, WKFrameRef frame, WKSecurityOriginRef securityOrigin, WKPageRunJavaScriptAlertResultListenerRef listener, const void *clientInfo)
|
||||
{
|
||||
auto& thisWindow = toWebKitBrowserWindow(clientInfo);
|
||||
WKRetain(listener);
|
||||
thisWindow.m_alertDialog = listener;
|
||||
}
|
||||
|
||||
void WebKitBrowserWindow::runJavaScriptConfirm(WKPageRef page, WKStringRef message, WKFrameRef frame, WKSecurityOriginRef securityOrigin, WKPageRunJavaScriptConfirmResultListenerRef listener, const void *clientInfo)
|
||||
{
|
||||
auto& thisWindow = toWebKitBrowserWindow(clientInfo);
|
||||
WKRetain(listener);
|
||||
thisWindow.m_confirmDialog = listener;
|
||||
}
|
||||
|
||||
void WebKitBrowserWindow::runJavaScriptPrompt(WKPageRef page, WKStringRef message, WKStringRef defaultValue, WKFrameRef frame, WKSecurityOriginRef securityOrigin, WKPageRunJavaScriptPromptResultListenerRef listener, const void *clientInfo)
|
||||
{
|
||||
auto& thisWindow = toWebKitBrowserWindow(clientInfo);
|
||||
WKRetain(listener);
|
||||
thisWindow.m_promptDialog = listener;
|
||||
}
|
||||
|
||||
void WebKitBrowserWindow::runBeforeUnloadConfirmPanel(WKPageRef page, WKStringRef message, WKFrameRef frame, WKPageRunBeforeUnloadConfirmPanelResultListenerRef listener, const void *clientInfo)
|
||||
{
|
||||
auto& thisWindow = toWebKitBrowserWindow(clientInfo);
|
||||
WKRetain(listener);
|
||||
thisWindow.m_beforeUnloadDialog = listener;
|
||||
}
|
||||
|
||||
void WebKitBrowserWindow::handleJavaScriptDialog(WKPageRef page, bool accept, WKStringRef value, const void *clientInfo)
|
||||
{
|
||||
auto& thisWindow = toWebKitBrowserWindow(clientInfo);
|
||||
if (thisWindow.m_alertDialog) {
|
||||
WKPageRunJavaScriptAlertResultListenerCall(thisWindow.m_alertDialog);
|
||||
WKRelease(thisWindow.m_alertDialog);
|
||||
thisWindow.m_alertDialog = NULL;
|
||||
}
|
||||
|
||||
if (thisWindow.m_confirmDialog) {
|
||||
WKPageRunJavaScriptConfirmResultListenerCall(thisWindow.m_confirmDialog, accept);
|
||||
WKRelease(thisWindow.m_confirmDialog);
|
||||
thisWindow.m_confirmDialog = NULL;
|
||||
}
|
||||
|
||||
if (thisWindow.m_promptDialog) {
|
||||
WKPageRunJavaScriptPromptResultListenerCall(thisWindow.m_promptDialog, accept ? value : NULL);
|
||||
WKRelease(thisWindow.m_promptDialog);
|
||||
thisWindow.m_promptDialog = NULL;
|
||||
}
|
||||
|
||||
if (thisWindow.m_beforeUnloadDialog) {
|
||||
WKPageRunBeforeUnloadConfirmPanelResultListenerCall(thisWindow.m_beforeUnloadDialog, accept);
|
||||
WKRelease(thisWindow.m_beforeUnloadDialog);
|
||||
thisWindow.m_beforeUnloadDialog = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
WKRect WebKitBrowserWindow::getWindowFrame(WKPageRef page, const void *clientInfo) {
|
||||
auto& thisWindow = toWebKitBrowserWindow(clientInfo);
|
||||
WKRect wkFrame { };
|
||||
RECT r;
|
||||
if (::GetWindowRect(thisWindow.m_hMainWnd, &r)) {
|
||||
wkFrame.origin.x = r.left;
|
||||
wkFrame.origin.y = r.top;
|
||||
wkFrame.size.width = r.right - r.left;
|
||||
wkFrame.size.height = r.bottom - r.top;
|
||||
}
|
||||
return wkFrame;
|
||||
}
|
||||
|
||||
WKPageRef WebKitBrowserWindow::createPageCallback(WKPageConfigurationRef configuration)
|
||||
{
|
||||
// This comes from the Playwright agent, configuration is a pool+data pair.
|
||||
return WebKitBrowserWindow::createViewCallback(configuration, true);
|
||||
}
|
||||
|
||||
WKPageRef WebKitBrowserWindow::createViewCallback(WKPageConfigurationRef configuration, bool navigate)
|
||||
{
|
||||
auto* newWindow = new MainWindow();
|
||||
bool ok = newWindow->init(hInst, configuration);
|
||||
if (navigate)
|
||||
newWindow->browserWindow()->loadURL(_bstr_t("about:blank").GetBSTR());
|
||||
|
||||
auto* newBrowserWindow = newWindow->browserWindow();
|
||||
return WKViewGetPage(newBrowserWindow->m_view.get());
|
||||
}
|
||||
|
||||
|
||||
WKPageRef WebKitBrowserWindow::createNewPage(WKPageRef, WKPageConfigurationRef configuration, WKNavigationActionRef, WKWindowFeaturesRef, const void*)
|
||||
{
|
||||
// This comes from the client for popups, configuration is inherited from main page.
|
||||
// Retain popups as per API contract.
|
||||
WKRetainPtr<WKPageRef> newPage = createViewCallback(configuration, false);
|
||||
return newPage.leakRef();
|
||||
}
|
||||
|
||||
void WebKitBrowserWindow::didNotHandleKeyEvent(WKPageRef, WKNativeEventPtr event, const void* clientInfo)
|
||||
{
|
||||
auto& thisWindow = toWebKitBrowserWindow(clientInfo);
|
||||
PostMessage(thisWindow.m_hMainWnd, event->message, event->wParam, event->lParam);
|
||||
}
|
||||
|
||||
void WebKitBrowserWindow::decidePolicyForNavigationAction(WKPageRef page, WKFrameRef frame, WKFrameNavigationType navigationType, WKEventModifiers modifiers, WKEventMouseButton mouseButton, WKFrameRef originatingFrame, WKURLRequestRef request, WKFramePolicyListenerRef listener, WKTypeRef userData, const void* clientInfo)
|
||||
{
|
||||
WebKitBrowserWindow* browserWindow = reinterpret_cast<WebKitBrowserWindow*>(const_cast<void*>(clientInfo));
|
||||
if (navigationType == kWKFrameNavigationTypeLinkClicked &&
|
||||
mouseButton == kWKEventMouseButtonLeftButton &&
|
||||
(modifiers & (kWKEventModifiersShiftKey | kWKEventModifiersControlKey)) != 0) {
|
||||
WKRetainPtr<WKPageRef> newPage = createViewCallback(WKPageCopyPageConfiguration(page), false);
|
||||
WKPageLoadURLRequest(newPage.get(), request);
|
||||
WKFramePolicyListenerIgnore(listener);
|
||||
return;
|
||||
}
|
||||
WKFramePolicyListenerUse(listener);
|
||||
}
|
||||
|
||||
void WebKitBrowserWindow::decidePolicyForResponse(WKPageRef page, WKFrameRef frame, WKURLResponseRef response, WKURLRequestRef request, bool canShowMIMEType, WKFramePolicyListenerRef listener, WKTypeRef userData, const void* clientInfo)
|
||||
{
|
||||
// Safari renders resources without content-type as text.
|
||||
if (WKURLResponseIsAttachment(response) || (!WKStringIsEmpty(WKURLResponseCopyMIMEType(response)) && !canShowMIMEType))
|
||||
WKFramePolicyListenerDownload(listener);
|
||||
else
|
||||
WKFramePolicyListenerUse(listener);
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* Copyright (C) 2018 Sony Interactive Entertainment Inc.
|
||||
*
|
||||
* 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. ``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
|
||||
* 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.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "Common.h"
|
||||
#include <WebKit/WKBase.h>
|
||||
#include <WebKit/WebKit2_C.h>
|
||||
#include <unordered_map>
|
||||
|
||||
class BrowserWindowClient {
|
||||
public:
|
||||
virtual void activeURLChanged(std::wstring) = 0;
|
||||
};
|
||||
|
||||
class WebKitBrowserWindow {
|
||||
public:
|
||||
static WKPageRef createPageCallback(WKPageConfigurationRef);
|
||||
WebKitBrowserWindow(BrowserWindowClient&, HWND mainWnd, WKPageConfigurationRef);
|
||||
~WebKitBrowserWindow();
|
||||
|
||||
HRESULT loadURL(const BSTR& url);
|
||||
void reload();
|
||||
void navigateForwardOrBackward(bool forward);
|
||||
void launchInspector();
|
||||
|
||||
_bstr_t userAgent();
|
||||
void setUserAgent(_bstr_t&);
|
||||
|
||||
void resetZoom();
|
||||
void zoomIn();
|
||||
void zoomOut();
|
||||
|
||||
bool canTrustServerCertificate(WKProtectionSpaceRef);
|
||||
HWND hwnd();
|
||||
|
||||
private:
|
||||
static WKPageRef createViewCallback(WKPageConfigurationRef, bool navigate);
|
||||
|
||||
static void didChangeTitle(const void*);
|
||||
static void didChangeIsLoading(const void*);
|
||||
static void didChangeEstimatedProgress(const void*);
|
||||
static void didChangeActiveURL(const void*);
|
||||
static void didReceiveAuthenticationChallenge(WKPageRef, WKAuthenticationChallengeRef, const void*);
|
||||
static WKPageRef createNewPage(WKPageRef, WKPageConfigurationRef, WKNavigationActionRef, WKWindowFeaturesRef, const void *);
|
||||
static void closeWindow(WKPageRef, const void*);
|
||||
static void runJavaScriptAlert(WKPageRef page, WKStringRef alertText, WKFrameRef frame, WKSecurityOriginRef securityOrigin, WKPageRunJavaScriptAlertResultListenerRef listener, const void *clientInfo);
|
||||
static void runJavaScriptConfirm(WKPageRef page, WKStringRef message, WKFrameRef frame, WKSecurityOriginRef securityOrigin, WKPageRunJavaScriptConfirmResultListenerRef listener, const void *clientInfo);
|
||||
static void runJavaScriptPrompt(WKPageRef page, WKStringRef message, WKStringRef defaultValue, WKFrameRef frame, WKSecurityOriginRef securityOrigin, WKPageRunJavaScriptPromptResultListenerRef listener, const void *clientInfo);
|
||||
static void runBeforeUnloadConfirmPanel(WKPageRef page, WKStringRef message, WKFrameRef frame, WKPageRunBeforeUnloadConfirmPanelResultListenerRef listener, const void *clientInfo);
|
||||
static void handleJavaScriptDialog(WKPageRef page, bool accept, WKStringRef value, const void *clientInfo);
|
||||
static WKRect getWindowFrame(WKPageRef page, const void *clientInfo);
|
||||
static void didNotHandleKeyEvent(WKPageRef, WKNativeEventPtr, const void*);
|
||||
static void decidePolicyForNavigationAction(WKPageRef, WKFrameRef, WKFrameNavigationType, WKEventModifiers, WKEventMouseButton, WKFrameRef, WKURLRequestRef, WKFramePolicyListenerRef, WKTypeRef, const void* clientInfo);
|
||||
static void decidePolicyForResponse(WKPageRef, WKFrameRef, WKURLResponseRef, WKURLRequestRef, bool, WKFramePolicyListenerRef, WKTypeRef, const void*);
|
||||
|
||||
BrowserWindowClient& m_client;
|
||||
WKRetainPtr<WKViewRef> m_view;
|
||||
HWND m_hMainWnd { nullptr };
|
||||
std::unordered_map<std::wstring, std::wstring> m_acceptedServerTrustCerts;
|
||||
WKPageRunJavaScriptAlertResultListenerRef m_alertDialog = { };
|
||||
WKPageRunJavaScriptConfirmResultListenerRef m_confirmDialog = { };
|
||||
WKPageRunJavaScriptPromptResultListenerRef m_promptDialog = { };
|
||||
WKPageRunBeforeUnloadConfirmPanelResultListenerRef m_beforeUnloadDialog = { };
|
||||
};
|
||||
@@ -0,0 +1,168 @@
|
||||
/*
|
||||
* Copyright (C) 2006, 2008, 2013-2015 Apple Inc. All rights reserved.
|
||||
* Copyright (C) 2009, 2011 Brent Fulgham. All rights reserved.
|
||||
* Copyright (C) 2009, 2010, 2011 Appcelerator, Inc. All rights reserved.
|
||||
* Copyright (C) 2013 Alex Christensen. 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. ``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
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#pragma warning(disable: 4091)
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "Common.h"
|
||||
#include "MainWindow.h"
|
||||
#include "PlaywrightLibResource.h"
|
||||
#include "PlaywrightReplace.h"
|
||||
#include <WebKit/WKContext.h>
|
||||
#include <WebKit/WKWebsiteDataStoreConfigurationRef.h>
|
||||
#include <WebKit/WKWebsiteDataStoreRef.h>
|
||||
#include <WebKit/WKWebsiteDataStoreRefCurl.h>
|
||||
#include <wtf/win/SoftLinking.h>
|
||||
#include "WebKitBrowserWindow.h"
|
||||
#include <wtf/MainThread.h>
|
||||
#include <WebKit/WKInspector.h>
|
||||
|
||||
SOFT_LINK_LIBRARY(user32);
|
||||
SOFT_LINK_OPTIONAL(user32, SetProcessDpiAwarenessContext, BOOL, STDAPICALLTYPE, (DPI_AWARENESS_CONTEXT));
|
||||
|
||||
CommandLineOptions g_options;
|
||||
|
||||
static WKRetainPtr<WKStringRef> toWK(const std::string& string)
|
||||
{
|
||||
return adoptWK(WKStringCreateWithUTF8CString(string.c_str()));
|
||||
}
|
||||
|
||||
static std::string toUTF8String(const wchar_t* src, size_t srcLength)
|
||||
{
|
||||
int length = WideCharToMultiByte(CP_UTF8, 0, src, srcLength, 0, 0, nullptr, nullptr);
|
||||
std::vector<char> buffer(length);
|
||||
size_t actualLength = WideCharToMultiByte(CP_UTF8, 0, src, srcLength, buffer.data(), length, nullptr, nullptr);
|
||||
return { buffer.data(), actualLength };
|
||||
}
|
||||
|
||||
static void configureDataStore(WKWebsiteDataStoreRef dataStore) {
|
||||
if (g_options.curloptProxy.length()) {
|
||||
auto curloptProxy = createWKURL(g_options.curloptProxy);
|
||||
auto curloptNoproxy = createWKString(g_options.curloptNoproxy);
|
||||
WKWebsiteDataStoreEnableCustomNetworkProxySettings(dataStore, curloptProxy.get(), curloptNoproxy.get());
|
||||
}
|
||||
}
|
||||
|
||||
int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPWSTR lpstrCmdLine, _In_ int nCmdShow)
|
||||
{
|
||||
hInst = hInstance;
|
||||
#ifdef _CRTDBG_MAP_ALLOC
|
||||
_CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR);
|
||||
_CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
|
||||
#endif
|
||||
|
||||
MSG msg { };
|
||||
HACCEL hAccelTable, hPreAccelTable;
|
||||
|
||||
INITCOMMONCONTROLSEX InitCtrlEx;
|
||||
|
||||
InitCtrlEx.dwSize = sizeof(INITCOMMONCONTROLSEX);
|
||||
InitCtrlEx.dwICC = 0x00004000; // ICC_STANDARD_CLASSES;
|
||||
InitCommonControlsEx(&InitCtrlEx);
|
||||
|
||||
g_options = parseCommandLine();
|
||||
if (g_options.inspectorPipe) {
|
||||
WKInspectorInitializeRemoteInspectorPipe(
|
||||
configureDataStore,
|
||||
WebKitBrowserWindow::createPageCallback,
|
||||
[]() { PostQuitMessage(0); });
|
||||
}
|
||||
|
||||
if (g_options.useFullDesktop)
|
||||
computeFullDesktopFrame();
|
||||
|
||||
// Init COM
|
||||
OleInitialize(nullptr);
|
||||
|
||||
if (SetProcessDpiAwarenessContextPtr())
|
||||
SetProcessDpiAwarenessContextPtr()(DPI_AWARENESS_CONTEXT_UNAWARE);
|
||||
|
||||
s_headless = g_options.headless;
|
||||
MainWindow::configure(g_options.inspectorPipe, g_options.disableAcceleratedCompositing);
|
||||
|
||||
if (!g_options.noStartupWindow) {
|
||||
auto configuration = adoptWK(WKWebsiteDataStoreConfigurationCreate());
|
||||
if (g_options.userDataDir.length()) {
|
||||
std::string profileFolder = toUTF8String(g_options.userDataDir, g_options.userDataDir.length());
|
||||
WKWebsiteDataStoreConfigurationSetNetworkCacheDirectory(configuration.get(), toWK(profileFolder + "\\Cache").get());
|
||||
WKWebsiteDataStoreConfigurationSetCacheStorageDirectory(configuration.get(), toWK(profileFolder + "\\CacheStorage").get());
|
||||
WKWebsiteDataStoreConfigurationSetIndexedDBDatabaseDirectory(configuration.get(), toWK(profileFolder + "\\Databases" + "\\IndexedDB").get());
|
||||
WKWebsiteDataStoreConfigurationSetLocalStorageDirectory(configuration.get(), toWK(profileFolder + "\\LocalStorage").get());
|
||||
WKWebsiteDataStoreConfigurationSetWebSQLDatabaseDirectory(configuration.get(), toWK(profileFolder + "\\Databases" + "\\WebSQL").get());
|
||||
WKWebsiteDataStoreConfigurationSetMediaKeysStorageDirectory(configuration.get(), toWK(profileFolder + "\\MediaKeys").get());
|
||||
WKWebsiteDataStoreConfigurationSetResourceLoadStatisticsDirectory(configuration.get(), toWK(profileFolder + "\\ResourceLoadStatistics").get());
|
||||
WKWebsiteDataStoreConfigurationSetServiceWorkerRegistrationDirectory(configuration.get(), toWK(profileFolder + "\\ServiceWorkers").get());
|
||||
}
|
||||
auto context = adoptWK(WKContextCreateWithConfiguration(nullptr));
|
||||
auto dataStore = adoptWK(WKWebsiteDataStoreCreateWithConfiguration(configuration.get()));
|
||||
configureDataStore(dataStore.get());
|
||||
|
||||
auto* mainWindow = new MainWindow();
|
||||
auto conf = adoptWK(WKPageConfigurationCreate());
|
||||
WKPageConfigurationSetContext(conf.get(), context.get());
|
||||
WKPageConfigurationSetWebsiteDataStore(conf.get(), dataStore.get());
|
||||
HRESULT hr = mainWindow->init(hInst, conf.get());
|
||||
if (FAILED(hr))
|
||||
goto exit;
|
||||
|
||||
if (g_options.requestedURL.length())
|
||||
mainWindow->loadURL(g_options.requestedURL.GetBSTR());
|
||||
else
|
||||
mainWindow->loadURL(L"about:blank");
|
||||
}
|
||||
|
||||
hAccelTable = LoadAccelerators(hInst, MAKEINTRESOURCE(IDC_PLAYWRIGHT));
|
||||
hPreAccelTable = LoadAccelerators(hInst, MAKEINTRESOURCE(IDR_ACCELERATORS_PRE));
|
||||
|
||||
#pragma warning(disable:4509)
|
||||
|
||||
// Main message loop:
|
||||
__try {
|
||||
while (GetMessage(&msg, nullptr, 0, 0)) {
|
||||
if (TranslateAccelerator(msg.hwnd, hPreAccelTable, &msg))
|
||||
continue;
|
||||
bool processed = false;
|
||||
if (MainWindow::isInstance(msg.hwnd))
|
||||
processed = TranslateAccelerator(msg.hwnd, hAccelTable, &msg);
|
||||
if (!processed) {
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
}
|
||||
}
|
||||
} __except(createCrashReport(GetExceptionInformation()), EXCEPTION_EXECUTE_HANDLER) { }
|
||||
|
||||
exit:
|
||||
#ifdef _CRTDBG_MAP_ALLOC
|
||||
_CrtDumpMemoryLeaks();
|
||||
#endif
|
||||
|
||||
// Shut down COM.
|
||||
OleUninitialize();
|
||||
|
||||
return static_cast<int>(msg.wParam);
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Visual C++ generated include file.
|
||||
// Used by WinLauncher.rc
|
||||
//
|
||||
#define IDC_MYICON 2
|
||||
#define IDD_WINLAUNCHER_DIALOG 102
|
||||
#define IDS_APP_TITLE 103
|
||||
#define IDD_ABOUTBOX 103
|
||||
#define IDM_ABOUT 104
|
||||
#define IDI_WINLAUNCHER 107
|
||||
#define IDC_WINLAUNCHER 109
|
||||
#define IDR_MAINFRAME 128
|
||||
#define IDC_STATIC -1
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NO_MFC 1
|
||||
#define _APS_NEXT_RESOURCE_VALUE 129
|
||||
#define _APS_NEXT_COMMAND_VALUE 32771
|
||||
#define _APS_NEXT_CONTROL_VALUE 1000
|
||||
#define _APS_NEXT_SYMED_VALUE 110
|
||||
#endif
|
||||
#endif
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright (C) 2006 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. ``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
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// stdafx.cpp : source file that includes just the standard includes
|
||||
// Spinneret.pch will be the pre-compiled header
|
||||
// stdafx.obj will contain the pre-compiled type information
|
||||
|
||||
#include "stdafx.h"
|
||||
|
||||
// TODO: reference any additional headers you need in STDAFX.H
|
||||
// and not in this file
|
||||
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Copyright (C) 2006 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. ``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
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// stdafx.h : include file for standard system include files,
|
||||
// or project specific include files that are used frequently, but
|
||||
// are changed infrequently
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#if defined(HAVE_CONFIG_H) && HAVE_CONFIG_H && defined(BUILDING_WITH_CMAKE)
|
||||
#include "cmakeconfig.h"
|
||||
#endif
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
||||
|
||||
// Needed for limit defines, like INTMAX_MAX, which is used by the std C++ library
|
||||
#ifndef __STDC_LIMIT_MACROS
|
||||
#define __STDC_LIMIT_MACROS
|
||||
#endif
|
||||
|
||||
#include <assert.h>
|
||||
#include <comdef.h>
|
||||
#include <comip.h>
|
||||
#include <commctrl.h>
|
||||
#include <commdlg.h>
|
||||
#include <comutil.h>
|
||||
#include <malloc.h>
|
||||
#include <memory.h>
|
||||
#include <objbase.h>
|
||||
#include <shellapi.h>
|
||||
#include <shlwapi.h>
|
||||
#include <stdlib.h>
|
||||
#include <string>
|
||||
#include <tchar.h>
|
||||
#include <windows.h>
|
||||
#include <wininet.h>
|
||||
#include <wtf/Platform.h>
|
||||
|
||||
#include <JavaScriptCore/JSExportMacros.h>
|
||||
#include <WebCore/PlatformExportMacros.h>
|
||||
|
||||
#if 0
|
||||
// Visual Studio Leak Detection
|
||||
// <http://msdn2.microsoft.com/en-US/library/e5ewb1h3.aspx>
|
||||
#if defined(_MSC_VER) && defined(_DEBUG)
|
||||
#define _CRTDBG_MAP_ALLOC
|
||||
#include <stdlib.h>
|
||||
#include <crtdbg.h>
|
||||
#endif
|
||||
#endif
|
||||
|
After Width: | Height: | Size: 982 B |