| 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 29 matching lines...) Expand all Loading... |
| 40 #include "chrome/common/chrome_constants.h" | 40 #include "chrome/common/chrome_constants.h" |
| 41 #include "chrome/common/chrome_switches.h" | 41 #include "chrome/common/chrome_switches.h" |
| 42 #include "chrome/common/native_web_keyboard_event.h" | 42 #include "chrome/common/native_web_keyboard_event.h" |
| 43 #include "chrome/common/net/url_request_context_getter.h" | 43 #include "chrome/common/net/url_request_context_getter.h" |
| 44 #include "chrome/common/notification_details.h" | 44 #include "chrome/common/notification_details.h" |
| 45 #include "chrome/common/notification_service.h" | 45 #include "chrome/common/notification_service.h" |
| 46 #include "chrome/common/notification_type.h" | 46 #include "chrome/common/notification_type.h" |
| 47 #include "chrome/common/render_messages.h" | 47 #include "chrome/common/render_messages.h" |
| 48 #include "chrome/common/render_messages_params.h" | 48 #include "chrome/common/render_messages_params.h" |
| 49 #include "chrome/common/result_codes.h" | 49 #include "chrome/common/result_codes.h" |
| 50 #include "chrome/common/thumbnail_score.h" | |
| 51 #include "chrome/common/translate_errors.h" | 50 #include "chrome/common/translate_errors.h" |
| 52 #include "chrome/common/url_constants.h" | 51 #include "chrome/common/url_constants.h" |
| 53 #include "chrome/common/web_apps.h" | 52 #include "chrome/common/web_apps.h" |
| 54 #include "gfx/native_widget_types.h" | 53 #include "gfx/native_widget_types.h" |
| 55 #include "net/base/net_util.h" | 54 #include "net/base/net_util.h" |
| 56 #include "printing/native_metafile.h" | 55 #include "printing/native_metafile.h" |
| 57 #include "third_party/skia/include/core/SkBitmap.h" | 56 #include "third_party/skia/include/core/SkBitmap.h" |
| 58 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFindOptions.h" | 57 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFindOptions.h" |
| 59 #include "webkit/glue/context_menu.h" | 58 #include "webkit/glue/context_menu.h" |
| 60 #include "webkit/glue/form_data.h" | 59 #include "webkit/glue/form_data.h" |
| (...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 567 static int next_id = 1; | 566 static int next_id = 1; |
| 568 int id = next_id++; | 567 int id = next_id++; |
| 569 Send(new ViewMsg_DownloadFavIcon(routing_id(), id, url, image_size)); | 568 Send(new ViewMsg_DownloadFavIcon(routing_id(), id, url, image_size)); |
| 570 return id; | 569 return id; |
| 571 } | 570 } |
| 572 | 571 |
| 573 void RenderViewHost::GetApplicationInfo(int32 page_id) { | 572 void RenderViewHost::GetApplicationInfo(int32 page_id) { |
| 574 Send(new ViewMsg_GetApplicationInfo(routing_id(), page_id)); | 573 Send(new ViewMsg_GetApplicationInfo(routing_id(), page_id)); |
| 575 } | 574 } |
| 576 | 575 |
| 577 void RenderViewHost::CaptureThumbnail() { | |
| 578 Send(new ViewMsg_CaptureThumbnail(routing_id())); | |
| 579 } | |
| 580 | |
| 581 void RenderViewHost::CaptureSnapshot() { | 576 void RenderViewHost::CaptureSnapshot() { |
| 582 Send(new ViewMsg_CaptureSnapshot(routing_id())); | 577 Send(new ViewMsg_CaptureSnapshot(routing_id())); |
| 583 } | 578 } |
| 584 | 579 |
| 585 void RenderViewHost::JavaScriptMessageBoxClosed(IPC::Message* reply_msg, | 580 void RenderViewHost::JavaScriptMessageBoxClosed(IPC::Message* reply_msg, |
| 586 bool success, | 581 bool success, |
| 587 const std::wstring& prompt) { | 582 const std::wstring& prompt) { |
| 588 process()->set_ignore_input_events(false); | 583 process()->set_ignore_input_events(false); |
| 589 bool is_waiting = | 584 bool is_waiting = |
| 590 is_waiting_for_beforeunload_ack_ || is_waiting_for_unload_ack_; | 585 is_waiting_for_beforeunload_ack_ || is_waiting_for_unload_ack_; |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 750 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowFullscreenWidget, | 745 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowFullscreenWidget, |
| 751 OnMsgShowFullscreenWidget) | 746 OnMsgShowFullscreenWidget) |
| 752 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_RunModal, OnMsgRunModal) | 747 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_RunModal, OnMsgRunModal) |
| 753 IPC_MESSAGE_HANDLER(ViewHostMsg_RenderViewReady, OnMsgRenderViewReady) | 748 IPC_MESSAGE_HANDLER(ViewHostMsg_RenderViewReady, OnMsgRenderViewReady) |
| 754 IPC_MESSAGE_HANDLER(ViewHostMsg_RenderViewGone, OnMsgRenderViewGone) | 749 IPC_MESSAGE_HANDLER(ViewHostMsg_RenderViewGone, OnMsgRenderViewGone) |
| 755 IPC_MESSAGE_HANDLER_GENERIC(ViewHostMsg_FrameNavigate, OnMsgNavigate(msg)) | 750 IPC_MESSAGE_HANDLER_GENERIC(ViewHostMsg_FrameNavigate, OnMsgNavigate(msg)) |
| 756 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateState, OnMsgUpdateState) | 751 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateState, OnMsgUpdateState) |
| 757 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateTitle, OnMsgUpdateTitle) | 752 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateTitle, OnMsgUpdateTitle) |
| 758 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateEncoding, OnMsgUpdateEncoding) | 753 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateEncoding, OnMsgUpdateEncoding) |
| 759 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateTargetURL, OnMsgUpdateTargetURL) | 754 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateTargetURL, OnMsgUpdateTargetURL) |
| 760 IPC_MESSAGE_HANDLER(ViewHostMsg_Thumbnail, OnMsgThumbnail) | |
| 761 IPC_MESSAGE_HANDLER(ViewHostMsg_Snapshot, OnMsgScreenshot) | 755 IPC_MESSAGE_HANDLER(ViewHostMsg_Snapshot, OnMsgScreenshot) |
| 762 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateInspectorSetting, | 756 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateInspectorSetting, |
| 763 OnUpdateInspectorSetting) | 757 OnUpdateInspectorSetting) |
| 764 IPC_MESSAGE_HANDLER(ViewHostMsg_Close, OnMsgClose) | 758 IPC_MESSAGE_HANDLER(ViewHostMsg_Close, OnMsgClose) |
| 765 IPC_MESSAGE_HANDLER(ViewHostMsg_RequestMove, OnMsgRequestMove) | 759 IPC_MESSAGE_HANDLER(ViewHostMsg_RequestMove, OnMsgRequestMove) |
| 766 IPC_MESSAGE_HANDLER(ViewHostMsg_DidStartLoading, OnMsgDidStartLoading) | 760 IPC_MESSAGE_HANDLER(ViewHostMsg_DidStartLoading, OnMsgDidStartLoading) |
| 767 IPC_MESSAGE_HANDLER(ViewHostMsg_DidStopLoading, OnMsgDidStopLoading) | 761 IPC_MESSAGE_HANDLER(ViewHostMsg_DidStopLoading, OnMsgDidStopLoading) |
| 768 IPC_MESSAGE_HANDLER(ViewHostMsg_DidChangeLoadProgress, | 762 IPC_MESSAGE_HANDLER(ViewHostMsg_DidChangeLoadProgress, |
| 769 OnMsgDidChangeLoadProgress) | 763 OnMsgDidChangeLoadProgress) |
| 770 IPC_MESSAGE_HANDLER(ViewHostMsg_DocumentAvailableInMainFrame, | 764 IPC_MESSAGE_HANDLER(ViewHostMsg_DocumentAvailableInMainFrame, |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 860 IPC_MESSAGE_HANDLER(ViewHostMsg_DetectedPhishingSite, | 854 IPC_MESSAGE_HANDLER(ViewHostMsg_DetectedPhishingSite, |
| 861 OnDetectedPhishingSite) | 855 OnDetectedPhishingSite) |
| 862 IPC_MESSAGE_HANDLER(ViewHostMsg_ScriptEvalResponse, OnScriptEvalResponse) | 856 IPC_MESSAGE_HANDLER(ViewHostMsg_ScriptEvalResponse, OnScriptEvalResponse) |
| 863 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateContentRestrictions, | 857 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateContentRestrictions, |
| 864 OnUpdateContentRestrictions) | 858 OnUpdateContentRestrictions) |
| 865 #if defined(OS_MACOSX) | 859 #if defined(OS_MACOSX) |
| 866 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowPopup, OnMsgShowPopup) | 860 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowPopup, OnMsgShowPopup) |
| 867 #endif | 861 #endif |
| 868 IPC_MESSAGE_HANDLER(ViewHostMsg_PagesReadyForPreview, | 862 IPC_MESSAGE_HANDLER(ViewHostMsg_PagesReadyForPreview, |
| 869 OnPagesReadyForPreview) | 863 OnPagesReadyForPreview) |
| 864 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateScrollOffset, OnUpdateScrollOffset) |
| 870 // Have the super handle all other messages. | 865 // Have the super handle all other messages. |
| 871 IPC_MESSAGE_UNHANDLED(handled = RenderWidgetHost::OnMessageReceived(msg)) | 866 IPC_MESSAGE_UNHANDLED(handled = RenderWidgetHost::OnMessageReceived(msg)) |
| 872 IPC_END_MESSAGE_MAP_EX() | 867 IPC_END_MESSAGE_MAP_EX() |
| 873 | 868 |
| 874 if (!msg_is_ok) { | 869 if (!msg_is_ok) { |
| 875 // The message had a handler, but its de-serialization failed. | 870 // The message had a handler, but its de-serialization failed. |
| 876 // Kill the renderer. | 871 // Kill the renderer. |
| 877 UserMetrics::RecordAction(UserMetricsAction("BadMessageTerminate_RVH")); | 872 UserMetrics::RecordAction(UserMetricsAction("BadMessageTerminate_RVH")); |
| 878 process()->ReceivedBadMessage(); | 873 process()->ReceivedBadMessage(); |
| 879 } | 874 } |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1069 | 1064 |
| 1070 void RenderViewHost::OnMsgUpdateTargetURL(int32 page_id, | 1065 void RenderViewHost::OnMsgUpdateTargetURL(int32 page_id, |
| 1071 const GURL& url) { | 1066 const GURL& url) { |
| 1072 delegate_->UpdateTargetURL(page_id, url); | 1067 delegate_->UpdateTargetURL(page_id, url); |
| 1073 | 1068 |
| 1074 // Send a notification back to the renderer that we are ready to | 1069 // Send a notification back to the renderer that we are ready to |
| 1075 // receive more target urls. | 1070 // receive more target urls. |
| 1076 Send(new ViewMsg_UpdateTargetURL_ACK(routing_id())); | 1071 Send(new ViewMsg_UpdateTargetURL_ACK(routing_id())); |
| 1077 } | 1072 } |
| 1078 | 1073 |
| 1079 void RenderViewHost::OnMsgThumbnail(const GURL& url, | |
| 1080 const ThumbnailScore& score, | |
| 1081 const SkBitmap& bitmap) { | |
| 1082 delegate_->UpdateThumbnail(url, bitmap, score); | |
| 1083 } | |
| 1084 | |
| 1085 void RenderViewHost::OnMsgScreenshot(const SkBitmap& bitmap) { | 1074 void RenderViewHost::OnMsgScreenshot(const SkBitmap& bitmap) { |
| 1086 NotificationService::current()->Notify( | 1075 NotificationService::current()->Notify( |
| 1087 NotificationType::TAB_SNAPSHOT_TAKEN, | 1076 NotificationType::TAB_SNAPSHOT_TAKEN, |
| 1088 Source<RenderViewHost>(this), | 1077 Source<RenderViewHost>(this), |
| 1089 Details<const SkBitmap>(&bitmap)); | 1078 Details<const SkBitmap>(&bitmap)); |
| 1090 } | 1079 } |
| 1091 | 1080 |
| 1092 void RenderViewHost::OnUpdateInspectorSetting( | 1081 void RenderViewHost::OnUpdateInspectorSetting( |
| 1093 const std::string& key, const std::string& value) { | 1082 const std::string& key, const std::string& value) { |
| 1094 delegate_->UpdateInspectorSetting(key, value); | 1083 delegate_->UpdateInspectorSetting(key, value); |
| (...skipping 925 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2020 if (printer_query.get()) { | 2009 if (printer_query.get()) { |
| 2021 BrowserThread::PostTask( | 2010 BrowserThread::PostTask( |
| 2022 BrowserThread::IO, FROM_HERE, | 2011 BrowserThread::IO, FROM_HERE, |
| 2023 NewRunnableMethod(printer_query.get(), | 2012 NewRunnableMethod(printer_query.get(), |
| 2024 &printing::PrinterQuery::StopWorker)); | 2013 &printing::PrinterQuery::StopWorker)); |
| 2025 } | 2014 } |
| 2026 | 2015 |
| 2027 // Send the printingDone msg for now. | 2016 // Send the printingDone msg for now. |
| 2028 Send(new ViewMsg_PrintingDone(routing_id(), params.document_cookie, true)); | 2017 Send(new ViewMsg_PrintingDone(routing_id(), params.document_cookie, true)); |
| 2029 } | 2018 } |
| 2019 |
| 2020 void RenderViewHost::OnUpdateScrollOffset(const gfx::Size& scroll_offset) { |
| 2021 last_scroll_offset_ = scroll_offset; |
| 2022 } |
| OLD | NEW |