OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/render_view_host.h" | 5 #include "chrome/browser/render_view_host.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
673 OnReceivedSavableResourceLinksForCurrentPage); | 673 OnReceivedSavableResourceLinksForCurrentPage); |
674 IPC_MESSAGE_HANDLER(ViewHostMsg_SendSerializedHtmlData, | 674 IPC_MESSAGE_HANDLER(ViewHostMsg_SendSerializedHtmlData, |
675 OnReceivedSerializedHtmlData); | 675 OnReceivedSerializedHtmlData); |
676 IPC_MESSAGE_HANDLER(ViewHostMsg_DidGetApplicationInfo, | 676 IPC_MESSAGE_HANDLER(ViewHostMsg_DidGetApplicationInfo, |
677 OnDidGetApplicationInfo); | 677 OnDidGetApplicationInfo); |
678 IPC_MESSAGE_FORWARD(ViewHostMsg_JSOutOfMemory, delegate_, | 678 IPC_MESSAGE_FORWARD(ViewHostMsg_JSOutOfMemory, delegate_, |
679 RenderViewHostDelegate::OnJSOutOfMemory); | 679 RenderViewHostDelegate::OnJSOutOfMemory); |
680 IPC_MESSAGE_HANDLER(ViewHostMsg_ShouldClose_ACK, OnMsgShouldCloseACK); | 680 IPC_MESSAGE_HANDLER(ViewHostMsg_ShouldClose_ACK, OnMsgShouldCloseACK); |
681 IPC_MESSAGE_HANDLER(ViewHostMsg_UnloadListenerChanged, | 681 IPC_MESSAGE_HANDLER(ViewHostMsg_UnloadListenerChanged, |
682 OnUnloadListenerChanged); | 682 OnUnloadListenerChanged); |
| 683 IPC_MESSAGE_HANDLER(ViewHostMsg_QueryFormFieldAutofill, |
| 684 OnQueryFormFieldAutofill) |
683 // Have the super handle all other messages. | 685 // Have the super handle all other messages. |
684 IPC_MESSAGE_UNHANDLED(RenderWidgetHost::OnMessageReceived(msg)) | 686 IPC_MESSAGE_UNHANDLED(RenderWidgetHost::OnMessageReceived(msg)) |
685 IPC_END_MESSAGE_MAP_EX() | 687 IPC_END_MESSAGE_MAP_EX() |
686 | 688 |
687 if (!msg_is_ok) { | 689 if (!msg_is_ok) { |
688 // The message had a handler, but its de-serialization failed. | 690 // The message had a handler, but its de-serialization failed. |
689 // Kill the renderer. | 691 // Kill the renderer. |
690 process()->ReceivedBadMessage(msg.type()); | 692 process()->ReceivedBadMessage(msg.type()); |
691 } | 693 } |
692 } | 694 } |
693 | 695 |
694 void RenderViewHost::Shutdown() { | 696 void RenderViewHost::Shutdown() { |
695 // If we are being run modally (see RunModal), then we need to cleanup. | 697 // If we are being run modally (see RunModal), then we need to cleanup. |
696 if (run_modal_reply_msg_) { | 698 if (run_modal_reply_msg_) { |
697 if (--modal_dialog_count_ == 0) | 699 if (--modal_dialog_count_ == 0) |
698 ResetEvent(modal_dialog_event_.Get()); | 700 ResetEvent(modal_dialog_event_.Get()); |
699 Send(run_modal_reply_msg_); | 701 Send(run_modal_reply_msg_); |
700 run_modal_reply_msg_ = NULL; | 702 run_modal_reply_msg_ = NULL; |
701 } | 703 } |
702 RenderWidgetHost::Shutdown(); | 704 RenderWidgetHost::Shutdown(); |
703 } | 705 } |
704 | 706 |
705 void RenderViewHost::OnMsgCreateWindow(int route_id, | 707 void RenderViewHost::OnMsgCreateWindow(int route_id, |
706 HANDLE modal_dialog_event) { | 708 HANDLE modal_dialog_event) { |
707 RenderViewHostDelegate::View* view = delegate_->GetViewDelegate(); | 709 RenderViewHostDelegate::View* view = delegate_->GetViewDelegate(); |
708 if (view) | 710 if (view) |
709 view->CreateNewWindow(route_id, modal_dialog_event); | 711 view->CreateNewWindow(route_id, modal_dialog_event); |
710 } | 712 } |
711 | 713 |
712 void RenderViewHost::OnMsgCreateWidget(int route_id) { | 714 void RenderViewHost::OnMsgCreateWidget(int route_id, |
| 715 bool focus_on_show) { |
713 RenderViewHostDelegate::View* view = delegate_->GetViewDelegate(); | 716 RenderViewHostDelegate::View* view = delegate_->GetViewDelegate(); |
714 if (view) | 717 if (view) |
715 view->CreateNewWidget(route_id); | 718 view->CreateNewWidget(route_id, focus_on_show); |
716 } | 719 } |
717 | 720 |
718 void RenderViewHost::OnMsgShowView(int route_id, | 721 void RenderViewHost::OnMsgShowView(int route_id, |
719 WindowOpenDisposition disposition, | 722 WindowOpenDisposition disposition, |
720 const gfx::Rect& initial_pos, | 723 const gfx::Rect& initial_pos, |
721 bool user_gesture) { | 724 bool user_gesture) { |
722 RenderViewHostDelegate::View* view = delegate_->GetViewDelegate(); | 725 RenderViewHostDelegate::View* view = delegate_->GetViewDelegate(); |
723 if (view) | 726 if (view) |
724 view->ShowCreatedWindow(route_id, disposition, initial_pos, user_gesture); | 727 view->ShowCreatedWindow(route_id, disposition, initial_pos, user_gesture); |
725 } | 728 } |
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1196 StopHangMonitorTimeout(); | 1199 StopHangMonitorTimeout(); |
1197 DCHECK(is_waiting_for_unload_ack_); | 1200 DCHECK(is_waiting_for_unload_ack_); |
1198 is_waiting_for_unload_ack_ = false; | 1201 is_waiting_for_unload_ack_ = false; |
1199 delegate_->ShouldClosePage(proceed); | 1202 delegate_->ShouldClosePage(proceed); |
1200 } | 1203 } |
1201 | 1204 |
1202 void RenderViewHost::OnUnloadListenerChanged(bool has_listener) { | 1205 void RenderViewHost::OnUnloadListenerChanged(bool has_listener) { |
1203 has_unload_listener_ = has_listener; | 1206 has_unload_listener_ = has_listener; |
1204 } | 1207 } |
1205 | 1208 |
| 1209 void RenderViewHost::OnQueryFormFieldAutofill(const std::wstring& field_name, |
| 1210 const std::wstring& user_text, |
| 1211 int64 node_id, |
| 1212 int request_id) { |
| 1213 // TODO(jcampan): this is where the suggestions should be queried from the |
| 1214 // database. The sample code commented below is left here in the meantime for |
| 1215 // testing purpose. |
| 1216 #ifndef TEST_AUTOFILL |
| 1217 static std::vector<std::wstring>* suggestions = NULL; |
| 1218 if (!suggestions) { |
| 1219 suggestions = new std::vector<std::wstring>(); |
| 1220 suggestions->push_back(L"Alice"); |
| 1221 suggestions->push_back(L"Jay"); |
| 1222 suggestions->push_back(L"Jason"); |
| 1223 suggestions->push_back(L"Jasmine"); |
| 1224 suggestions->push_back(L"Jamel"); |
| 1225 suggestions->push_back(L"Jamelo"); |
| 1226 suggestions->push_back(L"Volvo"); |
| 1227 suggestions->push_back(L"Volswagen"); |
| 1228 } |
| 1229 |
| 1230 |
| 1231 std::vector<std::wstring> result; |
| 1232 for (std::vector<std::wstring>::iterator iter = suggestions->begin(); |
| 1233 iter != suggestions->end(); ++iter) { |
| 1234 if (StartsWith(*iter, user_text, false)) |
| 1235 result.push_back(*iter); |
| 1236 } |
| 1237 Send(new ViewMsg_AutofillSuggestions(routing_id_, |
| 1238 node_id, request_id, result, 0)); |
| 1239 #else |
| 1240 Send(new ViewMsg_AutofillSuggestions(routing_id_, |
| 1241 node_id, request_id, |
| 1242 std::vector<std::wstring>(), 0)); |
| 1243 #endif |
| 1244 } |
| 1245 |
1206 void RenderViewHost::NotifyRendererUnresponsive() { | 1246 void RenderViewHost::NotifyRendererUnresponsive() { |
1207 if (is_waiting_for_unload_ack_ && | 1247 if (is_waiting_for_unload_ack_ && |
1208 !Singleton<CrossSiteRequestManager>()->HasPendingCrossSiteRequest( | 1248 !Singleton<CrossSiteRequestManager>()->HasPendingCrossSiteRequest( |
1209 process()->host_id(), routing_id_)) { | 1249 process()->host_id(), routing_id_)) { |
1210 // If the tab hangs in the beforeunload/unload handler there's really | 1250 // If the tab hangs in the beforeunload/unload handler there's really |
1211 // nothing we can do to recover. Pretend the unload listeners have | 1251 // nothing we can do to recover. Pretend the unload listeners have |
1212 // all fired and close the tab. If the hang is in the beforeunload handler | 1252 // all fired and close the tab. If the hang is in the beforeunload handler |
1213 // then the user will not have the option of cancelling the close. | 1253 // then the user will not have the option of cancelling the close. |
1214 UnloadListenerHasFired(); | 1254 UnloadListenerHasFired(); |
1215 delegate_->Close(this); | 1255 delegate_->Close(this); |
(...skipping 23 matching lines...) Expand all Loading... |
1239 Send(new ViewMsg_PersonalizationEvent(routing_id_, | 1279 Send(new ViewMsg_PersonalizationEvent(routing_id_, |
1240 event_name, | 1280 event_name, |
1241 event_arg)); | 1281 event_arg)); |
1242 } | 1282 } |
1243 #endif | 1283 #endif |
1244 | 1284 |
1245 void RenderViewHost::ForwardMessageFromExternalHost( | 1285 void RenderViewHost::ForwardMessageFromExternalHost( |
1246 const std::string& target, const std::string& message) { | 1286 const std::string& target, const std::string& message) { |
1247 Send(new ViewMsg_HandleMessageFromExternalHost(routing_id_, target, message)); | 1287 Send(new ViewMsg_HandleMessageFromExternalHost(routing_id_, target, message)); |
1248 } | 1288 } |
OLD | NEW |