Index: chrome/browser/renderer_host/render_view_host.cc |
=================================================================== |
--- chrome/browser/renderer_host/render_view_host.cc (revision 71029) |
+++ chrome/browser/renderer_host/render_view_host.cc (working copy) |
@@ -360,6 +360,27 @@ |
return pending_request_id_; |
} |
+RenderViewHost::CommandState RenderViewHost::GetStateForCommand( |
+ RenderViewCommand command) const { |
+ switch (command) { |
brettw
2011/01/13 05:59:55
Any reason this isn't an if statement? It will be
sail
2011/01/13 23:38:15
Done.
|
+ case RENDER_VIEW_COMMAND_TOGGLE_SPELL_CHECK: |
+ break; |
+ default: |
+ LOG(DFATAL) << "Unknown command " << command; |
+ break; |
+ } |
+ |
+ 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 = COMMAND_CHECKED_STATE_UNCHECKED; |
+ return state; |
+ } |
+ return it->second; |
+} |
+ |
void RenderViewHost::Stop() { |
Send(new ViewMsg_Stop(routing_id())); |
} |
@@ -867,6 +888,8 @@ |
#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() |
@@ -2017,3 +2040,34 @@ |
// 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) { |
+ RenderViewCommand render_view_command; |
+ switch (command) { |
brettw
2011/01/13 05:59:55
I'd probably use an if for these switches as well
sail
2011/01/13 23:38:15
Done.
|
+ case RENDER_VIEW_COMMAND_TOGGLE_SPELL_CHECK: |
+ render_view_command = static_cast<RenderViewCommand>(command); |
+ break; |
+ default: |
+ LOG(DFATAL) << "Unknown command " << command; |
+ return; |
+ } |
+ |
+ CommandCheckedState command_checked_state; |
+ switch (checked_state) { |
+ case COMMAND_CHECKED_STATE_UNCHECKED: |
+ case COMMAND_CHECKED_STATE_CHECKED: |
+ case COMMAND_CHECKED_STATE_MIXED: |
+ command_checked_state = static_cast<CommandCheckedState>(checked_state); |
+ break; |
+ default: |
+ LOG(DFATAL) << "Invalid checked state " << checked_state; |
+ return; |
+ } |
+ |
+ CommandState state; |
+ state.is_enabled = is_enabled; |
+ state.checked_state = command_checked_state; |
+ command_states_[render_view_command] = state; |
+} |