| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <cmath> | 9 #include <cmath> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 #include "content/browser/accessibility/browser_accessibility_state_impl.h" | 32 #include "content/browser/accessibility/browser_accessibility_state_impl.h" |
| 33 #include "content/browser/bad_message.h" | 33 #include "content/browser/bad_message.h" |
| 34 #include "content/browser/browser_plugin/browser_plugin_embedder.h" | 34 #include "content/browser/browser_plugin/browser_plugin_embedder.h" |
| 35 #include "content/browser/browser_plugin/browser_plugin_guest.h" | 35 #include "content/browser/browser_plugin/browser_plugin_guest.h" |
| 36 #include "content/browser/child_process_security_policy_impl.h" | 36 #include "content/browser/child_process_security_policy_impl.h" |
| 37 #include "content/browser/dom_storage/dom_storage_context_wrapper.h" | 37 #include "content/browser/dom_storage/dom_storage_context_wrapper.h" |
| 38 #include "content/browser/dom_storage/session_storage_namespace_impl.h" | 38 #include "content/browser/dom_storage/session_storage_namespace_impl.h" |
| 39 #include "content/browser/download/download_stats.h" | 39 #include "content/browser/download/download_stats.h" |
| 40 #include "content/browser/download/mhtml_generation_manager.h" | 40 #include "content/browser/download/mhtml_generation_manager.h" |
| 41 #include "content/browser/download/save_package.h" | 41 #include "content/browser/download/save_package.h" |
| 42 #include "content/browser/find_request_manager.h" |
| 42 #include "content/browser/frame_host/cross_process_frame_connector.h" | 43 #include "content/browser/frame_host/cross_process_frame_connector.h" |
| 43 #include "content/browser/frame_host/interstitial_page_impl.h" | 44 #include "content/browser/frame_host/interstitial_page_impl.h" |
| 44 #include "content/browser/frame_host/navigation_entry_impl.h" | 45 #include "content/browser/frame_host/navigation_entry_impl.h" |
| 45 #include "content/browser/frame_host/navigation_handle_impl.h" | 46 #include "content/browser/frame_host/navigation_handle_impl.h" |
| 46 #include "content/browser/frame_host/navigator_impl.h" | 47 #include "content/browser/frame_host/navigator_impl.h" |
| 47 #include "content/browser/frame_host/render_frame_host_impl.h" | 48 #include "content/browser/frame_host/render_frame_host_impl.h" |
| 48 #include "content/browser/frame_host/render_frame_proxy_host.h" | 49 #include "content/browser/frame_host/render_frame_proxy_host.h" |
| 49 #include "content/browser/frame_host/render_widget_host_view_child_frame.h" | 50 #include "content/browser/frame_host/render_widget_host_view_child_frame.h" |
| 50 #include "content/browser/geolocation/geolocation_service_context.h" | 51 #include "content/browser/geolocation/geolocation_service_context.h" |
| 51 #include "content/browser/host_zoom_map_impl.h" | 52 #include "content/browser/host_zoom_map_impl.h" |
| (...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 595 OnDomOperationResponse) | 596 OnDomOperationResponse) |
| 596 IPC_MESSAGE_HANDLER(FrameHostMsg_DidChangeThemeColor, | 597 IPC_MESSAGE_HANDLER(FrameHostMsg_DidChangeThemeColor, |
| 597 OnThemeColorChanged) | 598 OnThemeColorChanged) |
| 598 IPC_MESSAGE_HANDLER(FrameHostMsg_DidFinishDocumentLoad, | 599 IPC_MESSAGE_HANDLER(FrameHostMsg_DidFinishDocumentLoad, |
| 599 OnDocumentLoadedInFrame) | 600 OnDocumentLoadedInFrame) |
| 600 IPC_MESSAGE_HANDLER(FrameHostMsg_DidFinishLoad, OnDidFinishLoad) | 601 IPC_MESSAGE_HANDLER(FrameHostMsg_DidFinishLoad, OnDidFinishLoad) |
| 601 IPC_MESSAGE_HANDLER(FrameHostMsg_OpenColorChooser, OnOpenColorChooser) | 602 IPC_MESSAGE_HANDLER(FrameHostMsg_OpenColorChooser, OnOpenColorChooser) |
| 602 IPC_MESSAGE_HANDLER(FrameHostMsg_EndColorChooser, OnEndColorChooser) | 603 IPC_MESSAGE_HANDLER(FrameHostMsg_EndColorChooser, OnEndColorChooser) |
| 603 IPC_MESSAGE_HANDLER(FrameHostMsg_SetSelectedColorInColorChooser, | 604 IPC_MESSAGE_HANDLER(FrameHostMsg_SetSelectedColorInColorChooser, |
| 604 OnSetSelectedColorInColorChooser) | 605 OnSetSelectedColorInColorChooser) |
| 605 | |
| 606 IPC_MESSAGE_HANDLER(ViewHostMsg_DidFirstVisuallyNonEmptyPaint, | 606 IPC_MESSAGE_HANDLER(ViewHostMsg_DidFirstVisuallyNonEmptyPaint, |
| 607 OnFirstVisuallyNonEmptyPaint) | 607 OnFirstVisuallyNonEmptyPaint) |
| 608 IPC_MESSAGE_HANDLER(FrameHostMsg_DidLoadResourceFromMemoryCache, | 608 IPC_MESSAGE_HANDLER(FrameHostMsg_DidLoadResourceFromMemoryCache, |
| 609 OnDidLoadResourceFromMemoryCache) | 609 OnDidLoadResourceFromMemoryCache) |
| 610 IPC_MESSAGE_HANDLER(FrameHostMsg_DidDisplayInsecureContent, | 610 IPC_MESSAGE_HANDLER(FrameHostMsg_DidDisplayInsecureContent, |
| 611 OnDidDisplayInsecureContent) | 611 OnDidDisplayInsecureContent) |
| 612 IPC_MESSAGE_HANDLER(FrameHostMsg_DidRunInsecureContent, | 612 IPC_MESSAGE_HANDLER(FrameHostMsg_DidRunInsecureContent, |
| 613 OnDidRunInsecureContent) | 613 OnDidRunInsecureContent) |
| 614 IPC_MESSAGE_HANDLER(FrameHostMsg_DidDisplayContentWithCertificateErrors, | 614 IPC_MESSAGE_HANDLER(FrameHostMsg_DidDisplayContentWithCertificateErrors, |
| 615 OnDidDisplayContentWithCertificateErrors) | 615 OnDidDisplayContentWithCertificateErrors) |
| (...skipping 2329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2945 void WebContentsImpl::Find(int request_id, | 2945 void WebContentsImpl::Find(int request_id, |
| 2946 const base::string16& search_text, | 2946 const base::string16& search_text, |
| 2947 const blink::WebFindOptions& options) { | 2947 const blink::WebFindOptions& options) { |
| 2948 // Cowardly refuse to search for no text. | 2948 // Cowardly refuse to search for no text. |
| 2949 if (search_text.empty()) { | 2949 if (search_text.empty()) { |
| 2950 NOTREACHED(); | 2950 NOTREACHED(); |
| 2951 return; | 2951 return; |
| 2952 } | 2952 } |
| 2953 | 2953 |
| 2954 // See if a top level browser plugin handles the find request first. | 2954 // See if a top level browser plugin handles the find request first. |
| 2955 // TODO(paulmeyer): Remove this after find-in-page works across GuestViews. |
| 2955 if (browser_plugin_embedder_ && | 2956 if (browser_plugin_embedder_ && |
| 2956 browser_plugin_embedder_->Find(request_id, search_text, options)) { | 2957 browser_plugin_embedder_->Find(request_id, search_text, options)) { |
| 2957 return; | 2958 return; |
| 2958 } | 2959 } |
| 2959 GetMainFrame()->Send(new FrameMsg_Find(GetMainFrame()->GetRoutingID(), | 2960 |
| 2960 request_id, search_text, options)); | 2961 GetOrCreateFindRequestManager()->Find(request_id, search_text, options); |
| 2961 } | 2962 } |
| 2962 | 2963 |
| 2963 void WebContentsImpl::StopFinding(StopFindAction action) { | 2964 void WebContentsImpl::StopFinding(StopFindAction action) { |
| 2964 // See if a top level browser plugin handles the stop finding request first. | 2965 // See if a top level browser plugin handles the stop finding request first. |
| 2966 // TODO(paulmeyer): Remove this after find-in-page works across GuestViews. |
| 2965 if (browser_plugin_embedder_ && | 2967 if (browser_plugin_embedder_ && |
| 2966 browser_plugin_embedder_->StopFinding(action)) { | 2968 browser_plugin_embedder_->StopFinding(action)) { |
| 2967 return; | 2969 return; |
| 2968 } | 2970 } |
| 2969 GetMainFrame()->Send( | 2971 |
| 2970 new FrameMsg_StopFinding(GetMainFrame()->GetRoutingID(), action)); | 2972 GetOrCreateFindRequestManager()->StopFinding(action); |
| 2971 } | 2973 } |
| 2972 | 2974 |
| 2973 void WebContentsImpl::InsertCSS(const std::string& css) { | 2975 void WebContentsImpl::InsertCSS(const std::string& css) { |
| 2974 GetMainFrame()->Send(new FrameMsg_CSSInsertRequest( | 2976 GetMainFrame()->Send(new FrameMsg_CSSInsertRequest( |
| 2975 GetMainFrame()->GetRoutingID(), css)); | 2977 GetMainFrame()->GetRoutingID(), css)); |
| 2976 } | 2978 } |
| 2977 | 2979 |
| 2978 bool WebContentsImpl::WasRecentlyAudible() { | 2980 bool WebContentsImpl::WasRecentlyAudible() { |
| 2979 return audio_stream_monitor_.WasRecentlyAudible(); | 2981 return audio_stream_monitor_.WasRecentlyAudible(); |
| 2980 } | 2982 } |
| (...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3478 void WebContentsImpl::OnUpdatePageImportanceSignals( | 3480 void WebContentsImpl::OnUpdatePageImportanceSignals( |
| 3479 const PageImportanceSignals& signals) { | 3481 const PageImportanceSignals& signals) { |
| 3480 page_importance_signals_ = signals; | 3482 page_importance_signals_ = signals; |
| 3481 } | 3483 } |
| 3482 | 3484 |
| 3483 void WebContentsImpl::OnFindReply(int request_id, | 3485 void WebContentsImpl::OnFindReply(int request_id, |
| 3484 int number_of_matches, | 3486 int number_of_matches, |
| 3485 const gfx::Rect& selection_rect, | 3487 const gfx::Rect& selection_rect, |
| 3486 int active_match_ordinal, | 3488 int active_match_ordinal, |
| 3487 bool final_update) { | 3489 bool final_update) { |
| 3488 if (delegate_) { | 3490 // Forward the find reply to the FindRequestManager, along with the |
| 3489 delegate_->FindReply(this, request_id, number_of_matches, selection_rect, | 3491 // RenderFrameHost associated with the frame that the reply came from. |
| 3490 active_match_ordinal, final_update); | 3492 GetOrCreateFindRequestManager()->OnFindReply(render_frame_message_source_, |
| 3491 } | 3493 request_id, |
| 3494 number_of_matches, |
| 3495 selection_rect, |
| 3496 active_match_ordinal, |
| 3497 final_update); |
| 3492 } | 3498 } |
| 3493 | 3499 |
| 3494 #if defined(OS_ANDROID) | 3500 #if defined(OS_ANDROID) |
| 3495 void WebContentsImpl::OnFindMatchRectsReply( | 3501 void WebContentsImpl::OnFindMatchRectsReply( |
| 3496 int version, | 3502 int version, |
| 3497 const std::vector<gfx::RectF>& rects, | 3503 const std::vector<gfx::RectF>& rects, |
| 3498 const gfx::RectF& active_rect) { | 3504 const gfx::RectF& active_rect) { |
| 3499 if (delegate_) | 3505 GetOrCreateFindRequestManager()->OnFindMatchRectsReply( |
| 3500 delegate_->FindMatchRectsReply(this, version, rects, active_rect); | 3506 render_frame_message_source_, version, rects, active_rect); |
| 3501 } | 3507 } |
| 3502 | 3508 |
| 3503 void WebContentsImpl::OnOpenDateTimeDialog( | 3509 void WebContentsImpl::OnOpenDateTimeDialog( |
| 3504 const ViewHostMsg_DateTimeDialogValue_Params& value) { | 3510 const ViewHostMsg_DateTimeDialogValue_Params& value) { |
| 3505 date_time_chooser_->ShowDialog(GetTopLevelNativeWindow(), | 3511 date_time_chooser_->ShowDialog(GetTopLevelNativeWindow(), |
| 3506 GetRenderViewHost(), | 3512 GetRenderViewHost(), |
| 3507 value.dialog_type, | 3513 value.dialog_type, |
| 3508 value.dialog_value, | 3514 value.dialog_value, |
| 3509 value.minimum, | 3515 value.minimum, |
| 3510 value.maximum, | 3516 value.maximum, |
| (...skipping 1181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4692 WebContentsAndroid* WebContentsImpl::GetWebContentsAndroid() { | 4698 WebContentsAndroid* WebContentsImpl::GetWebContentsAndroid() { |
| 4693 WebContentsAndroid* web_contents_android = | 4699 WebContentsAndroid* web_contents_android = |
| 4694 static_cast<WebContentsAndroid*>(GetUserData(kWebContentsAndroidKey)); | 4700 static_cast<WebContentsAndroid*>(GetUserData(kWebContentsAndroidKey)); |
| 4695 if (!web_contents_android) { | 4701 if (!web_contents_android) { |
| 4696 web_contents_android = new WebContentsAndroid(this); | 4702 web_contents_android = new WebContentsAndroid(this); |
| 4697 SetUserData(kWebContentsAndroidKey, web_contents_android); | 4703 SetUserData(kWebContentsAndroidKey, web_contents_android); |
| 4698 } | 4704 } |
| 4699 return web_contents_android; | 4705 return web_contents_android; |
| 4700 } | 4706 } |
| 4701 | 4707 |
| 4708 void WebContentsImpl::ActivateNearestFindResult(float x, |
| 4709 float y) { |
| 4710 GetOrCreateFindRequestManager()->ActivateNearestFindResult(x, y); |
| 4711 } |
| 4712 |
| 4713 void WebContentsImpl::RequestFindMatchRects(int current_version) { |
| 4714 GetOrCreateFindRequestManager()->RequestFindMatchRects(current_version); |
| 4715 } |
| 4716 |
| 4702 bool WebContentsImpl::CreateRenderViewForInitialEmptyDocument() { | 4717 bool WebContentsImpl::CreateRenderViewForInitialEmptyDocument() { |
| 4703 return CreateRenderViewForRenderManager( | 4718 return CreateRenderViewForRenderManager( |
| 4704 GetRenderViewHost(), MSG_ROUTING_NONE, MSG_ROUTING_NONE, | 4719 GetRenderViewHost(), MSG_ROUTING_NONE, MSG_ROUTING_NONE, |
| 4705 frame_tree_.root()->current_replication_state()); | 4720 frame_tree_.root()->current_replication_state()); |
| 4706 } | 4721 } |
| 4707 | 4722 |
| 4708 #elif defined(OS_MACOSX) | 4723 #elif defined(OS_MACOSX) |
| 4709 | 4724 |
| 4710 void WebContentsImpl::SetAllowOtherViews(bool allow) { | 4725 void WebContentsImpl::SetAllowOtherViews(bool allow) { |
| 4711 view_->SetAllowOtherViews(allow); | 4726 view_->SetAllowOtherViews(allow); |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4848 if (controller) { | 4863 if (controller) { |
| 4849 web_ui->AddMessageHandler(new GenericHandler()); | 4864 web_ui->AddMessageHandler(new GenericHandler()); |
| 4850 web_ui->SetController(controller); | 4865 web_ui->SetController(controller); |
| 4851 return web_ui; | 4866 return web_ui; |
| 4852 } | 4867 } |
| 4853 | 4868 |
| 4854 delete web_ui; | 4869 delete web_ui; |
| 4855 return NULL; | 4870 return NULL; |
| 4856 } | 4871 } |
| 4857 | 4872 |
| 4873 FindRequestManager* WebContentsImpl::GetOrCreateFindRequestManager() { |
| 4874 // TODO(paulmeyer): This method will need to access (or potentially create) |
| 4875 // the FindRequestManager in the outermost WebContents once find-in-page |
| 4876 // across GuestViews is implemented. |
| 4877 if (!find_request_manager_) |
| 4878 find_request_manager_.reset(new FindRequestManager(this)); |
| 4879 |
| 4880 return find_request_manager_.get(); |
| 4881 } |
| 4882 |
| 4883 void WebContentsImpl::NotifyFindReply(int request_id, |
| 4884 int number_of_matches, |
| 4885 const gfx::Rect& selection_rect, |
| 4886 int active_match_ordinal, |
| 4887 bool final_update) { |
| 4888 if (delegate_) { |
| 4889 delegate_->FindReply(this, request_id, number_of_matches, selection_rect, |
| 4890 active_match_ordinal, final_update); |
| 4891 } |
| 4892 } |
| 4893 |
| 4894 #if defined(OS_ANDROID) |
| 4895 void WebContentsImpl::NotifyFindMatchRectsReply( |
| 4896 int version, |
| 4897 const std::vector<gfx::RectF>& rects, |
| 4898 const gfx::RectF& active_rect) { |
| 4899 if (delegate_) |
| 4900 delegate_->FindMatchRectsReply(this, version, rects, active_rect); |
| 4901 } |
| 4902 #endif |
| 4903 |
| 4858 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) { | 4904 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) { |
| 4859 force_disable_overscroll_content_ = force_disable; | 4905 force_disable_overscroll_content_ = force_disable; |
| 4860 if (view_) | 4906 if (view_) |
| 4861 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); | 4907 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); |
| 4862 } | 4908 } |
| 4863 | 4909 |
| 4864 void WebContentsImpl::MediaStartedPlaying( | 4910 void WebContentsImpl::MediaStartedPlaying( |
| 4865 const WebContentsObserver::MediaPlayerId& id) { | 4911 const WebContentsObserver::MediaPlayerId& id) { |
| 4866 FOR_EACH_OBSERVER(WebContentsObserver, observers_, MediaStartedPlaying(id)); | 4912 FOR_EACH_OBSERVER(WebContentsObserver, observers_, MediaStartedPlaying(id)); |
| 4867 } | 4913 } |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4909 for (RenderViewHost* render_view_host : render_view_host_set) | 4955 for (RenderViewHost* render_view_host : render_view_host_set) |
| 4910 render_view_host->OnWebkitPreferencesChanged(); | 4956 render_view_host->OnWebkitPreferencesChanged(); |
| 4911 } | 4957 } |
| 4912 | 4958 |
| 4913 void WebContentsImpl::SetJavaScriptDialogManagerForTesting( | 4959 void WebContentsImpl::SetJavaScriptDialogManagerForTesting( |
| 4914 JavaScriptDialogManager* dialog_manager) { | 4960 JavaScriptDialogManager* dialog_manager) { |
| 4915 dialog_manager_ = dialog_manager; | 4961 dialog_manager_ = dialog_manager; |
| 4916 } | 4962 } |
| 4917 | 4963 |
| 4918 } // namespace content | 4964 } // namespace content |
| OLD | NEW |