OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #import "chrome/common/mac/objc_method_swizzle.h" | 5 #import "chrome/common/mac/objc_method_swizzle.h" |
6 | 6 |
7 #import "base/logging.h" | 7 #import "base/logging.h" |
8 #import "base/memory/scoped_nsobject.h" | 8 #import "base/mac/scoped_nsobject.h" |
9 | 9 |
10 namespace ObjcEvilDoers { | 10 namespace ObjcEvilDoers { |
11 | 11 |
12 Method GetImplementedInstanceMethod(Class aClass, SEL aSelector) { | 12 Method GetImplementedInstanceMethod(Class aClass, SEL aSelector) { |
13 Method method = NULL; | 13 Method method = NULL; |
14 unsigned int methodCount = 0; | 14 unsigned int methodCount = 0; |
15 Method* methodList = class_copyMethodList(aClass, &methodCount); | 15 Method* methodList = class_copyMethodList(aClass, &methodCount); |
16 if (methodList) { | 16 if (methodList) { |
17 for (unsigned int i = 0; i < methodCount; ++i) { | 17 for (unsigned int i = 0; i < methodCount; ++i) { |
18 if (method_getName(methodList[i]) == aSelector) { | 18 if (method_getName(methodList[i]) == aSelector) { |
(...skipping 30 matching lines...) Expand all Loading... |
49 } | 49 } |
50 | 50 |
51 IMP ret = method_getImplementation(original); | 51 IMP ret = method_getImplementation(original); |
52 if (ret) { | 52 if (ret) { |
53 method_exchangeImplementations(original, alternate); | 53 method_exchangeImplementations(original, alternate); |
54 } | 54 } |
55 return ret; | 55 return ret; |
56 } | 56 } |
57 | 57 |
58 } // namespace ObjcEvilDoers | 58 } // namespace ObjcEvilDoers |
OLD | NEW |