Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "build/build_config.h" | 5 #include "build/build_config.h" |
| 6 | 6 |
| 7 // #include <Carbon/Carbon.h> | 7 // #include <Carbon/Carbon.h> |
| 8 // #include <ApplicationServices/ApplicationServices.h> | 8 // #include <ApplicationServices/ApplicationServices.h> |
| 9 #import <Cocoa/Cocoa.h> | 9 #import <Cocoa/Cocoa.h> |
| 10 #import <objc/objc-runtime.h> | 10 #import <objc/objc-runtime.h> |
| 11 #include <mach/task.h> | 11 #include <mach/task.h> |
| 12 | 12 |
| 13 #include "base/chrome_application_mac.h" | |
| 14 #include "base/command_line.h" | 13 #include "base/command_line.h" |
| 15 #include "base/logging.h" | 14 #include "base/logging.h" |
| 15 #include "base/message_pump_mac.h" | |
| 16 #include "third_party/WebKit/WebKit/mac/WebCoreSupport/WebSystemInterface.h" | 16 #include "third_party/WebKit/WebKit/mac/WebCoreSupport/WebSystemInterface.h" |
| 17 #include "webkit/tools/test_shell/test_shell.h" | 17 #include "webkit/tools/test_shell/test_shell.h" |
| 18 #include "webkit/tools/test_shell/test_shell_platform_delegate.h" | 18 #include "webkit/tools/test_shell/test_shell_platform_delegate.h" |
| 19 #include "webkit/tools/test_shell/test_shell_switches.h" | 19 #include "webkit/tools/test_shell/test_shell_switches.h" |
| 20 | 20 |
| 21 static NSAutoreleasePool *gTestShellAutoreleasePool = nil; | 21 static NSAutoreleasePool *gTestShellAutoreleasePool = nil; |
| 22 | 22 |
| 23 @interface CrApplication : NSApplication<CrAppProtocol> { | |
| 24 @private | |
| 25 BOOL handlingSendEvent_; | |
| 26 } | |
| 27 - (BOOL)isHandlingSendEvent; | |
|
dmac
2010/12/17 18:00:16
Use a property to mimic what you did in chrome_app
Nico
2010/12/18 01:14:28
Done.
| |
| 28 @end | |
| 29 | |
| 30 @implementation CrApplication | |
| 31 - (BOOL)isHandlingSendEvent { | |
| 32 return handlingSendEvent_; | |
| 33 } | |
| 34 | |
| 35 - (void)sendEvent:(NSEvent*)event { | |
| 36 BOOL b = handlingSendEvent_; | |
|
Mark Mentovai
2010/12/17 17:31:38
What does b signify?
wasHandlingSendEvent?
Nico
2010/12/18 01:14:28
Done.
| |
| 37 handlingSendEvent_ = YES; | |
| 38 [super sendEvent:event]; | |
| 39 handlingSendEvent_ = b; | |
| 40 } | |
| 41 @end | |
| 42 | |
| 23 static void SetDefaultsToLayoutTestValues(void) { | 43 static void SetDefaultsToLayoutTestValues(void) { |
| 24 // So we can match the WebKit layout tests, we want to force a bunch of | 44 // So we can match the WebKit layout tests, we want to force a bunch of |
| 25 // preferences that control appearance to match. | 45 // preferences that control appearance to match. |
| 26 // (We want to do this as early as possible in application startup so | 46 // (We want to do this as early as possible in application startup so |
| 27 // the settings are in before any higher layers could cache values.) | 47 // the settings are in before any higher layers could cache values.) |
| 28 | 48 |
| 29 NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; | 49 NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; |
| 30 | 50 |
| 31 const NSInteger kMinFontSizeCGSmoothes = 4; | 51 const NSInteger kMinFontSizeCGSmoothes = 4; |
| 32 const NSInteger kNoFontSmoothing = 0; | 52 const NSInteger kNoFontSmoothing = 0; |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 83 [defaults removeObjectForKey:@"AppleAquaColorVariant"]; | 103 [defaults removeObjectForKey:@"AppleAquaColorVariant"]; |
| 84 [defaults removeObjectForKey:@"AppleHighlightColor"]; | 104 [defaults removeObjectForKey:@"AppleHighlightColor"]; |
| 85 [defaults removeObjectForKey:@"AppleOtherHighlightColor"]; | 105 [defaults removeObjectForKey:@"AppleOtherHighlightColor"]; |
| 86 [defaults removeObjectForKey:@"AppleLanguages"]; | 106 [defaults removeObjectForKey:@"AppleLanguages"]; |
| 87 [defaults removeObjectForKey:@"AppleScrollBarVariant"]; | 107 [defaults removeObjectForKey:@"AppleScrollBarVariant"]; |
| 88 } | 108 } |
| 89 | 109 |
| 90 #if OBJC_API_VERSION == 2 | 110 #if OBJC_API_VERSION == 2 |
| 91 static void SwizzleAllMethods(Class imposter, Class original) { | 111 static void SwizzleAllMethods(Class imposter, Class original) { |
| 92 unsigned int imposterMethodCount = 0; | 112 unsigned int imposterMethodCount = 0; |
| 93 Method* imposterMethods = class_copyMethodList(imposter, &imposterMethodCount) ; | 113 Method* imposterMethods = |
| 114 class_copyMethodList(imposter, &imposterMethodCount); | |
| 94 | 115 |
| 95 unsigned int originalMethodCount = 0; | 116 unsigned int originalMethodCount = 0; |
| 96 Method* originalMethods = class_copyMethodList(original, &originalMethodCount) ; | 117 Method* originalMethods = |
| 118 class_copyMethodList(original, &originalMethodCount); | |
| 97 | 119 |
| 98 for (unsigned int i = 0; i < imposterMethodCount; i++) { | 120 for (unsigned int i = 0; i < imposterMethodCount; i++) { |
| 99 SEL imposterMethodName = method_getName(imposterMethods[i]); | 121 SEL imposterMethodName = method_getName(imposterMethods[i]); |
| 100 | 122 |
| 101 // Attempt to add the method to the original class. If it fails, the method | 123 // Attempt to add the method to the original class. If it fails, the method |
| 102 // already exists and we should instead exchange the implementations. | 124 // already exists and we should instead exchange the implementations. |
| 103 if (class_addMethod(original, | 125 if (class_addMethod(original, |
| 104 imposterMethodName, | 126 imposterMethodName, |
| 105 method_getImplementation(originalMethods[i]), | 127 method_getImplementation(originalMethods[i]), |
| 106 method_getTypeEncoding(originalMethods[i]))) { | 128 method_getTypeEncoding(originalMethods[i]))) { |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 192 | 214 |
| 193 // If we die during tests, we don't want to be spamming the user's crash | 215 // If we die during tests, we don't want to be spamming the user's crash |
| 194 // reporter. Set our exception port to null and add signal handlers. | 216 // reporter. Set our exception port to null and add signal handlers. |
| 195 // Both of these are necessary to avoid the crash reporter. Although, we do | 217 // Both of these are necessary to avoid the crash reporter. Although, we do |
| 196 // still seem to be missing some cases. | 218 // still seem to be missing some cases. |
| 197 if (!parsed_command_line.HasSwitch(test_shell::kGDB)) { | 219 if (!parsed_command_line.HasSwitch(test_shell::kGDB)) { |
| 198 task_set_exception_ports(mach_task_self(), EXC_MASK_ALL, MACH_PORT_NULL, | 220 task_set_exception_ports(mach_task_self(), EXC_MASK_ALL, MACH_PORT_NULL, |
| 199 EXCEPTION_DEFAULT, THREAD_STATE_NONE); | 221 EXCEPTION_DEFAULT, THREAD_STATE_NONE); |
| 200 } | 222 } |
| 201 } | 223 } |
| OLD | NEW |