diff options
| author | Ben Murdoch <benm@google.com> | 2011-05-24 11:24:40 +0100 |
|---|---|---|
| committer | Ben Murdoch <benm@google.com> | 2011-06-02 09:53:15 +0100 |
| commit | 81bc750723a18f21cd17d1b173cd2a4dda9cea6e (patch) | |
| tree | 7a9e5ed86ff429fd347a25153107221543909b19 /Source/WebKit2/WebProcess/mac | |
| parent | 94088a6d336c1dd80a1e734af51e96abcbb689a7 (diff) | |
| download | external_webkit-81bc750723a18f21cd17d1b173cd2a4dda9cea6e.zip external_webkit-81bc750723a18f21cd17d1b173cd2a4dda9cea6e.tar.gz external_webkit-81bc750723a18f21cd17d1b173cd2a4dda9cea6e.tar.bz2 | |
Merge WebKit at r80534: Intial merge by Git
Change-Id: Ia7a83357124c9e1cdb1debf55d9661ec0bd09a61
Diffstat (limited to 'Source/WebKit2/WebProcess/mac')
4 files changed, 124 insertions, 3 deletions
diff --git a/Source/WebKit2/WebProcess/mac/FullKeyboardAccessWatcher.h b/Source/WebKit2/WebProcess/mac/FullKeyboardAccessWatcher.h new file mode 100644 index 0000000..d6212b2 --- /dev/null +++ b/Source/WebKit2/WebProcess/mac/FullKeyboardAccessWatcher.h @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2011 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. + */ + +#ifndef FullKeyboardAccessWatcher_h +#define FullKeyboardAccessWatcher_h + +#import <Cocoa/Cocoa.h> + +@interface FullKeyboardAccessWatcher : NSObject { +@private + BOOL fullKeyboardAccessEnabled; +} + ++ (BOOL)fullKeyboardAccessEnabled; + +@end; + +#endif // FullKeyboardAccessWatcher_h diff --git a/Source/WebKit2/WebProcess/mac/FullKeyboardAccessWatcher.mm b/Source/WebKit2/WebProcess/mac/FullKeyboardAccessWatcher.mm new file mode 100644 index 0000000..db19e95 --- /dev/null +++ b/Source/WebKit2/WebProcess/mac/FullKeyboardAccessWatcher.mm @@ -0,0 +1,70 @@ +/* + * Copyright (C) 2011 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 "config.h" +#import "FullKeyboardAccessWatcher.h" + +NSString * const KeyboardUIModeDidChangeNotification = @"com.apple.KeyboardUIModeDidChange"; +const CFStringRef AppleKeyboardUIMode = CFSTR("AppleKeyboardUIMode"); +const CFStringRef UniversalAccessDomain = CFSTR("com.apple.universalaccess"); + +@implementation FullKeyboardAccessWatcher + +- (void)retrieveKeyboardUIModeFromPreferences:(NSNotification *)notification +{ + CFPreferencesAppSynchronize(UniversalAccessDomain); + + Boolean keyExistsAndHasValidFormat; + int mode = CFPreferencesGetAppIntegerValue(AppleKeyboardUIMode, UniversalAccessDomain, &keyExistsAndHasValidFormat); + if (keyExistsAndHasValidFormat) { + // The keyboard access mode is reported by two bits: + // Bit 0 is set if feature is on + // Bit 1 is set if full keyboard access works for any control, not just text boxes and lists. + fullKeyboardAccessEnabled = (mode & 0x2); + } +} + +- (id)init +{ + self = [super init]; + if (!self) + return nil; + + [self retrieveKeyboardUIModeFromPreferences:nil]; + + [[NSDistributedNotificationCenter defaultCenter] + addObserver:self selector:@selector(retrieveKeyboardUIModeFromPreferences:) + name:KeyboardUIModeDidChangeNotification object:nil]; + + return self; +} + ++ (BOOL)fullKeyboardAccessEnabled +{ + static FullKeyboardAccessWatcher *watcher = [[FullKeyboardAccessWatcher alloc] init]; + return watcher->fullKeyboardAccessEnabled; +} + +@end diff --git a/Source/WebKit2/WebProcess/mac/WebProcessMac.mm b/Source/WebKit2/WebProcess/mac/WebProcessMac.mm index fc06d2c..92b36b8 100644 --- a/Source/WebKit2/WebProcess/mac/WebProcessMac.mm +++ b/Source/WebKit2/WebProcess/mac/WebProcessMac.mm @@ -26,6 +26,7 @@ #import "config.h" #import "WebProcess.h" +#import "FullKeyboardAccessWatcher.h" #import "SandboxExtension.h" #import "WebProcessCreationParameters.h" #import <WebCore/MemoryCache.h> @@ -110,6 +111,11 @@ void WebProcess::platformClearResourceCaches() [[NSURLCache sharedURLCache] removeAllCachedResponses]; } +bool WebProcess::fullKeyboardAccessEnabled() +{ + return [FullKeyboardAccessWatcher fullKeyboardAccessEnabled]; +} + #if ENABLE(WEB_PROCESS_SANDBOX) static void appendSandboxParameterPath(Vector<const char*>& vector, const char* name, const char* path) { @@ -179,7 +185,7 @@ void WebProcess::platformInitializeWebProcess(const WebProcessCreationParameters NSUInteger cacheMemoryCapacity = parameters.nsURLCacheMemoryCapacity; NSUInteger cacheDiskCapacity = parameters.nsURLCacheDiskCapacity; - NSString *nsCachePath = [[NSFileManager defaultManager] stringWithFileSystemRepresentation:parameters.nsURLCachePath.data() length:parameters.nsURLCachePath.length()]; + NSString *nsCachePath = [[NSFileManager defaultManager] stringWithFileSystemRepresentation:parameters.nsURLCachePath.data() length:strlen(parameters.nsURLCachePath.data())]; RetainPtr<NSURLCache> parentProcessURLCache(AdoptNS, [[NSURLCache alloc] initWithMemoryCapacity:cacheMemoryCapacity diskCapacity:cacheDiskCapacity diskPath:nsCachePath]); [NSURLCache setSharedURLCache:parentProcessURLCache.get()]; } @@ -187,7 +193,7 @@ void WebProcess::platformInitializeWebProcess(const WebProcessCreationParameters m_compositingRenderServerPort = parameters.acceleratedCompositingPort.port(); } -void WebProcess::platformShutdown() +void WebProcess::platformTerminate() { } diff --git a/Source/WebKit2/WebProcess/mac/WebProcessMainMac.mm b/Source/WebKit2/WebProcess/mac/WebProcessMainMac.mm index 846d7a1..6469df2 100644 --- a/Source/WebKit2/WebProcess/mac/WebProcessMainMac.mm +++ b/Source/WebKit2/WebProcess/mac/WebProcessMainMac.mm @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010 Apple Inc. All rights reserved. + * Copyright (C) 2010, 2011 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -72,6 +72,11 @@ int WebProcessMain(const CommandLine& commandLine) return 2; } + String localization = commandLine["localization"]; + RetainPtr<CFStringRef> cfLocalization(AdoptCF, CFStringCreateWithCharacters(0, reinterpret_cast<const UniChar*>(localization.characters()), localization.length())); + if (cfLocalization) + WKSetDefaultLocalization(cfLocalization.get()); + #if !SHOW_CRASH_REPORTER // Installs signal handlers that exit on a crash so that CrashReporter does not show up. signal(SIGILL, _exit); |
