diff options
-rw-r--r-- | chrome/app/chrome_command_ids.h | 1 | ||||
-rw-r--r-- | chrome/app/generated_resources.grd | 17 | ||||
-rw-r--r-- | chrome/app/nibs/MainMenu.xib | 59 | ||||
-rw-r--r-- | chrome/browser/tab_contents/render_view_context_menu.cc | 7 | ||||
-rw-r--r-- | chrome/browser/ui/views/tab_contents/render_view_context_menu_views.cc | 4 | ||||
-rw-r--r-- | content/browser/renderer_host/render_widget_host.cc | 5 | ||||
-rw-r--r-- | content/browser/renderer_host/render_widget_host.h | 1 | ||||
-rw-r--r-- | content/browser/renderer_host/render_widget_host_view_mac.mm | 21 | ||||
-rw-r--r-- | content/common/view_messages.h | 1 | ||||
-rw-r--r-- | content/renderer/render_view_impl.cc | 9 | ||||
-rw-r--r-- | content/renderer/render_view_impl.h | 1 |
11 files changed, 85 insertions, 41 deletions
diff --git a/chrome/app/chrome_command_ids.h b/chrome/app/chrome_command_ids.h index fc334fa..228347a 100644 --- a/chrome/app/chrome_command_ids.h +++ b/chrome/app/chrome_command_ids.h @@ -258,6 +258,7 @@ #define IDC_CONTENT_CONTEXT_UNDO 50144 #define IDC_CONTENT_CONTEXT_REDO 50145 #define IDC_CONTENT_CONTEXT_SELECTALL 50146 +#define IDC_CONTENT_CONTEXT_PASTE_AND_MATCH_STYLE 50147 // Other items. #define IDC_CONTENT_CONTEXT_TRANSLATE 50150 #define IDC_CONTENT_CONTEXT_INSPECTELEMENT 50151 diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd index d64a6d1..bf4dad1 100644 --- a/chrome/app/generated_resources.grd +++ b/chrome/app/generated_resources.grd @@ -734,6 +734,23 @@ are declared in build/common.gypi. </message> </if> + <!-- Paste and Match Style / Paste as Plain Text --> + <if expr="is_macosx"> + <message name="IDS_CONTENT_CONTEXT_PASTE_AND_MATCH_STYLE" desc="Mac/In Title Case: The name of the 'Paste and Match Style' command in the content area context menu"> + Paste and Match Style + </message> + </if> + <if expr="not is_macosx and pp_ifdef('use_titlecase')"> + <message name="IDS_CONTENT_CONTEXT_PASTE_AND_MATCH_STYLE" desc="In Title Case: The name of the 'Paste as plain text' command in the content area context menu"> + Paste As Plain Text + </message> + </if> + <if expr="not is_macosx and not pp_ifdef('use_titlecase')"> + <message name="IDS_CONTENT_CONTEXT_PASTE_AND_MATCH_STYLE" desc="The name of the 'Paste as plain text' command in the content area context menu"> + Paste as plain text + </message> + </if> + <!-- Page menu --> <if expr="not pp_ifdef('use_titlecase')"> <message name="IDS_NEW_TAB" desc="The text label of the New Tab menu item"> diff --git a/chrome/app/nibs/MainMenu.xib b/chrome/app/nibs/MainMenu.xib index 2cf45a1..5b62df2 100644 --- a/chrome/app/nibs/MainMenu.xib +++ b/chrome/app/nibs/MainMenu.xib @@ -12,7 +12,6 @@ </object> <object class="NSMutableArray" key="IBDocument.EditedObjectIDs"> <bool key="EncodedWithXMLCoder">YES</bool> - <integer value="81"/> </object> <object class="NSArray" key="IBDocument.PluginDependencies"> <bool key="EncodedWithXMLCoder">YES</bool> @@ -1728,14 +1727,6 @@ </object> <object class="IBConnectionRecord"> <object class="IBActionConnection" key="connection"> - <string key="label">pasteAsPlainText:</string> - <reference key="source" ref="1014"/> - <reference key="destination" ref="688066565"/> - </object> - <int key="connectionID">659</int> - </object> - <object class="IBConnectionRecord"> - <object class="IBActionConnection" key="connection"> <string key="label">commandDispatch:</string> <reference key="source" ref="1014"/> <reference key="destination" ref="1008975930"/> @@ -1840,14 +1831,6 @@ </object> <object class="IBConnectionRecord"> <object class="IBActionConnection" key="connection"> - <string key="label">pasteAsPlainText:</string> - <reference key="source" ref="1014"/> - <reference key="destination" ref="499460629"/> - </object> - <int key="connectionID">690</int> - </object> - <object class="IBConnectionRecord"> - <object class="IBActionConnection" key="connection"> <string key="label">commandDispatch:</string> <reference key="source" ref="1014"/> <reference key="destination" ref="210963491"/> @@ -1862,6 +1845,22 @@ </object> <int key="connectionID">695</int> </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">pasteAndMatchStyle:</string> + <reference key="source" ref="1014"/> + <reference key="destination" ref="688066565"/> + </object> + <int key="connectionID">696</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">pasteAndMatchStyle:</string> + <reference key="source" ref="1014"/> + <reference key="destination" ref="499460629"/> + </object> + <int key="connectionID">697</int> + </object> </object> <object class="IBMutableOrderedSet" key="objectRecords"> <object class="NSArray" key="orderedObjects"> @@ -3030,7 +3029,7 @@ <integer value="1"/> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <integer value="1"/> - <string>{{512, 142}, {358, 263}}</string> + <string>{{442, 276}, {358, 263}}</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <integer value="1"/> <string>{{197, 734}, {243, 243}}</string> @@ -3074,7 +3073,7 @@ <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <integer value="1"/> <string>{{525, 802}, {197, 73}}</string> - <string>{{0, 539}, {1852, 20}}</string> + <string>{{6, 364}, {1852, 20}}</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <integer value="1"/> <string>{74, 862}</string> @@ -3213,7 +3212,7 @@ </object> </object> <nil key="sourceID"/> - <int key="maxID">695</int> + <int key="maxID">697</int> </object> <object class="IBClassDescriber" key="IBDocument.Classes"> <object class="NSMutableArray" key="referencedPartialClassDescriptions"> @@ -3440,11 +3439,13 @@ <bool key="EncodedWithXMLCoder">YES</bool> <string>commandDispatch:</string> <string>copyToFindPboard:</string> + <string>pasteAndMatchStyle:</string> </object> <object class="NSMutableArray" key="dict.values"> <bool key="EncodedWithXMLCoder">YES</bool> <string>id</string> <string>id</string> + <string>id</string> </object> </object> <object class="NSMutableDictionary" key="actionInfosByName"> @@ -3453,6 +3454,7 @@ <bool key="EncodedWithXMLCoder">YES</bool> <string>commandDispatch:</string> <string>copyToFindPboard:</string> + <string>pasteAndMatchStyle:</string> </object> <object class="NSMutableArray" key="dict.values"> <bool key="EncodedWithXMLCoder">YES</bool> @@ -3464,6 +3466,10 @@ <string key="name">copyToFindPboard:</string> <string key="candidateClassName">id</string> </object> + <object class="IBActionInfo"> + <string key="name">pasteAndMatchStyle:</string> + <string key="candidateClassName">id</string> + </object> </object> </object> <object class="IBClassDescriptionSource" key="sourceIdentifier"> @@ -3544,28 +3550,21 @@ <string key="className">NSObject</string> <object class="IBClassDescriptionSource" key="sourceIdentifier"> <string key="majorKey">IBProjectSource</string> - <string key="minorKey">browser/renderer_host/accelerated_plugin_view_mac.h</string> - </object> - </object> - <object class="IBPartialClassDescription"> - <string key="className">NSObject</string> - <object class="IBClassDescriptionSource" key="sourceIdentifier"> - <string key="majorKey">IBProjectSource</string> - <string key="minorKey">browser/ui/cocoa/objc_zombie.h</string> + <string key="minorKey">browser/ui/cocoa/status_bubble_mac.h</string> </object> </object> <object class="IBPartialClassDescription"> <string key="className">NSObject</string> <object class="IBClassDescriptionSource" key="sourceIdentifier"> <string key="majorKey">IBProjectSource</string> - <string key="minorKey">browser/ui/cocoa/status_bubble_mac.h</string> + <string key="minorKey">browser/ui/cocoa/tabs/tab_strip_model_observer_bridge.h</string> </object> </object> <object class="IBPartialClassDescription"> <string key="className">NSObject</string> <object class="IBClassDescriptionSource" key="sourceIdentifier"> <string key="majorKey">IBProjectSource</string> - <string key="minorKey">browser/ui/cocoa/tabs/tab_strip_model_observer_bridge.h</string> + <string key="minorKey">common/mac/objc_zombie.h</string> </object> </object> <object class="IBPartialClassDescription"> diff --git a/chrome/browser/tab_contents/render_view_context_menu.cc b/chrome/browser/tab_contents/render_view_context_menu.cc index 071f164..e21ff5c 100644 --- a/chrome/browser/tab_contents/render_view_context_menu.cc +++ b/chrome/browser/tab_contents/render_view_context_menu.cc @@ -872,6 +872,8 @@ void RenderViewContextMenu::AppendEditableItems() { IDS_CONTENT_CONTEXT_COPY); menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_PASTE, IDS_CONTENT_CONTEXT_PASTE); + menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_PASTE_AND_MATCH_STYLE, + IDS_CONTENT_CONTEXT_PASTE_AND_MATCH_STYLE); menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_DELETE, IDS_CONTENT_CONTEXT_DELETE); menu_model_.AddSeparator(); @@ -1234,6 +1236,7 @@ bool RenderViewContextMenu::IsCommandIdEnabled(int id) const { return !!(params_.edit_flags & WebContextMenuData::CanCopy); case IDC_CONTENT_CONTEXT_PASTE: + case IDC_CONTENT_CONTEXT_PASTE_AND_MATCH_STYLE: return !!(params_.edit_flags & WebContextMenuData::CanPaste); case IDC_CONTENT_CONTEXT_DELETE: @@ -1714,6 +1717,10 @@ void RenderViewContextMenu::ExecuteCommand(int id, int event_flags) { rvh->Paste(); break; + case IDC_CONTENT_CONTEXT_PASTE_AND_MATCH_STYLE: + rvh->PasteAndMatchStyle(); + break; + case IDC_CONTENT_CONTEXT_DELETE: rvh->Delete(); break; diff --git a/chrome/browser/ui/views/tab_contents/render_view_context_menu_views.cc b/chrome/browser/ui/views/tab_contents/render_view_context_menu_views.cc index 54ce9b0..4391684 100644 --- a/chrome/browser/ui/views/tab_contents/render_view_context_menu_views.cc +++ b/chrome/browser/ui/views/tab_contents/render_view_context_menu_views.cc @@ -89,6 +89,10 @@ bool RenderViewContextMenuViews::GetAcceleratorForCommandId( *accel = views::Accelerator(ui::VKEY_V, false, true, false); return true; + case IDC_CONTENT_CONTEXT_PASTE_AND_MATCH_STYLE: + *accel = views::Accelerator(ui::VKEY_V, true, true, false); + return true; + case IDC_CONTENT_CONTEXT_SELECTALL: *accel = views::Accelerator(ui::VKEY_A, false, true, false); return true; diff --git a/content/browser/renderer_host/render_widget_host.cc b/content/browser/renderer_host/render_widget_host.cc index 1aa93ca..43639bf 100644 --- a/content/browser/renderer_host/render_widget_host.cc +++ b/content/browser/renderer_host/render_widget_host.cc @@ -1377,6 +1377,11 @@ void RenderWidgetHost::Paste() { UserMetrics::RecordAction(UserMetricsAction("Paste")); } +void RenderWidgetHost::PasteAndMatchStyle() { + Send(new ViewMsg_PasteAndMatchStyle(routing_id())); + UserMetrics::RecordAction(UserMetricsAction("PasteAndMatchStyle")); +} + void RenderWidgetHost::Delete() { Send(new ViewMsg_Delete(routing_id())); UserMetrics::RecordAction(UserMetricsAction("DeleteSelection")); diff --git a/content/browser/renderer_host/render_widget_host.h b/content/browser/renderer_host/render_widget_host.h index c31a16d..25cec88 100644 --- a/content/browser/renderer_host/render_widget_host.h +++ b/content/browser/renderer_host/render_widget_host.h @@ -419,6 +419,7 @@ class CONTENT_EXPORT RenderWidgetHost : public IPC::Channel::Listener, void Copy(); void CopyToFindPboard(); void Paste(); + void PasteAndMatchStyle(); void Delete(); void SelectAll(); diff --git a/content/browser/renderer_host/render_widget_host_view_mac.mm b/content/browser/renderer_host/render_widget_host_view_mac.mm index 587f55a..b5dafbf 100644 --- a/content/browser/renderer_host/render_widget_host_view_mac.mm +++ b/content/browser/renderer_host/render_widget_host_view_mac.mm @@ -1911,7 +1911,7 @@ void RenderWidgetHostViewMac::SetTextInputActive(bool active) { action == @selector(copy:) || action == @selector(copyToFindPboard:) || action == @selector(paste:) || - action == @selector(pasteAsPlainText:)) { + action == @selector(pasteAndMatchStyle:)) { return renderWidgetHostView_->render_widget_host_->IsRenderView(); } @@ -2566,50 +2566,49 @@ extern NSString *NSTextInputReplacementRangeAttributeName; - (void)undo:(id)sender { if (renderWidgetHostView_->render_widget_host_->IsRenderView()) { static_cast<RenderViewHost*>(renderWidgetHostView_->render_widget_host_)-> - Undo(); + Undo(); } } - (void)redo:(id)sender { if (renderWidgetHostView_->render_widget_host_->IsRenderView()) { static_cast<RenderViewHost*>(renderWidgetHostView_->render_widget_host_)-> - Redo(); + Redo(); } } - (void)cut:(id)sender { if (renderWidgetHostView_->render_widget_host_->IsRenderView()) { static_cast<RenderViewHost*>(renderWidgetHostView_->render_widget_host_)-> - Cut(); + Cut(); } } - (void)copy:(id)sender { if (renderWidgetHostView_->render_widget_host_->IsRenderView()) { static_cast<RenderViewHost*>(renderWidgetHostView_->render_widget_host_)-> - Copy(); + Copy(); } } - (void)copyToFindPboard:(id)sender { if (renderWidgetHostView_->render_widget_host_->IsRenderView()) { static_cast<RenderViewHost*>(renderWidgetHostView_->render_widget_host_)-> - CopyToFindPboard(); + CopyToFindPboard(); } } - (void)paste:(id)sender { if (renderWidgetHostView_->render_widget_host_->IsRenderView()) { static_cast<RenderViewHost*>(renderWidgetHostView_->render_widget_host_)-> - Paste(); + Paste(); } } -- (void)pasteAsPlainText:(id)sender { +- (void)pasteAndMatchStyle:(id)sender { if (renderWidgetHostView_->render_widget_host_->IsRenderView()) { - RenderWidgetHost* rwh = renderWidgetHostView_->render_widget_host_; - rwh->Send(new ViewMsg_ExecuteEditCommand( - rwh->routing_id(), "PasteAndMatchStyle", "")); + static_cast<RenderViewHost*>(renderWidgetHostView_->render_widget_host_)-> + PasteAndMatchStyle(); } } diff --git a/content/common/view_messages.h b/content/common/view_messages.h index bba5d05..073b810 100644 --- a/content/common/view_messages.h +++ b/content/common/view_messages.h @@ -844,6 +844,7 @@ IPC_MESSAGE_ROUTED0(ViewMsg_Copy) IPC_MESSAGE_ROUTED0(ViewMsg_CopyToFindPboard) #endif IPC_MESSAGE_ROUTED0(ViewMsg_Paste) +IPC_MESSAGE_ROUTED0(ViewMsg_PasteAndMatchStyle) // Replaces the selected region or a word around the cursor with the // specified string. IPC_MESSAGE_ROUTED1(ViewMsg_Replace, diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc index 7a87234..d3dfc1f 100644 --- a/content/renderer/render_view_impl.cc +++ b/content/renderer/render_view_impl.cc @@ -581,6 +581,7 @@ bool RenderViewImpl::OnMessageReceived(const IPC::Message& message) { IPC_MESSAGE_HANDLER(ViewMsg_CopyToFindPboard, OnCopyToFindPboard) #endif IPC_MESSAGE_HANDLER(ViewMsg_Paste, OnPaste) + IPC_MESSAGE_HANDLER(ViewMsg_PasteAndMatchStyle, OnPasteAndMatchStyle) IPC_MESSAGE_HANDLER(ViewMsg_Replace, OnReplace) IPC_MESSAGE_HANDLER(ViewMsg_Delete, OnDelete) IPC_MESSAGE_HANDLER(ViewMsg_SelectAll, OnSelectAll) @@ -942,6 +943,14 @@ void RenderViewImpl::OnPaste() { webview()->focusedFrame()->executeCommand(WebString::fromUTF8("Paste")); } +void RenderViewImpl::OnPasteAndMatchStyle() { + if (!webview()) + return; + + webview()->focusedFrame()->executeCommand( + WebString::fromUTF8("PasteAndMatchStyle")); +} + void RenderViewImpl::OnReplace(const string16& text) { if (!webview()) return; diff --git a/content/renderer/render_view_impl.h b/content/renderer/render_view_impl.h index 72d8827..2ae0e9d 100644 --- a/content/renderer/render_view_impl.h +++ b/content/renderer/render_view_impl.h @@ -805,6 +805,7 @@ class RenderViewImpl : public RenderWidget, void OnMoveOrResizeStarted(); CONTENT_EXPORT void OnNavigate(const ViewMsg_Navigate_Params& params); void OnPaste(); + void OnPasteAndMatchStyle(); #if defined(OS_MACOSX) void OnPluginImeCompositionCompleted(const string16& text, int plugin_id); #endif |