| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/web_contents/web_contents_impl.h" | 5 #include "content/browser/web_contents/web_contents_impl.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
| (...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 488 // Message handlers should be aware of which | 488 // Message handlers should be aware of which |
| 489 // RenderViewHost/RenderFrameHost sent the message, which is temporarily | 489 // RenderViewHost/RenderFrameHost sent the message, which is temporarily |
| 490 // stored in render_(view|frame)_message_source_. | 490 // stored in render_(view|frame)_message_source_. |
| 491 if (render_frame_host) | 491 if (render_frame_host) |
| 492 render_frame_message_source_ = render_frame_host; | 492 render_frame_message_source_ = render_frame_host; |
| 493 else | 493 else |
| 494 render_view_message_source_ = render_view_host; | 494 render_view_message_source_ = render_view_host; |
| 495 | 495 |
| 496 bool handled = true; | 496 bool handled = true; |
| 497 IPC_BEGIN_MESSAGE_MAP(WebContentsImpl, message) | 497 IPC_BEGIN_MESSAGE_MAP(WebContentsImpl, message) |
| 498 IPC_MESSAGE_HANDLER(FrameHostMsg_PepperPluginHung, OnPepperPluginHung) | |
| 499 IPC_MESSAGE_HANDLER(FrameHostMsg_PluginCrashed, OnPluginCrashed) | |
| 500 IPC_MESSAGE_HANDLER(FrameHostMsg_DomOperationResponse, | 498 IPC_MESSAGE_HANDLER(FrameHostMsg_DomOperationResponse, |
| 501 OnDomOperationResponse) | 499 OnDomOperationResponse) |
| 502 IPC_MESSAGE_HANDLER(FrameHostMsg_DidChangeThemeColor, | 500 IPC_MESSAGE_HANDLER(FrameHostMsg_DidChangeThemeColor, |
| 503 OnThemeColorChanged) | 501 OnThemeColorChanged) |
| 504 IPC_MESSAGE_HANDLER(FrameHostMsg_DidFinishDocumentLoad, | 502 IPC_MESSAGE_HANDLER(FrameHostMsg_DidFinishDocumentLoad, |
| 505 OnDocumentLoadedInFrame) | 503 OnDocumentLoadedInFrame) |
| 506 IPC_MESSAGE_HANDLER(FrameHostMsg_DidFinishLoad, OnDidFinishLoad) | 504 IPC_MESSAGE_HANDLER(FrameHostMsg_DidFinishLoad, OnDidFinishLoad) |
| 507 IPC_MESSAGE_HANDLER(FrameHostMsg_DidStartLoading, OnDidStartLoading) | 505 IPC_MESSAGE_HANDLER(FrameHostMsg_DidStartLoading, OnDidStartLoading) |
| 508 IPC_MESSAGE_HANDLER(FrameHostMsg_DidStopLoading, OnDidStopLoading) | 506 IPC_MESSAGE_HANDLER(FrameHostMsg_DidStopLoading, OnDidStopLoading) |
| 509 IPC_MESSAGE_HANDLER(FrameHostMsg_DidChangeLoadProgress, | 507 IPC_MESSAGE_HANDLER(FrameHostMsg_DidChangeLoadProgress, |
| (...skipping 18 matching lines...) Expand all Loading... |
| 528 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateZoomLimits, OnUpdateZoomLimits) | 526 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateZoomLimits, OnUpdateZoomLimits) |
| 529 IPC_MESSAGE_HANDLER(ViewHostMsg_EnumerateDirectory, OnEnumerateDirectory) | 527 IPC_MESSAGE_HANDLER(ViewHostMsg_EnumerateDirectory, OnEnumerateDirectory) |
| 530 IPC_MESSAGE_HANDLER(ViewHostMsg_RegisterProtocolHandler, | 528 IPC_MESSAGE_HANDLER(ViewHostMsg_RegisterProtocolHandler, |
| 531 OnRegisterProtocolHandler) | 529 OnRegisterProtocolHandler) |
| 532 IPC_MESSAGE_HANDLER(ViewHostMsg_UnregisterProtocolHandler, | 530 IPC_MESSAGE_HANDLER(ViewHostMsg_UnregisterProtocolHandler, |
| 533 OnUnregisterProtocolHandler) | 531 OnUnregisterProtocolHandler) |
| 534 IPC_MESSAGE_HANDLER(ViewHostMsg_Find_Reply, OnFindReply) | 532 IPC_MESSAGE_HANDLER(ViewHostMsg_Find_Reply, OnFindReply) |
| 535 IPC_MESSAGE_HANDLER(ViewHostMsg_AppCacheAccessed, OnAppCacheAccessed) | 533 IPC_MESSAGE_HANDLER(ViewHostMsg_AppCacheAccessed, OnAppCacheAccessed) |
| 536 IPC_MESSAGE_HANDLER(ViewHostMsg_WebUISend, OnWebUISend) | 534 IPC_MESSAGE_HANDLER(ViewHostMsg_WebUISend, OnWebUISend) |
| 537 #if defined(ENABLE_PLUGINS) | 535 #if defined(ENABLE_PLUGINS) |
| 536 IPC_MESSAGE_HANDLER(FrameHostMsg_PepperPluginHung, OnPepperPluginHung) |
| 537 IPC_MESSAGE_HANDLER(FrameHostMsg_PluginCrashed, OnPluginCrashed) |
| 538 IPC_MESSAGE_HANDLER(ViewHostMsg_RequestPpapiBrokerPermission, | 538 IPC_MESSAGE_HANDLER(ViewHostMsg_RequestPpapiBrokerPermission, |
| 539 OnRequestPpapiBrokerPermission) | 539 OnRequestPpapiBrokerPermission) |
| 540 IPC_MESSAGE_HANDLER_GENERIC(BrowserPluginHostMsg_Attach, | 540 IPC_MESSAGE_HANDLER_GENERIC(BrowserPluginHostMsg_Attach, |
| 541 OnBrowserPluginMessage(message)) | 541 OnBrowserPluginMessage(message)) |
| 542 #endif | 542 #endif |
| 543 IPC_MESSAGE_HANDLER(ImageHostMsg_DidDownloadImage, OnDidDownloadImage) | 543 IPC_MESSAGE_HANDLER(ImageHostMsg_DidDownloadImage, OnDidDownloadImage) |
| 544 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateFaviconURL, OnUpdateFaviconURL) | 544 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateFaviconURL, OnUpdateFaviconURL) |
| 545 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowValidationMessage, | 545 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowValidationMessage, |
| 546 OnShowValidationMessage) | 546 OnShowValidationMessage) |
| 547 IPC_MESSAGE_HANDLER(ViewHostMsg_HideValidationMessage, | 547 IPC_MESSAGE_HANDLER(ViewHostMsg_HideValidationMessage, |
| (...skipping 2332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2880 const ViewHostMsg_DateTimeDialogValue_Params& value) { | 2880 const ViewHostMsg_DateTimeDialogValue_Params& value) { |
| 2881 date_time_chooser_->ShowDialog(ContentViewCore::FromWebContents(this), | 2881 date_time_chooser_->ShowDialog(ContentViewCore::FromWebContents(this), |
| 2882 GetRenderViewHost(), | 2882 GetRenderViewHost(), |
| 2883 value.dialog_type, | 2883 value.dialog_type, |
| 2884 value.dialog_value, | 2884 value.dialog_value, |
| 2885 value.minimum, | 2885 value.minimum, |
| 2886 value.maximum, | 2886 value.maximum, |
| 2887 value.step, | 2887 value.step, |
| 2888 value.suggestions); | 2888 value.suggestions); |
| 2889 } | 2889 } |
| 2890 | |
| 2891 #endif | 2890 #endif |
| 2892 | 2891 |
| 2893 void WebContentsImpl::OnPepperPluginHung(int plugin_child_id, | |
| 2894 const base::FilePath& path, | |
| 2895 bool is_hung) { | |
| 2896 UMA_HISTOGRAM_COUNTS("Pepper.PluginHung", 1); | |
| 2897 | |
| 2898 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | |
| 2899 PluginHungStatusChanged(plugin_child_id, path, is_hung)); | |
| 2900 } | |
| 2901 | |
| 2902 void WebContentsImpl::OnPluginCrashed(const base::FilePath& plugin_path, | |
| 2903 base::ProcessId plugin_pid) { | |
| 2904 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | |
| 2905 PluginCrashed(plugin_path, plugin_pid)); | |
| 2906 } | |
| 2907 | |
| 2908 void WebContentsImpl::OnDomOperationResponse(const std::string& json_string, | 2892 void WebContentsImpl::OnDomOperationResponse(const std::string& json_string, |
| 2909 int automation_id) { | 2893 int automation_id) { |
| 2910 DomOperationNotificationDetails details(json_string, automation_id); | 2894 DomOperationNotificationDetails details(json_string, automation_id); |
| 2911 NotificationService::current()->Notify( | 2895 NotificationService::current()->Notify( |
| 2912 NOTIFICATION_DOM_OPERATION_RESPONSE, | 2896 NOTIFICATION_DOM_OPERATION_RESPONSE, |
| 2913 Source<WebContents>(this), | 2897 Source<WebContents>(this), |
| 2914 Details<DomOperationNotificationDetails>(&details)); | 2898 Details<DomOperationNotificationDetails>(&details)); |
| 2915 } | 2899 } |
| 2916 | 2900 |
| 2917 void WebContentsImpl::OnAppCacheAccessed(const GURL& manifest_url, | 2901 void WebContentsImpl::OnAppCacheAccessed(const GURL& manifest_url, |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2956 // This exists for render views that don't have a WebUI, but do have WebUI | 2940 // This exists for render views that don't have a WebUI, but do have WebUI |
| 2957 // bindings enabled. | 2941 // bindings enabled. |
| 2958 void WebContentsImpl::OnWebUISend(const GURL& source_url, | 2942 void WebContentsImpl::OnWebUISend(const GURL& source_url, |
| 2959 const std::string& name, | 2943 const std::string& name, |
| 2960 const base::ListValue& args) { | 2944 const base::ListValue& args) { |
| 2961 if (delegate_) | 2945 if (delegate_) |
| 2962 delegate_->WebUISend(this, source_url, name, args); | 2946 delegate_->WebUISend(this, source_url, name, args); |
| 2963 } | 2947 } |
| 2964 | 2948 |
| 2965 #if defined(ENABLE_PLUGINS) | 2949 #if defined(ENABLE_PLUGINS) |
| 2950 void WebContentsImpl::OnPepperPluginHung(int plugin_child_id, |
| 2951 const base::FilePath& path, |
| 2952 bool is_hung) { |
| 2953 UMA_HISTOGRAM_COUNTS("Pepper.PluginHung", 1); |
| 2954 |
| 2955 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
| 2956 PluginHungStatusChanged(plugin_child_id, path, is_hung)); |
| 2957 } |
| 2958 |
| 2959 void WebContentsImpl::OnPluginCrashed(const base::FilePath& plugin_path, |
| 2960 base::ProcessId plugin_pid) { |
| 2961 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
| 2962 PluginCrashed(plugin_path, plugin_pid)); |
| 2963 } |
| 2964 |
| 2966 void WebContentsImpl::OnRequestPpapiBrokerPermission( | 2965 void WebContentsImpl::OnRequestPpapiBrokerPermission( |
| 2967 int routing_id, | 2966 int routing_id, |
| 2968 const GURL& url, | 2967 const GURL& url, |
| 2969 const base::FilePath& plugin_path) { | 2968 const base::FilePath& plugin_path) { |
| 2970 if (!delegate_) { | 2969 if (!delegate_) { |
| 2971 OnPpapiBrokerPermissionResult(routing_id, false); | 2970 OnPpapiBrokerPermissionResult(routing_id, false); |
| 2972 return; | 2971 return; |
| 2973 } | 2972 } |
| 2974 | 2973 |
| 2975 if (!delegate_->RequestPpapiBrokerPermission( | 2974 if (!delegate_->RequestPpapiBrokerPermission( |
| (...skipping 13 matching lines...) Expand all Loading... |
| 2989 void WebContentsImpl::OnBrowserPluginMessage(const IPC::Message& message) { | 2988 void WebContentsImpl::OnBrowserPluginMessage(const IPC::Message& message) { |
| 2990 // This creates a BrowserPluginEmbedder, which handles all the BrowserPlugin | 2989 // This creates a BrowserPluginEmbedder, which handles all the BrowserPlugin |
| 2991 // specific messages for this WebContents. This means that any message from | 2990 // specific messages for this WebContents. This means that any message from |
| 2992 // a BrowserPlugin prior to this will be ignored. | 2991 // a BrowserPlugin prior to this will be ignored. |
| 2993 // For more info, see comment above classes BrowserPluginEmbedder and | 2992 // For more info, see comment above classes BrowserPluginEmbedder and |
| 2994 // BrowserPluginGuest. | 2993 // BrowserPluginGuest. |
| 2995 CHECK(!browser_plugin_embedder_.get()); | 2994 CHECK(!browser_plugin_embedder_.get()); |
| 2996 browser_plugin_embedder_.reset(BrowserPluginEmbedder::Create(this)); | 2995 browser_plugin_embedder_.reset(BrowserPluginEmbedder::Create(this)); |
| 2997 browser_plugin_embedder_->OnMessageReceived(message); | 2996 browser_plugin_embedder_->OnMessageReceived(message); |
| 2998 } | 2997 } |
| 2999 #endif | 2998 #endif // defined(ENABLE_PLUGINS) |
| 3000 | 2999 |
| 3001 void WebContentsImpl::OnDidDownloadImage( | 3000 void WebContentsImpl::OnDidDownloadImage( |
| 3002 int id, | 3001 int id, |
| 3003 int http_status_code, | 3002 int http_status_code, |
| 3004 const GURL& image_url, | 3003 const GURL& image_url, |
| 3005 const std::vector<SkBitmap>& bitmaps, | 3004 const std::vector<SkBitmap>& bitmaps, |
| 3006 const std::vector<gfx::Size>& original_bitmap_sizes) { | 3005 const std::vector<gfx::Size>& original_bitmap_sizes) { |
| 3007 if (bitmaps.size() != original_bitmap_sizes.size()) | 3006 if (bitmaps.size() != original_bitmap_sizes.size()) |
| 3008 return; | 3007 return; |
| 3009 | 3008 |
| (...skipping 1321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4331 node->render_manager()->ResumeResponseDeferredAtStart(); | 4330 node->render_manager()->ResumeResponseDeferredAtStart(); |
| 4332 } | 4331 } |
| 4333 | 4332 |
| 4334 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) { | 4333 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) { |
| 4335 force_disable_overscroll_content_ = force_disable; | 4334 force_disable_overscroll_content_ = force_disable; |
| 4336 if (view_) | 4335 if (view_) |
| 4337 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); | 4336 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); |
| 4338 } | 4337 } |
| 4339 | 4338 |
| 4340 } // namespace content | 4339 } // namespace content |
| OLD | NEW |