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 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.
| |
366 case RENDER_VIEW_COMMAND_TOGGLE_SPELL_CHECK: | |
367 break; | |
368 default: | |
369 LOG(DFATAL) << "Unknown command " << command; | |
370 break; | |
371 } | |
372 | |
373 std::map<RenderViewCommand, CommandState>::const_iterator it = | |
374 command_states_.find(command); | |
375 if (it == command_states_.end()) { | |
376 CommandState state; | |
377 state.is_enabled = false; | |
378 state.checked_state = COMMAND_CHECKED_STATE_UNCHECKED; | |
379 return state; | |
380 } | |
381 return it->second; | |
382 } | |
383 | |
363 void RenderViewHost::Stop() { | 384 void RenderViewHost::Stop() { |
364 Send(new ViewMsg_Stop(routing_id())); | 385 Send(new ViewMsg_Stop(routing_id())); |
365 } | 386 } |
366 | 387 |
367 void RenderViewHost::ReloadFrame() { | 388 void RenderViewHost::ReloadFrame() { |
368 Send(new ViewMsg_ReloadFrame(routing_id())); | 389 Send(new ViewMsg_ReloadFrame(routing_id())); |
369 } | 390 } |
370 | 391 |
371 bool RenderViewHost::PrintPages() { | 392 bool RenderViewHost::PrintPages() { |
372 return Send(new ViewMsg_PrintPages(routing_id())); | 393 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, | 881 IPC_MESSAGE_HANDLER(ViewHostMsg_DetectedPhishingSite, |
861 OnDetectedPhishingSite) | 882 OnDetectedPhishingSite) |
862 IPC_MESSAGE_HANDLER(ViewHostMsg_ScriptEvalResponse, OnScriptEvalResponse) | 883 IPC_MESSAGE_HANDLER(ViewHostMsg_ScriptEvalResponse, OnScriptEvalResponse) |
863 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateContentRestrictions, | 884 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateContentRestrictions, |
864 OnUpdateContentRestrictions) | 885 OnUpdateContentRestrictions) |
865 #if defined(OS_MACOSX) | 886 #if defined(OS_MACOSX) |
866 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowPopup, OnMsgShowPopup) | 887 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowPopup, OnMsgShowPopup) |
867 #endif | 888 #endif |
868 IPC_MESSAGE_HANDLER(ViewHostMsg_PagesReadyForPreview, | 889 IPC_MESSAGE_HANDLER(ViewHostMsg_PagesReadyForPreview, |
869 OnPagesReadyForPreview) | 890 OnPagesReadyForPreview) |
891 IPC_MESSAGE_HANDLER(ViewHostMsg_CommandStateChanged, | |
892 OnCommandStateChanged) | |
870 // Have the super handle all other messages. | 893 // Have the super handle all other messages. |
871 IPC_MESSAGE_UNHANDLED(handled = RenderWidgetHost::OnMessageReceived(msg)) | 894 IPC_MESSAGE_UNHANDLED(handled = RenderWidgetHost::OnMessageReceived(msg)) |
872 IPC_END_MESSAGE_MAP_EX() | 895 IPC_END_MESSAGE_MAP_EX() |
873 | 896 |
874 if (!msg_is_ok) { | 897 if (!msg_is_ok) { |
875 // The message had a handler, but its de-serialization failed. | 898 // The message had a handler, but its de-serialization failed. |
876 // Kill the renderer. | 899 // Kill the renderer. |
877 UserMetrics::RecordAction(UserMetricsAction("BadMessageTerminate_RVH")); | 900 UserMetrics::RecordAction(UserMetricsAction("BadMessageTerminate_RVH")); |
878 process()->ReceivedBadMessage(); | 901 process()->ReceivedBadMessage(); |
879 } | 902 } |
(...skipping 1130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2010 if (printer_query.get()) { | 2033 if (printer_query.get()) { |
2011 BrowserThread::PostTask( | 2034 BrowserThread::PostTask( |
2012 BrowserThread::IO, FROM_HERE, | 2035 BrowserThread::IO, FROM_HERE, |
2013 NewRunnableMethod(printer_query.get(), | 2036 NewRunnableMethod(printer_query.get(), |
2014 &printing::PrinterQuery::StopWorker)); | 2037 &printing::PrinterQuery::StopWorker)); |
2015 } | 2038 } |
2016 | 2039 |
2017 // Send the printingDone msg for now. | 2040 // Send the printingDone msg for now. |
2018 Send(new ViewMsg_PrintingDone(routing_id(), params.document_cookie, true)); | 2041 Send(new ViewMsg_PrintingDone(routing_id(), params.document_cookie, true)); |
2019 } | 2042 } |
2043 | |
2044 void RenderViewHost::OnCommandStateChanged(int command, | |
2045 bool is_enabled, | |
2046 int checked_state) { | |
2047 RenderViewCommand render_view_command; | |
2048 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.
| |
2049 case RENDER_VIEW_COMMAND_TOGGLE_SPELL_CHECK: | |
2050 render_view_command = static_cast<RenderViewCommand>(command); | |
2051 break; | |
2052 default: | |
2053 LOG(DFATAL) << "Unknown command " << command; | |
2054 return; | |
2055 } | |
2056 | |
2057 CommandCheckedState command_checked_state; | |
2058 switch (checked_state) { | |
2059 case COMMAND_CHECKED_STATE_UNCHECKED: | |
2060 case COMMAND_CHECKED_STATE_CHECKED: | |
2061 case COMMAND_CHECKED_STATE_MIXED: | |
2062 command_checked_state = static_cast<CommandCheckedState>(checked_state); | |
2063 break; | |
2064 default: | |
2065 LOG(DFATAL) << "Invalid checked state " << checked_state; | |
2066 return; | |
2067 } | |
2068 | |
2069 CommandState state; | |
2070 state.is_enabled = is_enabled; | |
2071 state.checked_state = command_checked_state; | |
2072 command_states_[render_view_command] = state; | |
2073 } | |
OLD | NEW |