| 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 #import "chrome/browser/renderer_host/render_widget_host_view_mac.h" | 9 #import "chrome/browser/renderer_host/render_widget_host_view_mac.h" |
| 10 #include "content/browser/renderer_host/render_widget_host.h" | 10 #include "content/browser/renderer_host/render_widget_host.h" |
| 11 #include "content/common/view_messages.h" | |
| 12 | 11 |
| 13 namespace { | 12 namespace { |
| 14 // The names of all the objc selectors w/o ':'s added to an object by | 13 // The names of all the objc selectors w/o ':'s added to an object by |
| 15 // AddEditingSelectorsToClass(). | 14 // AddEditingSelectorsToClass(). |
| 16 // | 15 // |
| 17 // This needs to be kept in Sync with WEB_COMMAND list in the WebKit tree at: | 16 // This needs to be kept in Sync with WEB_COMMAND list in the WebKit tree at: |
| 18 // WebKit/mac/WebView/WebHTMLView.mm . | 17 // WebKit/mac/WebView/WebHTMLView.mm . |
| 19 const char* kEditCommands[] = { | 18 const char* kEditCommands[] = { |
| 20 "alignCenter", | 19 "alignCenter", |
| 21 "alignJustified", | 20 "alignJustified", |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 RWHVMEditCommandHelper::CommandNameForSelector(_cmd); | 132 RWHVMEditCommandHelper::CommandNameForSelector(_cmd); |
| 134 std::string command([command_name_ns UTF8String]); | 133 std::string command([command_name_ns UTF8String]); |
| 135 | 134 |
| 136 // Forward the edit command string down the pipeline. | 135 // Forward the edit command string down the pipeline. |
| 137 RenderWidgetHostViewMac* rwhv = [(id<RenderWidgetHostViewMacOwner>)self | 136 RenderWidgetHostViewMac* rwhv = [(id<RenderWidgetHostViewMacOwner>)self |
| 138 renderWidgetHostViewMac]; | 137 renderWidgetHostViewMac]; |
| 139 DCHECK(rwhv); | 138 DCHECK(rwhv); |
| 140 | 139 |
| 141 // The second parameter is the core command value which isn't used here. | 140 // The second parameter is the core command value which isn't used here. |
| 142 RenderWidgetHost* rwh = rwhv->GetRenderWidgetHost(); | 141 RenderWidgetHost* rwh = rwhv->GetRenderWidgetHost(); |
| 143 rwh->Send(new ViewMsg_ExecuteEditCommand(rwh->routing_id(), command, "")); | 142 rwh->ExecuteEditCommand(command, ""); |
| 144 } | 143 } |
| 145 | 144 |
| 146 } // namespace | 145 } // namespace |
| 147 | 146 |
| 148 // Maps an objc-selector to a core command name. | 147 // Maps an objc-selector to a core command name. |
| 149 // | 148 // |
| 150 // Returns the core command name (which is the selector name with the trailing | 149 // Returns the core command name (which is the selector name with the trailing |
| 151 // ':' stripped in most cases). | 150 // ':' stripped in most cases). |
| 152 // | 151 // |
| 153 // Adapted from a function by the same name in | 152 // Adapted from a function by the same name in |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 NSArray* RWHVMEditCommandHelper::GetEditSelectorNames() { | 221 NSArray* RWHVMEditCommandHelper::GetEditSelectorNames() { |
| 223 size_t num_edit_commands = arraysize(kEditCommands); | 222 size_t num_edit_commands = arraysize(kEditCommands); |
| 224 NSMutableArray* ret = [NSMutableArray arrayWithCapacity:num_edit_commands]; | 223 NSMutableArray* ret = [NSMutableArray arrayWithCapacity:num_edit_commands]; |
| 225 | 224 |
| 226 for (size_t i = 0; i < num_edit_commands; ++i) { | 225 for (size_t i = 0; i < num_edit_commands; ++i) { |
| 227 [ret addObject:[NSString stringWithUTF8String:kEditCommands[i]]]; | 226 [ret addObject:[NSString stringWithUTF8String:kEditCommands[i]]]; |
| 228 } | 227 } |
| 229 | 228 |
| 230 return ret; | 229 return ret; |
| 231 } | 230 } |
| OLD | NEW |