diff options
author | sail@chromium.org <sail@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-26 00:17:42 +0000 |
---|---|---|
committer | sail@chromium.org <sail@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-26 00:17:42 +0000 |
commit | 21cea6c0f49893d48f4299f0aa8910c1d3130914 (patch) | |
tree | 63df389b24bd96b972eaab43b2f1632960722cb4 /chrome/browser/renderer_host/render_view_host.cc | |
parent | 6d079b9a62065433b24eae83ad689d3defb628df (diff) | |
download | chromium_src-21cea6c0f49893d48f4299f0aa8910c1d3130914.zip chromium_src-21cea6c0f49893d48f4299f0aa8910c1d3130914.tar.gz chromium_src-21cea6c0f49893d48f4299f0aa8910c1d3130914.tar.bz2 |
Mac: Enable "Check Spelling While Typing" in Edit menu
Currently the "Edit -> Spelling and Grammar -> Check Spelling While Typing" menu item is always disabled.
The problem is that the logic to enable / disable this item lives in the render process and not in the UI.
This patch implements a generic message that the render process can send to the browser to update the state of view commands. This is used to enable and disable the "Check Spelling While Typing" menu item.
BUG=38440
TEST=Clicked in an edit box and verified that the "Check Spelling While Typing" menu item was enabled. Verified that changing the value from the context menu correctly updates the Edit menu as well.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@72570 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/renderer_host/render_view_host.cc')
-rw-r--r-- | chrome/browser/renderer_host/render_view_host.cc | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/chrome/browser/renderer_host/render_view_host.cc b/chrome/browser/renderer_host/render_view_host.cc index 566f1fc..46ba75a 100644 --- a/chrome/browser/renderer_host/render_view_host.cc +++ b/chrome/browser/renderer_host/render_view_host.cc @@ -350,6 +350,22 @@ int RenderViewHost::GetPendingRequestId() { return pending_request_id_; } +RenderViewHost::CommandState RenderViewHost::GetStateForCommand( + RenderViewCommand command) const { + if (command != RENDER_VIEW_COMMAND_TOGGLE_SPELL_CHECK) + LOG(DFATAL) << "Unknown command " << command; + + std::map<RenderViewCommand, CommandState>::const_iterator it = + command_states_.find(command); + if (it == command_states_.end()) { + CommandState state; + state.is_enabled = false; + state.checked_state = RENDER_VIEW_COMMAND_CHECKED_STATE_UNCHECKED; + return state; + } + return it->second; +} + void RenderViewHost::Stop() { Send(new ViewMsg_Stop(routing_id())); } @@ -827,6 +843,8 @@ bool RenderViewHost::OnMessageReceived(const IPC::Message& msg) { #endif IPC_MESSAGE_HANDLER(ViewHostMsg_PagesReadyForPreview, OnPagesReadyForPreview) + IPC_MESSAGE_HANDLER(ViewHostMsg_CommandStateChanged, + OnCommandStateChanged) // Have the super handle all other messages. IPC_MESSAGE_UNHANDLED(handled = RenderWidgetHost::OnMessageReceived(msg)) IPC_END_MESSAGE_MAP_EX() @@ -1787,3 +1805,25 @@ void RenderViewHost::OnPagesReadyForPreview( // Send the printingDone msg for now. Send(new ViewMsg_PrintingDone(routing_id(), params.document_cookie, true)); } + +void RenderViewHost::OnCommandStateChanged(int command, + bool is_enabled, + int checked_state) { + if (command != RENDER_VIEW_COMMAND_TOGGLE_SPELL_CHECK) { + LOG(DFATAL) << "Unknown command " << command; + return; + } + + if (checked_state != RENDER_VIEW_COMMAND_CHECKED_STATE_UNCHECKED && + checked_state != RENDER_VIEW_COMMAND_CHECKED_STATE_CHECKED && + checked_state != RENDER_VIEW_COMMAND_CHECKED_STATE_MIXED) { + LOG(DFATAL) << "Invalid checked state " << checked_state; + return; + } + + CommandState state; + state.is_enabled = is_enabled; + state.checked_state = + static_cast<RenderViewCommandCheckedState>(checked_state); + command_states_[static_cast<RenderViewCommand>(command)] = state; +} |