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 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 int request_id) { | 353 int request_id) { |
354 CrossSiteRequestManager::GetInstance()->SetHasPendingCrossSiteRequest( | 354 CrossSiteRequestManager::GetInstance()->SetHasPendingCrossSiteRequest( |
355 process()->id(), routing_id(), has_pending_request); | 355 process()->id(), routing_id(), has_pending_request); |
356 pending_request_id_ = request_id; | 356 pending_request_id_ = request_id; |
357 } | 357 } |
358 | 358 |
359 int RenderViewHost::GetPendingRequestId() { | 359 int RenderViewHost::GetPendingRequestId() { |
360 return pending_request_id_; | 360 return pending_request_id_; |
361 } | 361 } |
362 | 362 |
| 363 RenderViewHost::CommandState RenderViewHost::GetStateForCommand( |
| 364 RenderViewCommand command) const { |
| 365 if (command != RENDER_VIEW_COMMAND_TOGGLE_SPELL_CHECK) |
| 366 LOG(DFATAL) << "Unknown command " << command; |
| 367 |
| 368 std::map<RenderViewCommand, CommandState>::const_iterator it = |
| 369 command_states_.find(command); |
| 370 if (it == command_states_.end()) { |
| 371 CommandState state; |
| 372 state.is_enabled = false; |
| 373 state.checked_state = RENDER_VIEW_COMMAND_CHECKED_STATE_UNCHECKED; |
| 374 return state; |
| 375 } |
| 376 return it->second; |
| 377 } |
| 378 |
363 void RenderViewHost::Stop() { | 379 void RenderViewHost::Stop() { |
364 Send(new ViewMsg_Stop(routing_id())); | 380 Send(new ViewMsg_Stop(routing_id())); |
365 } | 381 } |
366 | 382 |
367 void RenderViewHost::ReloadFrame() { | 383 void RenderViewHost::ReloadFrame() { |
368 Send(new ViewMsg_ReloadFrame(routing_id())); | 384 Send(new ViewMsg_ReloadFrame(routing_id())); |
369 } | 385 } |
370 | 386 |
371 bool RenderViewHost::PrintPages() { | 387 bool RenderViewHost::PrintPages() { |
372 return Send(new ViewMsg_PrintPages(routing_id())); | 388 return Send(new ViewMsg_PrintPages(routing_id())); |
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
860 IPC_MESSAGE_HANDLER(ViewHostMsg_DetectedPhishingSite, | 876 IPC_MESSAGE_HANDLER(ViewHostMsg_DetectedPhishingSite, |
861 OnDetectedPhishingSite) | 877 OnDetectedPhishingSite) |
862 IPC_MESSAGE_HANDLER(ViewHostMsg_ScriptEvalResponse, OnScriptEvalResponse) | 878 IPC_MESSAGE_HANDLER(ViewHostMsg_ScriptEvalResponse, OnScriptEvalResponse) |
863 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateContentRestrictions, | 879 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateContentRestrictions, |
864 OnUpdateContentRestrictions) | 880 OnUpdateContentRestrictions) |
865 #if defined(OS_MACOSX) | 881 #if defined(OS_MACOSX) |
866 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowPopup, OnMsgShowPopup) | 882 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowPopup, OnMsgShowPopup) |
867 #endif | 883 #endif |
868 IPC_MESSAGE_HANDLER(ViewHostMsg_PagesReadyForPreview, | 884 IPC_MESSAGE_HANDLER(ViewHostMsg_PagesReadyForPreview, |
869 OnPagesReadyForPreview) | 885 OnPagesReadyForPreview) |
| 886 IPC_MESSAGE_HANDLER(ViewHostMsg_CommandStateChanged, |
| 887 OnCommandStateChanged) |
870 // Have the super handle all other messages. | 888 // Have the super handle all other messages. |
871 IPC_MESSAGE_UNHANDLED(handled = RenderWidgetHost::OnMessageReceived(msg)) | 889 IPC_MESSAGE_UNHANDLED(handled = RenderWidgetHost::OnMessageReceived(msg)) |
872 IPC_END_MESSAGE_MAP_EX() | 890 IPC_END_MESSAGE_MAP_EX() |
873 | 891 |
874 if (!msg_is_ok) { | 892 if (!msg_is_ok) { |
875 // The message had a handler, but its de-serialization failed. | 893 // The message had a handler, but its de-serialization failed. |
876 // Kill the renderer. | 894 // Kill the renderer. |
877 UserMetrics::RecordAction(UserMetricsAction("BadMessageTerminate_RVH")); | 895 UserMetrics::RecordAction(UserMetricsAction("BadMessageTerminate_RVH")); |
878 process()->ReceivedBadMessage(); | 896 process()->ReceivedBadMessage(); |
879 } | 897 } |
(...skipping 1130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2010 if (printer_query.get()) { | 2028 if (printer_query.get()) { |
2011 BrowserThread::PostTask( | 2029 BrowserThread::PostTask( |
2012 BrowserThread::IO, FROM_HERE, | 2030 BrowserThread::IO, FROM_HERE, |
2013 NewRunnableMethod(printer_query.get(), | 2031 NewRunnableMethod(printer_query.get(), |
2014 &printing::PrinterQuery::StopWorker)); | 2032 &printing::PrinterQuery::StopWorker)); |
2015 } | 2033 } |
2016 | 2034 |
2017 // Send the printingDone msg for now. | 2035 // Send the printingDone msg for now. |
2018 Send(new ViewMsg_PrintingDone(routing_id(), params.document_cookie, true)); | 2036 Send(new ViewMsg_PrintingDone(routing_id(), params.document_cookie, true)); |
2019 } | 2037 } |
| 2038 |
| 2039 void RenderViewHost::OnCommandStateChanged(int command, |
| 2040 bool is_enabled, |
| 2041 int checked_state) { |
| 2042 if (command != RENDER_VIEW_COMMAND_TOGGLE_SPELL_CHECK) { |
| 2043 LOG(DFATAL) << "Unknown command " << command; |
| 2044 return; |
| 2045 } |
| 2046 |
| 2047 if (checked_state != RENDER_VIEW_COMMAND_CHECKED_STATE_UNCHECKED && |
| 2048 checked_state != RENDER_VIEW_COMMAND_CHECKED_STATE_CHECKED && |
| 2049 checked_state != RENDER_VIEW_COMMAND_CHECKED_STATE_MIXED) { |
| 2050 LOG(DFATAL) << "Invalid checked state " << checked_state; |
| 2051 return; |
| 2052 } |
| 2053 |
| 2054 CommandState state; |
| 2055 state.is_enabled = is_enabled; |
| 2056 state.checked_state = |
| 2057 static_cast<RenderViewCommandCheckedState>(checked_state); |
| 2058 command_states_[static_cast<RenderViewCommand>(command)] = state; |
| 2059 } |
OLD | NEW |