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 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
593 OnDomOperationResponse) | 594 OnDomOperationResponse) |
594 IPC_MESSAGE_HANDLER(FrameHostMsg_DidChangeThemeColor, | 595 IPC_MESSAGE_HANDLER(FrameHostMsg_DidChangeThemeColor, |
595 OnThemeColorChanged) | 596 OnThemeColorChanged) |
596 IPC_MESSAGE_HANDLER(FrameHostMsg_DidFinishDocumentLoad, | 597 IPC_MESSAGE_HANDLER(FrameHostMsg_DidFinishDocumentLoad, |
597 OnDocumentLoadedInFrame) | 598 OnDocumentLoadedInFrame) |
598 IPC_MESSAGE_HANDLER(FrameHostMsg_DidFinishLoad, OnDidFinishLoad) | 599 IPC_MESSAGE_HANDLER(FrameHostMsg_DidFinishLoad, OnDidFinishLoad) |
599 IPC_MESSAGE_HANDLER(FrameHostMsg_OpenColorChooser, OnOpenColorChooser) | 600 IPC_MESSAGE_HANDLER(FrameHostMsg_OpenColorChooser, OnOpenColorChooser) |
600 IPC_MESSAGE_HANDLER(FrameHostMsg_EndColorChooser, OnEndColorChooser) | 601 IPC_MESSAGE_HANDLER(FrameHostMsg_EndColorChooser, OnEndColorChooser) |
601 IPC_MESSAGE_HANDLER(FrameHostMsg_SetSelectedColorInColorChooser, | 602 IPC_MESSAGE_HANDLER(FrameHostMsg_SetSelectedColorInColorChooser, |
602 OnSetSelectedColorInColorChooser) | 603 OnSetSelectedColorInColorChooser) |
603 | |
604 IPC_MESSAGE_HANDLER(ViewHostMsg_DidFirstVisuallyNonEmptyPaint, | 604 IPC_MESSAGE_HANDLER(ViewHostMsg_DidFirstVisuallyNonEmptyPaint, |
605 OnFirstVisuallyNonEmptyPaint) | 605 OnFirstVisuallyNonEmptyPaint) |
606 IPC_MESSAGE_HANDLER(FrameHostMsg_DidLoadResourceFromMemoryCache, | 606 IPC_MESSAGE_HANDLER(FrameHostMsg_DidLoadResourceFromMemoryCache, |
607 OnDidLoadResourceFromMemoryCache) | 607 OnDidLoadResourceFromMemoryCache) |
608 IPC_MESSAGE_HANDLER(FrameHostMsg_DidDisplayInsecureContent, | 608 IPC_MESSAGE_HANDLER(FrameHostMsg_DidDisplayInsecureContent, |
609 OnDidDisplayInsecureContent) | 609 OnDidDisplayInsecureContent) |
610 IPC_MESSAGE_HANDLER(FrameHostMsg_DidRunInsecureContent, | 610 IPC_MESSAGE_HANDLER(FrameHostMsg_DidRunInsecureContent, |
611 OnDidRunInsecureContent) | 611 OnDidRunInsecureContent) |
612 IPC_MESSAGE_HANDLER(FrameHostMsg_DidDisplayContentWithCertificateErrors, | 612 IPC_MESSAGE_HANDLER(FrameHostMsg_DidDisplayContentWithCertificateErrors, |
613 OnDidDisplayContentWithCertificateErrors) | 613 OnDidDisplayContentWithCertificateErrors) |
(...skipping 2279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2893 void WebContentsImpl::Find(int request_id, | 2893 void WebContentsImpl::Find(int request_id, |
2894 const base::string16& search_text, | 2894 const base::string16& search_text, |
2895 const blink::WebFindOptions& options) { | 2895 const blink::WebFindOptions& options) { |
2896 // Cowardly refuse to search for no text. | 2896 // Cowardly refuse to search for no text. |
2897 if (search_text.empty()) { | 2897 if (search_text.empty()) { |
2898 NOTREACHED(); | 2898 NOTREACHED(); |
2899 return; | 2899 return; |
2900 } | 2900 } |
2901 | 2901 |
2902 // See if a top level browser plugin handles the find request first. | 2902 // See if a top level browser plugin handles the find request first. |
2903 // TODO(paulmeyer): Remove this after find-in-page works across GuestViews. | |
2903 if (browser_plugin_embedder_ && | 2904 if (browser_plugin_embedder_ && |
2904 browser_plugin_embedder_->Find(request_id, search_text, options)) { | 2905 browser_plugin_embedder_->Find(request_id, search_text, options)) { |
2905 return; | 2906 return; |
2906 } | 2907 } |
2907 GetMainFrame()->Send(new FrameMsg_Find(GetMainFrame()->GetRoutingID(), | 2908 |
2908 request_id, search_text, options)); | 2909 GetOrCreateFindRequestManager()->Find(request_id, search_text, options); |
2909 } | 2910 } |
2910 | 2911 |
2911 void WebContentsImpl::StopFinding(StopFindAction action) { | 2912 void WebContentsImpl::StopFinding(StopFindAction action) { |
2912 // See if a top level browser plugin handles the stop finding request first. | 2913 // See if a top level browser plugin handles the stop finding request first. |
2914 // TODO(paulmeyer): Remove this after find-in-page works across GuestViews. | |
2913 if (browser_plugin_embedder_ && | 2915 if (browser_plugin_embedder_ && |
2914 browser_plugin_embedder_->StopFinding(action)) { | 2916 browser_plugin_embedder_->StopFinding(action)) { |
2915 return; | 2917 return; |
2916 } | 2918 } |
2917 GetMainFrame()->Send( | 2919 |
2918 new FrameMsg_StopFinding(GetMainFrame()->GetRoutingID(), action)); | 2920 GetOrCreateFindRequestManager()->StopFinding(action); |
2919 } | 2921 } |
2920 | 2922 |
2921 void WebContentsImpl::InsertCSS(const std::string& css) { | 2923 void WebContentsImpl::InsertCSS(const std::string& css) { |
2922 GetMainFrame()->Send(new FrameMsg_CSSInsertRequest( | 2924 GetMainFrame()->Send(new FrameMsg_CSSInsertRequest( |
2923 GetMainFrame()->GetRoutingID(), css)); | 2925 GetMainFrame()->GetRoutingID(), css)); |
2924 } | 2926 } |
2925 | 2927 |
2926 bool WebContentsImpl::WasRecentlyAudible() { | 2928 bool WebContentsImpl::WasRecentlyAudible() { |
2927 return audio_stream_monitor_.WasRecentlyAudible(); | 2929 return audio_stream_monitor_.WasRecentlyAudible(); |
2928 } | 2930 } |
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3426 void WebContentsImpl::OnUpdatePageImportanceSignals( | 3428 void WebContentsImpl::OnUpdatePageImportanceSignals( |
3427 const PageImportanceSignals& signals) { | 3429 const PageImportanceSignals& signals) { |
3428 page_importance_signals_ = signals; | 3430 page_importance_signals_ = signals; |
3429 } | 3431 } |
3430 | 3432 |
3431 void WebContentsImpl::OnFindReply(int request_id, | 3433 void WebContentsImpl::OnFindReply(int request_id, |
3432 int number_of_matches, | 3434 int number_of_matches, |
3433 const gfx::Rect& selection_rect, | 3435 const gfx::Rect& selection_rect, |
3434 int active_match_ordinal, | 3436 int active_match_ordinal, |
3435 bool final_update) { | 3437 bool final_update) { |
3436 if (delegate_) { | 3438 // Forward the find reply to the FindRequestManager, along with the |
3437 delegate_->FindReply(this, request_id, number_of_matches, selection_rect, | 3439 // RenderFrameHost associated with the frame that the reply came from. |
3438 active_match_ordinal, final_update); | 3440 GetOrCreateFindRequestManager()->FindReply(render_frame_message_source_, |
3439 } | 3441 request_id, |
3442 number_of_matches, | |
3443 selection_rect, | |
3444 active_match_ordinal, | |
3445 final_update); | |
3440 } | 3446 } |
3441 | 3447 |
3442 #if defined(OS_ANDROID) | 3448 #if defined(OS_ANDROID) |
3443 void WebContentsImpl::OnFindMatchRectsReply( | 3449 void WebContentsImpl::OnFindMatchRectsReply( |
3444 int version, | 3450 int version, |
3445 const std::vector<gfx::RectF>& rects, | 3451 const std::vector<gfx::RectF>& rects, |
3446 const gfx::RectF& active_rect) { | 3452 const gfx::RectF& active_rect) { |
3447 if (delegate_) | 3453 GetOrCreateFindRequestManager()->FindMatchRectsReply( |
3448 delegate_->FindMatchRectsReply(this, version, rects, active_rect); | 3454 render_frame_message_source_, version, rects, active_rect); |
3449 } | 3455 } |
3450 | 3456 |
3451 void WebContentsImpl::OnOpenDateTimeDialog( | 3457 void WebContentsImpl::OnOpenDateTimeDialog( |
3452 const ViewHostMsg_DateTimeDialogValue_Params& value) { | 3458 const ViewHostMsg_DateTimeDialogValue_Params& value) { |
3453 date_time_chooser_->ShowDialog(GetTopLevelNativeWindow(), | 3459 date_time_chooser_->ShowDialog(GetTopLevelNativeWindow(), |
3454 GetRenderViewHost(), | 3460 GetRenderViewHost(), |
3455 value.dialog_type, | 3461 value.dialog_type, |
3456 value.dialog_value, | 3462 value.dialog_value, |
3457 value.minimum, | 3463 value.minimum, |
3458 value.maximum, | 3464 value.maximum, |
(...skipping 1186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4645 WebContentsAndroid* WebContentsImpl::GetWebContentsAndroid() { | 4651 WebContentsAndroid* WebContentsImpl::GetWebContentsAndroid() { |
4646 WebContentsAndroid* web_contents_android = | 4652 WebContentsAndroid* web_contents_android = |
4647 static_cast<WebContentsAndroid*>(GetUserData(kWebContentsAndroidKey)); | 4653 static_cast<WebContentsAndroid*>(GetUserData(kWebContentsAndroidKey)); |
4648 if (!web_contents_android) { | 4654 if (!web_contents_android) { |
4649 web_contents_android = new WebContentsAndroid(this); | 4655 web_contents_android = new WebContentsAndroid(this); |
4650 SetUserData(kWebContentsAndroidKey, web_contents_android); | 4656 SetUserData(kWebContentsAndroidKey, web_contents_android); |
4651 } | 4657 } |
4652 return web_contents_android; | 4658 return web_contents_android; |
4653 } | 4659 } |
4654 | 4660 |
4661 void WebContentsImpl::ActivateNearestFindResult(float x, | |
4662 float y) { | |
4663 GetOrCreateFindRequestManager()->ActivateNearestFindResult(x, y); | |
4664 } | |
4665 | |
4666 void WebContentsImpl::RequestFindMatchRects(int current_version) { | |
4667 GetOrCreateFindRequestManager()->RequestFindMatchRects(current_version); | |
4668 } | |
4669 | |
4655 bool WebContentsImpl::CreateRenderViewForInitialEmptyDocument() { | 4670 bool WebContentsImpl::CreateRenderViewForInitialEmptyDocument() { |
4656 return CreateRenderViewForRenderManager( | 4671 return CreateRenderViewForRenderManager( |
4657 GetRenderViewHost(), MSG_ROUTING_NONE, MSG_ROUTING_NONE, | 4672 GetRenderViewHost(), MSG_ROUTING_NONE, MSG_ROUTING_NONE, |
4658 frame_tree_.root()->current_replication_state()); | 4673 frame_tree_.root()->current_replication_state()); |
4659 } | 4674 } |
4660 | 4675 |
4661 #elif defined(OS_MACOSX) | 4676 #elif defined(OS_MACOSX) |
4662 | 4677 |
4663 void WebContentsImpl::SetAllowOtherViews(bool allow) { | 4678 void WebContentsImpl::SetAllowOtherViews(bool allow) { |
4664 view_->SetAllowOtherViews(allow); | 4679 view_->SetAllowOtherViews(allow); |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4801 if (controller) { | 4816 if (controller) { |
4802 web_ui->AddMessageHandler(new GenericHandler()); | 4817 web_ui->AddMessageHandler(new GenericHandler()); |
4803 web_ui->SetController(controller); | 4818 web_ui->SetController(controller); |
4804 return web_ui; | 4819 return web_ui; |
4805 } | 4820 } |
4806 | 4821 |
4807 delete web_ui; | 4822 delete web_ui; |
4808 return NULL; | 4823 return NULL; |
4809 } | 4824 } |
4810 | 4825 |
4826 FindRequestManager* WebContentsImpl::GetOrCreateFindRequestManager() { | |
ncarter (slow)
2016/04/06 19:08:03
I am okay with this name (it matches what we did f
paulmeyer
2016/04/07 17:36:15
I'll keep it this way. I think it does have some v
| |
4827 // TODO(paulmeyer): This method will need to access (or potentially create) | |
4828 // the FindRequestManager in the outermost WebContents once find-in-page | |
4829 // across GuestViews is implemented. | |
4830 if (!find_request_manager_) | |
4831 find_request_manager_.reset(new FindRequestManager(this)); | |
4832 | |
4833 return find_request_manager_.get(); | |
4834 } | |
4835 | |
4836 void WebContentsImpl::FindReply(int request_id, | |
4837 int number_of_matches, | |
4838 const gfx::Rect& selection_rect, | |
4839 int active_match_ordinal, | |
4840 bool final_update) { | |
4841 if (delegate_) { | |
4842 delegate_->FindReply(this, request_id, number_of_matches, selection_rect, | |
4843 active_match_ordinal, final_update); | |
4844 } | |
4845 } | |
4846 | |
4847 #if defined(OS_ANDROID) | |
4848 void WebContentsImpl::FindMatchRectsReply( | |
4849 int version, | |
4850 const std::vector<gfx::RectF>& rects, | |
4851 const gfx::RectF& active_rect) { | |
4852 if (delegate_) | |
4853 delegate_->FindMatchRectsReply(this, version, rects, active_rect); | |
4854 } | |
4855 #endif | |
4856 | |
4811 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) { | 4857 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) { |
4812 force_disable_overscroll_content_ = force_disable; | 4858 force_disable_overscroll_content_ = force_disable; |
4813 if (view_) | 4859 if (view_) |
4814 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); | 4860 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); |
4815 } | 4861 } |
4816 | 4862 |
4817 void WebContentsImpl::MediaStartedPlaying( | 4863 void WebContentsImpl::MediaStartedPlaying( |
4818 const WebContentsObserver::MediaPlayerId& id) { | 4864 const WebContentsObserver::MediaPlayerId& id) { |
4819 FOR_EACH_OBSERVER(WebContentsObserver, observers_, MediaStartedPlaying(id)); | 4865 FOR_EACH_OBSERVER(WebContentsObserver, observers_, MediaStartedPlaying(id)); |
4820 } | 4866 } |
(...skipping 25 matching lines...) Expand all Loading... | |
4846 else | 4892 else |
4847 WasHidden(); | 4893 WasHidden(); |
4848 } | 4894 } |
4849 | 4895 |
4850 void WebContentsImpl::SetJavaScriptDialogManagerForTesting( | 4896 void WebContentsImpl::SetJavaScriptDialogManagerForTesting( |
4851 JavaScriptDialogManager* dialog_manager) { | 4897 JavaScriptDialogManager* dialog_manager) { |
4852 dialog_manager_ = dialog_manager; | 4898 dialog_manager_ = dialog_manager; |
4853 } | 4899 } |
4854 | 4900 |
4855 } // namespace content | 4901 } // namespace content |
OLD | NEW |