| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #include "chrome/browser/renderer_host/render_view_host.h" | 5 #include "chrome/browser/renderer_host/render_view_host.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <utility> | 8 #include <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 int request_id) { | 343 int request_id) { |
| 344 CrossSiteRequestManager::GetInstance()->SetHasPendingCrossSiteRequest( | 344 CrossSiteRequestManager::GetInstance()->SetHasPendingCrossSiteRequest( |
| 345 process()->id(), routing_id(), has_pending_request); | 345 process()->id(), routing_id(), has_pending_request); |
| 346 pending_request_id_ = request_id; | 346 pending_request_id_ = request_id; |
| 347 } | 347 } |
| 348 | 348 |
| 349 int RenderViewHost::GetPendingRequestId() { | 349 int RenderViewHost::GetPendingRequestId() { |
| 350 return pending_request_id_; | 350 return pending_request_id_; |
| 351 } | 351 } |
| 352 | 352 |
| 353 RenderViewHost::CommandState RenderViewHost::GetStateForCommand( | |
| 354 RenderViewCommand command) const { | |
| 355 if (command != RENDER_VIEW_COMMAND_TOGGLE_SPELL_CHECK) | |
| 356 LOG(DFATAL) << "Unknown command " << command; | |
| 357 | |
| 358 std::map<RenderViewCommand, CommandState>::const_iterator it = | |
| 359 command_states_.find(command); | |
| 360 if (it == command_states_.end()) { | |
| 361 CommandState state; | |
| 362 state.is_enabled = false; | |
| 363 state.checked_state = RENDER_VIEW_COMMAND_CHECKED_STATE_UNCHECKED; | |
| 364 return state; | |
| 365 } | |
| 366 return it->second; | |
| 367 } | |
| 368 | |
| 369 void RenderViewHost::Stop() { | 353 void RenderViewHost::Stop() { |
| 370 Send(new ViewMsg_Stop(routing_id())); | 354 Send(new ViewMsg_Stop(routing_id())); |
| 371 } | 355 } |
| 372 | 356 |
| 373 void RenderViewHost::ReloadFrame() { | 357 void RenderViewHost::ReloadFrame() { |
| 374 Send(new ViewMsg_ReloadFrame(routing_id())); | 358 Send(new ViewMsg_ReloadFrame(routing_id())); |
| 375 } | 359 } |
| 376 | 360 |
| 377 bool RenderViewHost::PrintPages() { | 361 bool RenderViewHost::PrintPages() { |
| 378 return Send(new ViewMsg_PrintPages(routing_id())); | 362 return Send(new ViewMsg_PrintPages(routing_id())); |
| (...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 836 IPC_MESSAGE_HANDLER(ViewHostMsg_FocusedNodeChanged, OnMsgFocusedNodeChanged) | 820 IPC_MESSAGE_HANDLER(ViewHostMsg_FocusedNodeChanged, OnMsgFocusedNodeChanged) |
| 837 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateZoomLimits, OnUpdateZoomLimits) | 821 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateZoomLimits, OnUpdateZoomLimits) |
| 838 IPC_MESSAGE_HANDLER(ViewHostMsg_DetectedPhishingSite, | 822 IPC_MESSAGE_HANDLER(ViewHostMsg_DetectedPhishingSite, |
| 839 OnDetectedPhishingSite) | 823 OnDetectedPhishingSite) |
| 840 IPC_MESSAGE_HANDLER(ViewHostMsg_ScriptEvalResponse, OnScriptEvalResponse) | 824 IPC_MESSAGE_HANDLER(ViewHostMsg_ScriptEvalResponse, OnScriptEvalResponse) |
| 841 #if defined(OS_MACOSX) | 825 #if defined(OS_MACOSX) |
| 842 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowPopup, OnMsgShowPopup) | 826 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowPopup, OnMsgShowPopup) |
| 843 #endif | 827 #endif |
| 844 IPC_MESSAGE_HANDLER(ViewHostMsg_PagesReadyForPreview, | 828 IPC_MESSAGE_HANDLER(ViewHostMsg_PagesReadyForPreview, |
| 845 OnPagesReadyForPreview) | 829 OnPagesReadyForPreview) |
| 846 IPC_MESSAGE_HANDLER(ViewHostMsg_CommandStateChanged, | |
| 847 OnCommandStateChanged) | |
| 848 // Have the super handle all other messages. | 830 // Have the super handle all other messages. |
| 849 IPC_MESSAGE_UNHANDLED(handled = RenderWidgetHost::OnMessageReceived(msg)) | 831 IPC_MESSAGE_UNHANDLED(handled = RenderWidgetHost::OnMessageReceived(msg)) |
| 850 IPC_END_MESSAGE_MAP_EX() | 832 IPC_END_MESSAGE_MAP_EX() |
| 851 | 833 |
| 852 if (!msg_is_ok) { | 834 if (!msg_is_ok) { |
| 853 // The message had a handler, but its de-serialization failed. | 835 // The message had a handler, but its de-serialization failed. |
| 854 // Kill the renderer. | 836 // Kill the renderer. |
| 855 UserMetrics::RecordAction(UserMetricsAction("BadMessageTerminate_RVH")); | 837 UserMetrics::RecordAction(UserMetricsAction("BadMessageTerminate_RVH")); |
| 856 process()->ReceivedBadMessage(); | 838 process()->ReceivedBadMessage(); |
| 857 } | 839 } |
| (...skipping 940 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1798 if (printer_query.get()) { | 1780 if (printer_query.get()) { |
| 1799 BrowserThread::PostTask( | 1781 BrowserThread::PostTask( |
| 1800 BrowserThread::IO, FROM_HERE, | 1782 BrowserThread::IO, FROM_HERE, |
| 1801 NewRunnableMethod(printer_query.get(), | 1783 NewRunnableMethod(printer_query.get(), |
| 1802 &printing::PrinterQuery::StopWorker)); | 1784 &printing::PrinterQuery::StopWorker)); |
| 1803 } | 1785 } |
| 1804 | 1786 |
| 1805 // Send the printingDone msg for now. | 1787 // Send the printingDone msg for now. |
| 1806 Send(new ViewMsg_PrintingDone(routing_id(), params.document_cookie, true)); | 1788 Send(new ViewMsg_PrintingDone(routing_id(), params.document_cookie, true)); |
| 1807 } | 1789 } |
| 1808 | |
| 1809 void RenderViewHost::OnCommandStateChanged(int command, | |
| 1810 bool is_enabled, | |
| 1811 int checked_state) { | |
| 1812 if (command != RENDER_VIEW_COMMAND_TOGGLE_SPELL_CHECK) { | |
| 1813 LOG(DFATAL) << "Unknown command " << command; | |
| 1814 return; | |
| 1815 } | |
| 1816 | |
| 1817 if (checked_state != RENDER_VIEW_COMMAND_CHECKED_STATE_UNCHECKED && | |
| 1818 checked_state != RENDER_VIEW_COMMAND_CHECKED_STATE_CHECKED && | |
| 1819 checked_state != RENDER_VIEW_COMMAND_CHECKED_STATE_MIXED) { | |
| 1820 LOG(DFATAL) << "Invalid checked state " << checked_state; | |
| 1821 return; | |
| 1822 } | |
| 1823 | |
| 1824 CommandState state; | |
| 1825 state.is_enabled = is_enabled; | |
| 1826 state.checked_state = | |
| 1827 static_cast<RenderViewCommandCheckedState>(checked_state); | |
| 1828 command_states_[static_cast<RenderViewCommand>(command)] = state; | |
| 1829 } | |
| OLD | NEW |