OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 #import "chrome/browser/ui/cocoa/rwhvm_editcommand_helper.h" | 5 #import "chrome/browser/ui/cocoa/rwhvm_editcommand_helper.h" |
6 | 6 |
7 #import <objc/runtime.h> | 7 #import <objc/runtime.h> |
8 | 8 |
9 #include "chrome/browser/renderer_host/render_widget_host.h" | 9 #include "chrome/browser/renderer_host/render_widget_host.h" |
10 #import "chrome/browser/renderer_host/render_widget_host_view_mac.h" | 10 #import "chrome/browser/renderer_host/render_widget_host_view_mac.h" |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 int selector_len = [selector_str length]; | 172 int selector_len = [selector_str length]; |
173 return [selector_str substringToIndex:selector_len - 1]; | 173 return [selector_str substringToIndex:selector_len - 1]; |
174 } | 174 } |
175 | 175 |
176 RWHVMEditCommandHelper::RWHVMEditCommandHelper() { | 176 RWHVMEditCommandHelper::RWHVMEditCommandHelper() { |
177 for (size_t i = 0; i < arraysize(kEditCommands); ++i) { | 177 for (size_t i = 0; i < arraysize(kEditCommands); ++i) { |
178 edit_command_set_.insert(kEditCommands[i]); | 178 edit_command_set_.insert(kEditCommands[i]); |
179 } | 179 } |
180 } | 180 } |
181 | 181 |
| 182 RWHVMEditCommandHelper::~RWHVMEditCommandHelper() {} |
| 183 |
182 // Dynamically adds Selectors to the aformentioned class. | 184 // Dynamically adds Selectors to the aformentioned class. |
183 void RWHVMEditCommandHelper::AddEditingSelectorsToClass(Class klass) { | 185 void RWHVMEditCommandHelper::AddEditingSelectorsToClass(Class klass) { |
184 for (size_t i = 0; i < arraysize(kEditCommands); ++i) { | 186 for (size_t i = 0; i < arraysize(kEditCommands); ++i) { |
185 // Append trailing ':' to command name to get selector name. | 187 // Append trailing ':' to command name to get selector name. |
186 NSString* sel_str = [NSString stringWithFormat: @"%s:", kEditCommands[i]]; | 188 NSString* sel_str = [NSString stringWithFormat: @"%s:", kEditCommands[i]]; |
187 | 189 |
188 SEL edit_selector = NSSelectorFromString(sel_str); | 190 SEL edit_selector = NSSelectorFromString(sel_str); |
189 // May want to use @encode() for the last parameter to this method. | 191 // May want to use @encode() for the last parameter to this method. |
190 // If class_addMethod fails we assume that all the editing selectors where | 192 // If class_addMethod fails we assume that all the editing selectors where |
191 // added to the class. | 193 // added to the class. |
(...skipping 26 matching lines...) Expand all Loading... |
218 NSArray* RWHVMEditCommandHelper::GetEditSelectorNames() { | 220 NSArray* RWHVMEditCommandHelper::GetEditSelectorNames() { |
219 size_t num_edit_commands = arraysize(kEditCommands); | 221 size_t num_edit_commands = arraysize(kEditCommands); |
220 NSMutableArray* ret = [NSMutableArray arrayWithCapacity:num_edit_commands]; | 222 NSMutableArray* ret = [NSMutableArray arrayWithCapacity:num_edit_commands]; |
221 | 223 |
222 for (size_t i = 0; i < num_edit_commands; ++i) { | 224 for (size_t i = 0; i < num_edit_commands; ++i) { |
223 [ret addObject:[NSString stringWithUTF8String:kEditCommands[i]]]; | 225 [ret addObject:[NSString stringWithUTF8String:kEditCommands[i]]]; |
224 } | 226 } |
225 | 227 |
226 return ret; | 228 return ret; |
227 } | 229 } |
OLD | NEW |