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 2272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2886 void WebContentsImpl::Find(int request_id, | 2886 void WebContentsImpl::Find(int request_id, |
2887 const base::string16& search_text, | 2887 const base::string16& search_text, |
2888 const blink::WebFindOptions& options) { | 2888 const blink::WebFindOptions& options) { |
2889 // Cowardly refuse to search for no text. | 2889 // Cowardly refuse to search for no text. |
2890 if (search_text.empty()) { | 2890 if (search_text.empty()) { |
2891 NOTREACHED(); | 2891 NOTREACHED(); |
2892 return; | 2892 return; |
2893 } | 2893 } |
2894 | 2894 |
2895 // See if a top level browser plugin handles the find request first. | 2895 // See if a top level browser plugin handles the find request first. |
2896 // TODO(paulmeyer): Remove this after find-in-page works across GuestViews. | |
2896 if (browser_plugin_embedder_ && | 2897 if (browser_plugin_embedder_ && |
2897 browser_plugin_embedder_->Find(request_id, search_text, options)) { | 2898 browser_plugin_embedder_->Find(request_id, search_text, options)) { |
2898 return; | 2899 return; |
2899 } | 2900 } |
2900 GetMainFrame()->Send(new FrameMsg_Find(GetMainFrame()->GetRoutingID(), | 2901 |
2901 request_id, search_text, options)); | 2902 GetOrCreateFindRequestManager()->Find(request_id, search_text, options); |
2902 } | 2903 } |
2903 | 2904 |
2904 void WebContentsImpl::StopFinding(StopFindAction action) { | 2905 void WebContentsImpl::StopFinding(StopFindAction action) { |
2905 // See if a top level browser plugin handles the stop finding request first. | 2906 // See if a top level browser plugin handles the stop finding request first. |
2907 // TODO(paulmeyer): Remove this after find-in-page works across GuestViews. | |
2906 if (browser_plugin_embedder_ && | 2908 if (browser_plugin_embedder_ && |
2907 browser_plugin_embedder_->StopFinding(action)) { | 2909 browser_plugin_embedder_->StopFinding(action)) { |
2908 return; | 2910 return; |
2909 } | 2911 } |
2910 GetMainFrame()->Send( | 2912 |
2911 new FrameMsg_StopFinding(GetMainFrame()->GetRoutingID(), action)); | 2913 GetOrCreateFindRequestManager()->StopFinding(action); |
2912 } | 2914 } |
2913 | 2915 |
2914 void WebContentsImpl::InsertCSS(const std::string& css) { | 2916 void WebContentsImpl::InsertCSS(const std::string& css) { |
2915 GetMainFrame()->Send(new FrameMsg_CSSInsertRequest( | 2917 GetMainFrame()->Send(new FrameMsg_CSSInsertRequest( |
2916 GetMainFrame()->GetRoutingID(), css)); | 2918 GetMainFrame()->GetRoutingID(), css)); |
2917 } | 2919 } |
2918 | 2920 |
2919 bool WebContentsImpl::WasRecentlyAudible() { | 2921 bool WebContentsImpl::WasRecentlyAudible() { |
2920 return audio_stream_monitor_.WasRecentlyAudible(); | 2922 return audio_stream_monitor_.WasRecentlyAudible(); |
2921 } | 2923 } |
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3419 void WebContentsImpl::OnUpdatePageImportanceSignals( | 3421 void WebContentsImpl::OnUpdatePageImportanceSignals( |
3420 const PageImportanceSignals& signals) { | 3422 const PageImportanceSignals& signals) { |
3421 page_importance_signals_ = signals; | 3423 page_importance_signals_ = signals; |
3422 } | 3424 } |
3423 | 3425 |
3424 void WebContentsImpl::OnFindReply(int request_id, | 3426 void WebContentsImpl::OnFindReply(int request_id, |
3425 int number_of_matches, | 3427 int number_of_matches, |
3426 const gfx::Rect& selection_rect, | 3428 const gfx::Rect& selection_rect, |
3427 int active_match_ordinal, | 3429 int active_match_ordinal, |
3428 bool final_update) { | 3430 bool final_update) { |
3429 if (delegate_) { | 3431 // Forward the find reply to the FindRequestManager, along with the |
3430 delegate_->FindReply(this, request_id, number_of_matches, selection_rect, | 3432 // RenderFrameHost associated with the frame that the reply came from. |
3431 active_match_ordinal, final_update); | 3433 GetOrCreateFindRequestManager()->FindReply(render_frame_message_source_, |
3432 } | 3434 request_id, |
3435 number_of_matches, | |
3436 selection_rect, | |
3437 active_match_ordinal, | |
3438 final_update); | |
3433 } | 3439 } |
3434 | 3440 |
3435 #if defined(OS_ANDROID) | 3441 #if defined(OS_ANDROID) |
3436 void WebContentsImpl::OnFindMatchRectsReply( | 3442 void WebContentsImpl::OnFindMatchRectsReply( |
3437 int version, | 3443 int version, |
3438 const std::vector<gfx::RectF>& rects, | 3444 const std::vector<gfx::RectF>& rects, |
3439 const gfx::RectF& active_rect) { | 3445 const gfx::RectF& active_rect) { |
3440 if (delegate_) | 3446 GetOrCreateFindRequestManager()->FindMatchRectsReply( |
3441 delegate_->FindMatchRectsReply(this, version, rects, active_rect); | 3447 render_frame_message_source_, version, rects, active_rect); |
3442 } | 3448 } |
3443 | 3449 |
3444 void WebContentsImpl::OnOpenDateTimeDialog( | 3450 void WebContentsImpl::OnOpenDateTimeDialog( |
3445 const ViewHostMsg_DateTimeDialogValue_Params& value) { | 3451 const ViewHostMsg_DateTimeDialogValue_Params& value) { |
3446 date_time_chooser_->ShowDialog(GetTopLevelNativeWindow(), | 3452 date_time_chooser_->ShowDialog(GetTopLevelNativeWindow(), |
3447 GetRenderViewHost(), | 3453 GetRenderViewHost(), |
3448 value.dialog_type, | 3454 value.dialog_type, |
3449 value.dialog_value, | 3455 value.dialog_value, |
3450 value.minimum, | 3456 value.minimum, |
3451 value.maximum, | 3457 value.maximum, |
(...skipping 1186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4638 WebContentsAndroid* WebContentsImpl::GetWebContentsAndroid() { | 4644 WebContentsAndroid* WebContentsImpl::GetWebContentsAndroid() { |
4639 WebContentsAndroid* web_contents_android = | 4645 WebContentsAndroid* web_contents_android = |
4640 static_cast<WebContentsAndroid*>(GetUserData(kWebContentsAndroidKey)); | 4646 static_cast<WebContentsAndroid*>(GetUserData(kWebContentsAndroidKey)); |
4641 if (!web_contents_android) { | 4647 if (!web_contents_android) { |
4642 web_contents_android = new WebContentsAndroid(this); | 4648 web_contents_android = new WebContentsAndroid(this); |
4643 SetUserData(kWebContentsAndroidKey, web_contents_android); | 4649 SetUserData(kWebContentsAndroidKey, web_contents_android); |
4644 } | 4650 } |
4645 return web_contents_android; | 4651 return web_contents_android; |
4646 } | 4652 } |
4647 | 4653 |
4654 void WebContentsImpl::ActivateNearestFindResult(float x, | |
4655 float y) { | |
4656 GetOrCreateFindRequestManager()->ActivateNearestFindResult(x, y); | |
4657 } | |
4658 | |
4659 void WebContentsImpl::RequestFindMatchRects(int current_version) { | |
4660 GetOrCreateFindRequestManager()->RequestFindMatchRects(current_version); | |
4661 } | |
4662 | |
4648 bool WebContentsImpl::CreateRenderViewForInitialEmptyDocument() { | 4663 bool WebContentsImpl::CreateRenderViewForInitialEmptyDocument() { |
4649 return CreateRenderViewForRenderManager( | 4664 return CreateRenderViewForRenderManager( |
4650 GetRenderViewHost(), MSG_ROUTING_NONE, MSG_ROUTING_NONE, | 4665 GetRenderViewHost(), MSG_ROUTING_NONE, MSG_ROUTING_NONE, |
4651 frame_tree_.root()->current_replication_state()); | 4666 frame_tree_.root()->current_replication_state()); |
4652 } | 4667 } |
4653 | 4668 |
4654 #elif defined(OS_MACOSX) | 4669 #elif defined(OS_MACOSX) |
4655 | 4670 |
4656 void WebContentsImpl::SetAllowOtherViews(bool allow) { | 4671 void WebContentsImpl::SetAllowOtherViews(bool allow) { |
4657 view_->SetAllowOtherViews(allow); | 4672 view_->SetAllowOtherViews(allow); |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4791 if (controller) { | 4806 if (controller) { |
4792 web_ui->AddMessageHandler(new GenericHandler()); | 4807 web_ui->AddMessageHandler(new GenericHandler()); |
4793 web_ui->SetController(controller); | 4808 web_ui->SetController(controller); |
4794 return web_ui; | 4809 return web_ui; |
4795 } | 4810 } |
4796 | 4811 |
4797 delete web_ui; | 4812 delete web_ui; |
4798 return NULL; | 4813 return NULL; |
4799 } | 4814 } |
4800 | 4815 |
4816 FindRequestManager* WebContentsImpl::GetOrCreateFindRequestManager() { | |
4817 // TODO(paulmeyer): This method will need to access (or potentially create) | |
4818 // the FindRequestManager in the outermost WebContents once find-in-page | |
4819 // across GuestViews is implemented. | |
4820 if (!find_request_manager_.get()) | |
dcheng
2016/04/04 18:59:52
Nit: no .get()
paulmeyer
2016/04/04 20:07:47
Done.
Thanks for catching this! I didn't realize
| |
4821 find_request_manager_.reset(new FindRequestManager(this)); | |
4822 | |
4823 return find_request_manager_.get(); | |
4824 } | |
4825 | |
4826 void WebContentsImpl::FindReply(int request_id, | |
4827 int number_of_matches, | |
4828 const gfx::Rect& selection_rect, | |
4829 int active_match_ordinal, | |
4830 bool final_update) { | |
4831 if (delegate_) { | |
4832 delegate_->FindReply(this, request_id, number_of_matches, selection_rect, | |
4833 active_match_ordinal, final_update); | |
4834 } | |
4835 } | |
4836 | |
4837 #if defined(OS_ANDROID) | |
4838 void WebContentsImpl::FindMatchRectsReply( | |
4839 int version, | |
4840 const std::vector<gfx::RectF>& rects, | |
4841 const gfx::RectF& active_rect) { | |
4842 if (delegate_) | |
4843 delegate_->FindMatchRectsReply(this, version, rects, active_rect); | |
4844 } | |
4845 #endif | |
4846 | |
4801 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) { | 4847 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) { |
4802 force_disable_overscroll_content_ = force_disable; | 4848 force_disable_overscroll_content_ = force_disable; |
4803 if (view_) | 4849 if (view_) |
4804 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); | 4850 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); |
4805 } | 4851 } |
4806 | 4852 |
4807 void WebContentsImpl::MediaStartedPlaying( | 4853 void WebContentsImpl::MediaStartedPlaying( |
4808 const WebContentsObserver::MediaPlayerId& id) { | 4854 const WebContentsObserver::MediaPlayerId& id) { |
4809 FOR_EACH_OBSERVER(WebContentsObserver, observers_, MediaStartedPlaying(id)); | 4855 FOR_EACH_OBSERVER(WebContentsObserver, observers_, MediaStartedPlaying(id)); |
4810 } | 4856 } |
(...skipping 25 matching lines...) Expand all Loading... | |
4836 else | 4882 else |
4837 WasHidden(); | 4883 WasHidden(); |
4838 } | 4884 } |
4839 | 4885 |
4840 void WebContentsImpl::SetJavaScriptDialogManagerForTesting( | 4886 void WebContentsImpl::SetJavaScriptDialogManagerForTesting( |
4841 JavaScriptDialogManager* dialog_manager) { | 4887 JavaScriptDialogManager* dialog_manager) { |
4842 dialog_manager_ = dialog_manager; | 4888 dialog_manager_ = dialog_manager; |
4843 } | 4889 } |
4844 | 4890 |
4845 } // namespace content | 4891 } // namespace content |
OLD | NEW |