| 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 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 // when there are no more references to this object. | 250 // when there are no more references to this object. |
| 251 ~AXTreeSnapshotCombiner() { | 251 ~AXTreeSnapshotCombiner() { |
| 252 combiner_.Combine(); | 252 combiner_.Combine(); |
| 253 callback_.Run(combiner_.combined()); | 253 callback_.Run(combiner_.combined()); |
| 254 } | 254 } |
| 255 | 255 |
| 256 ui::AXTreeCombiner combiner_; | 256 ui::AXTreeCombiner combiner_; |
| 257 AXTreeSnapshotCallback callback_; | 257 AXTreeSnapshotCallback callback_; |
| 258 }; | 258 }; |
| 259 | 259 |
| 260 // Helper for GetInnerWebContents(). |
| 261 bool GetInnerWebContentsHelper( |
| 262 std::vector<WebContentsImpl*>* all_guest_contents, |
| 263 WebContents* guest_contents) { |
| 264 all_guest_contents->push_back(static_cast<WebContentsImpl*>(guest_contents)); |
| 265 return false; |
| 266 } |
| 267 |
| 260 } // namespace | 268 } // namespace |
| 261 | 269 |
| 262 WebContents* WebContents::Create(const WebContents::CreateParams& params) { | 270 WebContents* WebContents::Create(const WebContents::CreateParams& params) { |
| 263 FrameTreeNode* opener_node = nullptr; | 271 FrameTreeNode* opener_node = nullptr; |
| 264 if (params.opener_render_frame_id != MSG_ROUTING_NONE) { | 272 if (params.opener_render_frame_id != MSG_ROUTING_NONE) { |
| 265 RenderFrameHostImpl* opener_rfh = RenderFrameHostImpl::FromID( | 273 RenderFrameHostImpl* opener_rfh = RenderFrameHostImpl::FromID( |
| 266 params.opener_render_process_id, params.opener_render_frame_id); | 274 params.opener_render_process_id, params.opener_render_frame_id); |
| 267 if (opener_rfh) | 275 if (opener_rfh) |
| 268 opener_node = opener_rfh->frame_tree_node(); | 276 opener_node = opener_rfh->frame_tree_node(); |
| 269 } | 277 } |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 374 WebContentsImpl* current_web_contents) | 382 WebContentsImpl* current_web_contents) |
| 375 : current_web_contents_(current_web_contents), | 383 : current_web_contents_(current_web_contents), |
| 376 outer_web_contents_(nullptr), | 384 outer_web_contents_(nullptr), |
| 377 outer_contents_frame_tree_node_id_( | 385 outer_contents_frame_tree_node_id_( |
| 378 FrameTreeNode::kFrameTreeNodeInvalidId), | 386 FrameTreeNode::kFrameTreeNodeInvalidId), |
| 379 focused_web_contents_(current_web_contents) {} | 387 focused_web_contents_(current_web_contents) {} |
| 380 | 388 |
| 381 WebContentsImpl::WebContentsTreeNode::~WebContentsTreeNode() { | 389 WebContentsImpl::WebContentsTreeNode::~WebContentsTreeNode() { |
| 382 if (OuterContentsFrameTreeNode()) | 390 if (OuterContentsFrameTreeNode()) |
| 383 OuterContentsFrameTreeNode()->RemoveObserver(this); | 391 OuterContentsFrameTreeNode()->RemoveObserver(this); |
| 392 |
| 393 if (outer_web_contents_) |
| 394 outer_web_contents_->node_.DetachInnerWebContents(current_web_contents_); |
| 384 } | 395 } |
| 385 | 396 |
| 386 void WebContentsImpl::WebContentsTreeNode::ConnectToOuterWebContents( | 397 void WebContentsImpl::WebContentsTreeNode::ConnectToOuterWebContents( |
| 387 WebContentsImpl* outer_web_contents, | 398 WebContentsImpl* outer_web_contents, |
| 388 RenderFrameHostImpl* outer_contents_frame) { | 399 RenderFrameHostImpl* outer_contents_frame) { |
| 389 focused_web_contents_ = nullptr; | 400 focused_web_contents_ = nullptr; |
| 390 outer_web_contents_ = outer_web_contents; | 401 outer_web_contents_ = outer_web_contents; |
| 391 outer_contents_frame_tree_node_id_ = | 402 outer_contents_frame_tree_node_id_ = |
| 392 outer_contents_frame->frame_tree_node()->frame_tree_node_id(); | 403 outer_contents_frame->frame_tree_node()->frame_tree_node_id(); |
| 393 | 404 |
| 405 outer_web_contents_->node_.AttachInnerWebContents(current_web_contents_); |
| 394 outer_contents_frame->frame_tree_node()->AddObserver(this); | 406 outer_contents_frame->frame_tree_node()->AddObserver(this); |
| 395 } | 407 } |
| 396 | 408 |
| 409 void WebContentsImpl::WebContentsTreeNode::AttachInnerWebContents( |
| 410 WebContentsImpl* inner_web_contents) { |
| 411 inner_web_contents_.push_back(inner_web_contents); |
| 412 } |
| 413 |
| 414 void WebContentsImpl::WebContentsTreeNode::DetachInnerWebContents( |
| 415 WebContentsImpl* inner_web_contents) { |
| 416 DCHECK(std::find(inner_web_contents_.begin(), inner_web_contents_.end(), |
| 417 inner_web_contents) != inner_web_contents_.end()); |
| 418 inner_web_contents_.erase( |
| 419 std::remove(inner_web_contents_.begin(), inner_web_contents_.end(), |
| 420 inner_web_contents), |
| 421 inner_web_contents_.end()); |
| 422 } |
| 423 |
| 397 FrameTreeNode* | 424 FrameTreeNode* |
| 398 WebContentsImpl::WebContentsTreeNode::OuterContentsFrameTreeNode() const { | 425 WebContentsImpl::WebContentsTreeNode::OuterContentsFrameTreeNode() const { |
| 399 return FrameTreeNode::GloballyFindByID(outer_contents_frame_tree_node_id_); | 426 return FrameTreeNode::GloballyFindByID(outer_contents_frame_tree_node_id_); |
| 400 } | 427 } |
| 401 | 428 |
| 402 void WebContentsImpl::WebContentsTreeNode::OnFrameTreeNodeDestroyed( | 429 void WebContentsImpl::WebContentsTreeNode::OnFrameTreeNodeDestroyed( |
| 403 FrameTreeNode* node) { | 430 FrameTreeNode* node) { |
| 404 DCHECK_EQ(outer_contents_frame_tree_node_id_, node->frame_tree_node_id()) | 431 DCHECK_EQ(outer_contents_frame_tree_node_id_, node->frame_tree_node_id()) |
| 405 << "WebContentsTreeNode should only receive notifications for the " | 432 << "WebContentsTreeNode should only receive notifications for the " |
| 406 "FrameTreeNode in its outer WebContents that hosts it."; | 433 "FrameTreeNode in its outer WebContents that hosts it."; |
| 407 delete current_web_contents_; // deletes |this| too. | 434 delete current_web_contents_; // deletes |this| too. |
| 408 } | 435 } |
| 409 | 436 |
| 410 void WebContentsImpl::WebContentsTreeNode::SetFocusedWebContents( | 437 void WebContentsImpl::WebContentsTreeNode::SetFocusedWebContents( |
| 411 WebContentsImpl* web_contents) { | 438 WebContentsImpl* web_contents) { |
| 412 DCHECK(!outer_web_contents()) | 439 DCHECK(!outer_web_contents()) |
| 413 << "Only the outermost WebContents tracks focus."; | 440 << "Only the outermost WebContents tracks focus."; |
| 414 focused_web_contents_ = web_contents; | 441 focused_web_contents_ = web_contents; |
| 415 } | 442 } |
| 416 | 443 |
| 444 WebContentsImpl* |
| 445 WebContentsImpl::WebContentsTreeNode::GetInnerWebContentsInFrame( |
| 446 const FrameTreeNode* frame) { |
| 447 auto ftn_id = frame->frame_tree_node_id(); |
| 448 for (WebContentsImpl* contents : inner_web_contents_) { |
| 449 if (contents->node_.outer_contents_frame_tree_node_id() == ftn_id) { |
| 450 return contents; |
| 451 } |
| 452 } |
| 453 return nullptr; |
| 454 } |
| 455 |
| 456 const std::vector<WebContentsImpl*>& |
| 457 WebContentsImpl::WebContentsTreeNode::inner_web_contents() const { |
| 458 return inner_web_contents_; |
| 459 } |
| 460 |
| 417 // WebContentsImpl ------------------------------------------------------------- | 461 // WebContentsImpl ------------------------------------------------------------- |
| 418 | 462 |
| 419 WebContentsImpl::WebContentsImpl(BrowserContext* browser_context) | 463 WebContentsImpl::WebContentsImpl(BrowserContext* browser_context) |
| 420 : delegate_(NULL), | 464 : delegate_(NULL), |
| 421 controller_(this, browser_context), | 465 controller_(this, browser_context), |
| 422 render_view_host_delegate_view_(NULL), | 466 render_view_host_delegate_view_(NULL), |
| 423 created_with_opener_(false), | 467 created_with_opener_(false), |
| 424 frame_tree_(new NavigatorImpl(&controller_, this), | 468 frame_tree_(new NavigatorImpl(&controller_, this), |
| 425 this, | 469 this, |
| 426 this, | 470 this, |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 657 continue; | 701 continue; |
| 658 // Because a WebContents can only have one current RVH at a time, there will | 702 // Because a WebContents can only have one current RVH at a time, there will |
| 659 // be no duplicate WebContents here. | 703 // be no duplicate WebContents here. |
| 660 result.push_back(static_cast<WebContentsImpl*>(web_contents)); | 704 result.push_back(static_cast<WebContentsImpl*>(web_contents)); |
| 661 } | 705 } |
| 662 return result; | 706 return result; |
| 663 } | 707 } |
| 664 | 708 |
| 665 // static | 709 // static |
| 666 WebContentsImpl* WebContentsImpl::FromFrameTreeNode( | 710 WebContentsImpl* WebContentsImpl::FromFrameTreeNode( |
| 667 FrameTreeNode* frame_tree_node) { | 711 const FrameTreeNode* frame_tree_node) { |
| 668 return static_cast<WebContentsImpl*>( | 712 return static_cast<WebContentsImpl*>( |
| 669 WebContents::FromRenderFrameHost(frame_tree_node->current_frame_host())); | 713 WebContents::FromRenderFrameHost(frame_tree_node->current_frame_host())); |
| 670 } | 714 } |
| 671 | 715 |
| 672 // static | 716 // static |
| 673 WebContents* WebContentsImpl::FromRenderFrameHostID(int render_process_host_id, | 717 WebContents* WebContentsImpl::FromRenderFrameHostID(int render_process_host_id, |
| 674 int render_frame_host_id) { | 718 int render_frame_host_id) { |
| 675 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 719 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 676 RenderFrameHost* render_frame_host = | 720 RenderFrameHost* render_frame_host = |
| 677 RenderFrameHost::FromID(render_process_host_id, render_frame_host_id); | 721 RenderFrameHost::FromID(render_process_host_id, render_frame_host_id); |
| 678 if (!render_frame_host) | 722 if (!render_frame_host) |
| 679 return nullptr; | 723 return nullptr; |
| 680 | 724 |
| 681 return WebContents::FromRenderFrameHost(render_frame_host); | 725 return WebContents::FromRenderFrameHost(render_frame_host); |
| 682 } | 726 } |
| 683 | 727 |
| 728 // static |
| 729 WebContentsImpl* WebContentsImpl::FromOuterFrameTreeNode( |
| 730 const FrameTreeNode* frame_tree_node) { |
| 731 return WebContentsImpl::FromFrameTreeNode(frame_tree_node) |
| 732 ->node_.GetInnerWebContentsInFrame(frame_tree_node); |
| 733 } |
| 734 |
| 684 RenderFrameHostManager* WebContentsImpl::GetRenderManagerForTesting() { | 735 RenderFrameHostManager* WebContentsImpl::GetRenderManagerForTesting() { |
| 685 return GetRenderManager(); | 736 return GetRenderManager(); |
| 686 } | 737 } |
| 687 | 738 |
| 688 bool WebContentsImpl::OnMessageReceived(RenderViewHostImpl* render_view_host, | 739 bool WebContentsImpl::OnMessageReceived(RenderViewHostImpl* render_view_host, |
| 689 const IPC::Message& message) { | 740 const IPC::Message& message) { |
| 690 RenderFrameHost* main_frame = render_view_host->GetMainFrame(); | 741 RenderFrameHost* main_frame = render_view_host->GetMainFrame(); |
| 691 if (main_frame) { | 742 if (main_frame) { |
| 692 WebUIImpl* web_ui = static_cast<RenderFrameHostImpl*>(main_frame)->web_ui(); | 743 WebUIImpl* web_ui = static_cast<RenderFrameHostImpl*>(main_frame)->web_ui(); |
| 693 if (web_ui && web_ui->OnMessageReceived(message)) | 744 if (web_ui && web_ui->OnMessageReceived(message)) |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1031 } | 1082 } |
| 1032 | 1083 |
| 1033 WebContentsBindingSet* WebContentsImpl::GetBindingSet( | 1084 WebContentsBindingSet* WebContentsImpl::GetBindingSet( |
| 1034 const std::string& interface_name) { | 1085 const std::string& interface_name) { |
| 1035 auto it = binding_sets_.find(interface_name); | 1086 auto it = binding_sets_.find(interface_name); |
| 1036 if (it == binding_sets_.end()) | 1087 if (it == binding_sets_.end()) |
| 1037 return nullptr; | 1088 return nullptr; |
| 1038 return it->second; | 1089 return it->second; |
| 1039 } | 1090 } |
| 1040 | 1091 |
| 1092 std::vector<WebContentsImpl*> WebContentsImpl::GetInnerWebContents() { |
| 1093 if (browser_plugin_embedder_) { |
| 1094 std::vector<WebContentsImpl*> inner_contents; |
| 1095 GetBrowserContext()->GetGuestManager()->ForEachGuest( |
| 1096 this, base::Bind(&GetInnerWebContentsHelper, &inner_contents)); |
| 1097 return inner_contents; |
| 1098 } |
| 1099 |
| 1100 return node_.inner_web_contents(); |
| 1101 } |
| 1102 |
| 1103 std::vector<WebContentsImpl*> WebContentsImpl::GetWebContentsAndAllInner() { |
| 1104 std::vector<WebContentsImpl*> all_contents(1, this); |
| 1105 |
| 1106 for (size_t i = 0; i != all_contents.size(); ++i) { |
| 1107 for (auto* inner_contents : all_contents[i]->GetInnerWebContents()) { |
| 1108 all_contents.push_back(inner_contents); |
| 1109 } |
| 1110 } |
| 1111 |
| 1112 return all_contents; |
| 1113 } |
| 1114 |
| 1041 void WebContentsImpl::UpdateDeviceScaleFactor(double device_scale_factor) { | 1115 void WebContentsImpl::UpdateDeviceScaleFactor(double device_scale_factor) { |
| 1042 SendPageMessage( | 1116 SendPageMessage( |
| 1043 new PageMsg_SetDeviceScaleFactor(MSG_ROUTING_NONE, device_scale_factor)); | 1117 new PageMsg_SetDeviceScaleFactor(MSG_ROUTING_NONE, device_scale_factor)); |
| 1044 } | 1118 } |
| 1045 | 1119 |
| 1046 void WebContentsImpl::GetScreenInfo(ScreenInfo* screen_info) { | 1120 void WebContentsImpl::GetScreenInfo(ScreenInfo* screen_info) { |
| 1047 if (GetView()) | 1121 if (GetView()) |
| 1048 GetView()->GetScreenInfo(screen_info); | 1122 GetView()->GetScreenInfo(screen_info); |
| 1049 } | 1123 } |
| 1050 | 1124 |
| (...skipping 793 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1844 RenderWidgetHostImpl* WebContentsImpl::GetFocusedRenderWidgetHost( | 1918 RenderWidgetHostImpl* WebContentsImpl::GetFocusedRenderWidgetHost( |
| 1845 RenderWidgetHostImpl* receiving_widget) { | 1919 RenderWidgetHostImpl* receiving_widget) { |
| 1846 if (!SiteIsolationPolicy::AreCrossProcessFramesPossible()) | 1920 if (!SiteIsolationPolicy::AreCrossProcessFramesPossible()) |
| 1847 return receiving_widget; | 1921 return receiving_widget; |
| 1848 | 1922 |
| 1849 // Events for widgets other than the main frame (e.g., popup menus) should be | 1923 // Events for widgets other than the main frame (e.g., popup menus) should be |
| 1850 // forwarded directly to the widget they arrived on. | 1924 // forwarded directly to the widget they arrived on. |
| 1851 if (receiving_widget != GetMainFrame()->GetRenderWidgetHost()) | 1925 if (receiving_widget != GetMainFrame()->GetRenderWidgetHost()) |
| 1852 return receiving_widget; | 1926 return receiving_widget; |
| 1853 | 1927 |
| 1854 FrameTreeNode* focused_frame = | 1928 // If the focused WebContents is a guest WebContents, then get the focused |
| 1855 GetFocusedWebContents()->frame_tree_.GetFocusedFrame(); | 1929 // frame in the embedder WebContents instead. |
| 1930 FrameTreeNode* focused_frame = nullptr; |
| 1931 WebContentsImpl* focused_contents = GetFocusedWebContents(); |
| 1932 if (focused_contents->browser_plugin_guest_ && |
| 1933 !GuestMode::IsCrossProcessFrameGuest(focused_contents)) { |
| 1934 focused_frame = frame_tree_.GetFocusedFrame(); |
| 1935 } else { |
| 1936 focused_frame = GetFocusedWebContents()->frame_tree_.GetFocusedFrame(); |
| 1937 } |
| 1856 if (!focused_frame) | 1938 if (!focused_frame) |
| 1857 return receiving_widget; | 1939 return receiving_widget; |
| 1858 | 1940 |
| 1859 // The view may be null if a subframe's renderer process has crashed while | 1941 // The view may be null if a subframe's renderer process has crashed while |
| 1860 // the subframe has focus. Drop the event in that case. Do not give | 1942 // the subframe has focus. Drop the event in that case. Do not give |
| 1861 // it to the main frame, so that the user doesn't unexpectedly type into the | 1943 // it to the main frame, so that the user doesn't unexpectedly type into the |
| 1862 // wrong frame if a focused subframe renderer crashes while they type. | 1944 // wrong frame if a focused subframe renderer crashes while they type. |
| 1863 RenderWidgetHostView* view = focused_frame->current_frame_host()->GetView(); | 1945 RenderWidgetHostView* view = focused_frame->current_frame_host()->GetView(); |
| 1864 if (!view) | 1946 if (!view) |
| 1865 return nullptr; | 1947 return nullptr; |
| (...skipping 1405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3271 | 3353 |
| 3272 void WebContentsImpl::Find(int request_id, | 3354 void WebContentsImpl::Find(int request_id, |
| 3273 const base::string16& search_text, | 3355 const base::string16& search_text, |
| 3274 const blink::WebFindOptions& options) { | 3356 const blink::WebFindOptions& options) { |
| 3275 // Cowardly refuse to search for no text. | 3357 // Cowardly refuse to search for no text. |
| 3276 if (search_text.empty()) { | 3358 if (search_text.empty()) { |
| 3277 NOTREACHED(); | 3359 NOTREACHED(); |
| 3278 return; | 3360 return; |
| 3279 } | 3361 } |
| 3280 | 3362 |
| 3281 // See if a top level browser plugin handles the find request first. | |
| 3282 // TODO(paulmeyer): Remove this after find-in-page works across GuestViews. | |
| 3283 if (browser_plugin_embedder_ && | |
| 3284 browser_plugin_embedder_->Find(request_id, search_text, options)) { | |
| 3285 return; | |
| 3286 } | |
| 3287 | |
| 3288 GetOrCreateFindRequestManager()->Find(request_id, search_text, options); | 3363 GetOrCreateFindRequestManager()->Find(request_id, search_text, options); |
| 3289 } | 3364 } |
| 3290 | 3365 |
| 3291 void WebContentsImpl::StopFinding(StopFindAction action) { | 3366 void WebContentsImpl::StopFinding(StopFindAction action) { |
| 3292 // See if a top level browser plugin handles the stop finding request first. | 3367 if (FindRequestManager* manager = GetFindRequestManager()) |
| 3293 // TODO(paulmeyer): Remove this after find-in-page works across GuestViews. | 3368 manager->StopFinding(action); |
| 3294 if (browser_plugin_embedder_ && | |
| 3295 browser_plugin_embedder_->StopFinding(action)) { | |
| 3296 return; | |
| 3297 } | |
| 3298 | |
| 3299 GetOrCreateFindRequestManager()->StopFinding(action); | |
| 3300 } | 3369 } |
| 3301 | 3370 |
| 3302 bool WebContentsImpl::WasRecentlyAudible() { | 3371 bool WebContentsImpl::WasRecentlyAudible() { |
| 3303 return audio_stream_monitor_.WasRecentlyAudible() || | 3372 return audio_stream_monitor_.WasRecentlyAudible() || |
| 3304 (browser_plugin_embedder_ && | 3373 (browser_plugin_embedder_ && |
| 3305 browser_plugin_embedder_->WereAnyGuestsRecentlyAudible()); | 3374 browser_plugin_embedder_->WereAnyGuestsRecentlyAudible()); |
| 3306 } | 3375 } |
| 3307 | 3376 |
| 3308 void WebContentsImpl::GetManifest(const GetManifestCallback& callback) { | 3377 void WebContentsImpl::GetManifest(const GetManifestCallback& callback) { |
| 3309 manifest_manager_host_->GetManifest(GetMainFrame(), callback); | 3378 manifest_manager_host_->GetManifest(GetMainFrame(), callback); |
| (...skipping 1454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4764 GetMainFrame()->GetRenderWidgetHost()->SetPageFocus(true); | 4833 GetMainFrame()->GetRenderWidgetHost()->SetPageFocus(true); |
| 4765 GetOutermostWebContents()->node_.SetFocusedWebContents(this); | 4834 GetOutermostWebContents()->node_.SetFocusedWebContents(this); |
| 4766 } | 4835 } |
| 4767 | 4836 |
| 4768 void WebContentsImpl::SetFocusedFrame(FrameTreeNode* node, | 4837 void WebContentsImpl::SetFocusedFrame(FrameTreeNode* node, |
| 4769 SiteInstance* source) { | 4838 SiteInstance* source) { |
| 4770 // The PDF plugin still runs as a BrowserPlugin and must go through the | 4839 // The PDF plugin still runs as a BrowserPlugin and must go through the |
| 4771 // input redirection mechanism. It must not become focused direcly. | 4840 // input redirection mechanism. It must not become focused direcly. |
| 4772 if (!GuestMode::IsCrossProcessFrameGuest(this) && browser_plugin_guest_) { | 4841 if (!GuestMode::IsCrossProcessFrameGuest(this) && browser_plugin_guest_) { |
| 4773 frame_tree_.SetFocusedFrame(node, source); | 4842 frame_tree_.SetFocusedFrame(node, source); |
| 4843 if (GetFocusedWebContents() != this) |
| 4844 GetOutermostWebContents()->node_.SetFocusedWebContents(this); |
| 4774 return; | 4845 return; |
| 4775 } | 4846 } |
| 4776 | 4847 |
| 4777 SetAsFocusedWebContentsIfNecessary(); | 4848 SetAsFocusedWebContentsIfNecessary(); |
| 4778 | 4849 |
| 4779 frame_tree_.SetFocusedFrame(node, source); | 4850 frame_tree_.SetFocusedFrame(node, source); |
| 4780 } | 4851 } |
| 4781 | 4852 |
| 4782 void WebContentsImpl::OnFocusedElementChangedInFrame( | 4853 void WebContentsImpl::OnFocusedElementChangedInFrame( |
| 4783 RenderFrameHostImpl* frame, | 4854 RenderFrameHostImpl* frame, |
| (...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5211 ->CreateWebUIControllerForURL(web_ui.get(), url); | 5282 ->CreateWebUIControllerForURL(web_ui.get(), url); |
| 5212 if (controller) { | 5283 if (controller) { |
| 5213 web_ui->AddMessageHandler(base::MakeUnique<GenericHandler>()); | 5284 web_ui->AddMessageHandler(base::MakeUnique<GenericHandler>()); |
| 5214 web_ui->SetController(controller); | 5285 web_ui->SetController(controller); |
| 5215 return web_ui; | 5286 return web_ui; |
| 5216 } | 5287 } |
| 5217 | 5288 |
| 5218 return nullptr; | 5289 return nullptr; |
| 5219 } | 5290 } |
| 5220 | 5291 |
| 5292 FindRequestManager* WebContentsImpl::GetFindRequestManager() { |
| 5293 for (WebContentsImpl* contents = this; contents; |
| 5294 contents = contents->GetOuterWebContents()) { |
| 5295 if (contents->find_request_manager_) |
| 5296 return contents->find_request_manager_.get(); |
| 5297 } |
| 5298 |
| 5299 return nullptr; |
| 5300 } |
| 5301 |
| 5221 FindRequestManager* WebContentsImpl::GetOrCreateFindRequestManager() { | 5302 FindRequestManager* WebContentsImpl::GetOrCreateFindRequestManager() { |
| 5222 // TODO(paulmeyer): This method will need to access (or potentially create) | 5303 if (FindRequestManager* manager = GetFindRequestManager()) |
| 5223 // the FindRequestManager in the outermost WebContents once find-in-page | 5304 return manager; |
| 5224 // across GuestViews is implemented. | 5305 |
| 5225 if (!find_request_manager_) | 5306 // No existing FindRequestManager found, so one must be created. |
| 5226 find_request_manager_.reset(new FindRequestManager(this)); | 5307 find_request_manager_.reset(new FindRequestManager(this)); |
| 5308 |
| 5309 // Concurrent find sessions must not overlap, so destroy any existing |
| 5310 // FindRequestManagers in any inner WebContentses. |
| 5311 for (WebContentsImpl* contents : GetWebContentsAndAllInner()) { |
| 5312 if (contents == this) |
| 5313 continue; |
| 5314 if (contents->find_request_manager_) { |
| 5315 contents->find_request_manager_->StopFinding( |
| 5316 content::STOP_FIND_ACTION_CLEAR_SELECTION); |
| 5317 contents->find_request_manager_.release(); |
| 5318 } |
| 5319 } |
| 5227 | 5320 |
| 5228 return find_request_manager_.get(); | 5321 return find_request_manager_.get(); |
| 5229 } | 5322 } |
| 5230 | 5323 |
| 5231 void WebContentsImpl::NotifyFindReply(int request_id, | 5324 void WebContentsImpl::NotifyFindReply(int request_id, |
| 5232 int number_of_matches, | 5325 int number_of_matches, |
| 5233 const gfx::Rect& selection_rect, | 5326 const gfx::Rect& selection_rect, |
| 5234 int active_match_ordinal, | 5327 int active_match_ordinal, |
| 5235 bool final_update) { | 5328 bool final_update) { |
| 5236 if (delegate_ && !is_being_destroyed_) { | 5329 if (delegate_ && !is_being_destroyed_) { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5268 | 5361 |
| 5269 void WebContentsImpl::SetHasPersistentVideo(bool has_persistent_video) { | 5362 void WebContentsImpl::SetHasPersistentVideo(bool has_persistent_video) { |
| 5270 if (has_persistent_video_ == has_persistent_video) | 5363 if (has_persistent_video_ == has_persistent_video) |
| 5271 return; | 5364 return; |
| 5272 | 5365 |
| 5273 has_persistent_video_ = has_persistent_video; | 5366 has_persistent_video_ = has_persistent_video; |
| 5274 NotifyPreferencesChanged(); | 5367 NotifyPreferencesChanged(); |
| 5275 media_web_contents_observer()->RequestPersistentVideo(has_persistent_video); | 5368 media_web_contents_observer()->RequestPersistentVideo(has_persistent_video); |
| 5276 } | 5369 } |
| 5277 | 5370 |
| 5371 void WebContentsImpl::BrowserPluginGuestWillDestroy() { |
| 5372 WebContentsImpl* outermost = GetOutermostWebContents(); |
| 5373 if (this != outermost && ContainsOrIsFocusedWebContents()) |
| 5374 outermost->SetAsFocusedWebContentsIfNecessary(); |
| 5375 } |
| 5376 |
| 5278 #if defined(OS_ANDROID) | 5377 #if defined(OS_ANDROID) |
| 5279 void WebContentsImpl::NotifyFindMatchRectsReply( | 5378 void WebContentsImpl::NotifyFindMatchRectsReply( |
| 5280 int version, | 5379 int version, |
| 5281 const std::vector<gfx::RectF>& rects, | 5380 const std::vector<gfx::RectF>& rects, |
| 5282 const gfx::RectF& active_rect) { | 5381 const gfx::RectF& active_rect) { |
| 5283 if (delegate_) | 5382 if (delegate_) |
| 5284 delegate_->FindMatchRectsReply(this, version, rects, active_rect); | 5383 delegate_->FindMatchRectsReply(this, version, rects, active_rect); |
| 5285 } | 5384 } |
| 5286 #endif | 5385 #endif |
| 5287 | 5386 |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5410 RenderViewHost* render_view_host = RenderViewHost::From(render_widget_host); | 5509 RenderViewHost* render_view_host = RenderViewHost::From(render_widget_host); |
| 5411 if (!render_view_host) | 5510 if (!render_view_host) |
| 5412 continue; | 5511 continue; |
| 5413 render_view_host_set.insert(render_view_host); | 5512 render_view_host_set.insert(render_view_host); |
| 5414 } | 5513 } |
| 5415 for (RenderViewHost* render_view_host : render_view_host_set) | 5514 for (RenderViewHost* render_view_host : render_view_host_set) |
| 5416 render_view_host->OnWebkitPreferencesChanged(); | 5515 render_view_host->OnWebkitPreferencesChanged(); |
| 5417 } | 5516 } |
| 5418 | 5517 |
| 5419 } // namespace content | 5518 } // namespace content |
| OLD | NEW |