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 GetWebContentsAndAllInner(). | |
261 bool GetWebContentsHelper(std::vector<WebContentsImpl*>* all_guest_contents, | |
262 WebContents* guest_contents) { | |
263 all_guest_contents->push_back(static_cast<WebContentsImpl*>(guest_contents)); | |
264 return false; | |
265 } | |
266 | |
260 } // namespace | 267 } // namespace |
261 | 268 |
262 WebContents* WebContents::Create(const WebContents::CreateParams& params) { | 269 WebContents* WebContents::Create(const WebContents::CreateParams& params) { |
263 FrameTreeNode* opener_node = nullptr; | 270 FrameTreeNode* opener_node = nullptr; |
264 if (params.opener_render_frame_id != MSG_ROUTING_NONE) { | 271 if (params.opener_render_frame_id != MSG_ROUTING_NONE) { |
265 RenderFrameHostImpl* opener_rfh = RenderFrameHostImpl::FromID( | 272 RenderFrameHostImpl* opener_rfh = RenderFrameHostImpl::FromID( |
266 params.opener_render_process_id, params.opener_render_frame_id); | 273 params.opener_render_process_id, params.opener_render_frame_id); |
267 if (opener_rfh) | 274 if (opener_rfh) |
268 opener_node = opener_rfh->frame_tree_node(); | 275 opener_node = opener_rfh->frame_tree_node(); |
269 } | 276 } |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
374 WebContentsImpl* current_web_contents) | 381 WebContentsImpl* current_web_contents) |
375 : current_web_contents_(current_web_contents), | 382 : current_web_contents_(current_web_contents), |
376 outer_web_contents_(nullptr), | 383 outer_web_contents_(nullptr), |
377 outer_contents_frame_tree_node_id_( | 384 outer_contents_frame_tree_node_id_( |
378 FrameTreeNode::kFrameTreeNodeInvalidId), | 385 FrameTreeNode::kFrameTreeNodeInvalidId), |
379 focused_web_contents_(current_web_contents) {} | 386 focused_web_contents_(current_web_contents) {} |
380 | 387 |
381 WebContentsImpl::WebContentsTreeNode::~WebContentsTreeNode() { | 388 WebContentsImpl::WebContentsTreeNode::~WebContentsTreeNode() { |
382 if (OuterContentsFrameTreeNode()) | 389 if (OuterContentsFrameTreeNode()) |
383 OuterContentsFrameTreeNode()->RemoveObserver(this); | 390 OuterContentsFrameTreeNode()->RemoveObserver(this); |
391 | |
392 if (outer_web_contents_) | |
393 outer_web_contents_->node_.DetachInnerWebContents(current_web_contents_); | |
384 } | 394 } |
385 | 395 |
386 void WebContentsImpl::WebContentsTreeNode::ConnectToOuterWebContents( | 396 void WebContentsImpl::WebContentsTreeNode::ConnectToOuterWebContents( |
387 WebContentsImpl* outer_web_contents, | 397 WebContentsImpl* outer_web_contents, |
388 RenderFrameHostImpl* outer_contents_frame) { | 398 RenderFrameHostImpl* outer_contents_frame) { |
389 focused_web_contents_ = nullptr; | 399 focused_web_contents_ = nullptr; |
390 outer_web_contents_ = outer_web_contents; | 400 outer_web_contents_ = outer_web_contents; |
391 outer_contents_frame_tree_node_id_ = | 401 outer_contents_frame_tree_node_id_ = |
392 outer_contents_frame->frame_tree_node()->frame_tree_node_id(); | 402 outer_contents_frame->frame_tree_node()->frame_tree_node_id(); |
393 | 403 |
404 outer_web_contents_->node_.AttachInnerWebContents(current_web_contents_); | |
394 outer_contents_frame->frame_tree_node()->AddObserver(this); | 405 outer_contents_frame->frame_tree_node()->AddObserver(this); |
395 } | 406 } |
396 | 407 |
408 void WebContentsImpl::WebContentsTreeNode::AttachInnerWebContents( | |
409 WebContentsImpl* inner_web_contents) { | |
410 inner_web_contents_.push_back(inner_web_contents); | |
411 } | |
412 | |
413 void WebContentsImpl::WebContentsTreeNode::DetachInnerWebContents( | |
414 WebContentsImpl* inner_web_contents) { | |
415 DCHECK(std::find(inner_web_contents_.begin(), inner_web_contents_.end(), | |
416 inner_web_contents) != inner_web_contents_.end()); | |
417 inner_web_contents_.erase( | |
418 std::remove(inner_web_contents_.begin(), inner_web_contents_.end(), | |
419 inner_web_contents), | |
420 inner_web_contents_.end()); | |
421 } | |
422 | |
397 FrameTreeNode* | 423 FrameTreeNode* |
398 WebContentsImpl::WebContentsTreeNode::OuterContentsFrameTreeNode() const { | 424 WebContentsImpl::WebContentsTreeNode::OuterContentsFrameTreeNode() const { |
399 return FrameTreeNode::GloballyFindByID(outer_contents_frame_tree_node_id_); | 425 return FrameTreeNode::GloballyFindByID(outer_contents_frame_tree_node_id_); |
400 } | 426 } |
401 | 427 |
402 void WebContentsImpl::WebContentsTreeNode::OnFrameTreeNodeDestroyed( | 428 void WebContentsImpl::WebContentsTreeNode::OnFrameTreeNodeDestroyed( |
403 FrameTreeNode* node) { | 429 FrameTreeNode* node) { |
404 DCHECK_EQ(outer_contents_frame_tree_node_id_, node->frame_tree_node_id()) | 430 DCHECK_EQ(outer_contents_frame_tree_node_id_, node->frame_tree_node_id()) |
405 << "WebContentsTreeNode should only receive notifications for the " | 431 << "WebContentsTreeNode should only receive notifications for the " |
406 "FrameTreeNode in its outer WebContents that hosts it."; | 432 "FrameTreeNode in its outer WebContents that hosts it."; |
407 delete current_web_contents_; // deletes |this| too. | 433 delete current_web_contents_; // deletes |this| too. |
408 } | 434 } |
409 | 435 |
410 void WebContentsImpl::WebContentsTreeNode::SetFocusedWebContents( | 436 void WebContentsImpl::WebContentsTreeNode::SetFocusedWebContents( |
411 WebContentsImpl* web_contents) { | 437 WebContentsImpl* web_contents) { |
412 DCHECK(!outer_web_contents()) | 438 DCHECK(!outer_web_contents()) |
413 << "Only the outermost WebContents tracks focus."; | 439 << "Only the outermost WebContents tracks focus."; |
414 focused_web_contents_ = web_contents; | 440 focused_web_contents_ = web_contents; |
415 } | 441 } |
416 | 442 |
443 WebContentsImpl* | |
444 WebContentsImpl::WebContentsTreeNode::GetInnerWebContentsInFrame( | |
445 const FrameTreeNode* frame) { | |
446 for (auto* contents : inner_web_contents_) | |
447 if (contents->node_.OuterContentsFrameTreeNode() == frame) | |
ncarter (slow)
2017/03/27 23:21:37
Might be faster to do this?
auto ftn_id = frame->
paulmeyer
2017/03/31 18:31:16
Agreed. Done.
| |
448 return contents; | |
449 return nullptr; | |
450 } | |
451 | |
452 void WebContentsImpl::WebContentsTreeNode::GetAllInnerWebContents( | |
453 std::vector<WebContentsImpl*>* all_contents) { | |
454 for (auto* contents : inner_web_contents_) { | |
455 all_contents->push_back(contents); | |
456 contents->node_.GetAllInnerWebContents(all_contents); | |
457 } | |
458 } | |
459 | |
417 // WebContentsImpl ------------------------------------------------------------- | 460 // WebContentsImpl ------------------------------------------------------------- |
418 | 461 |
419 WebContentsImpl::WebContentsImpl(BrowserContext* browser_context) | 462 WebContentsImpl::WebContentsImpl(BrowserContext* browser_context) |
420 : delegate_(NULL), | 463 : delegate_(NULL), |
421 controller_(this, browser_context), | 464 controller_(this, browser_context), |
422 render_view_host_delegate_view_(NULL), | 465 render_view_host_delegate_view_(NULL), |
423 created_with_opener_(false), | 466 created_with_opener_(false), |
424 frame_tree_(new NavigatorImpl(&controller_, this), | 467 frame_tree_(new NavigatorImpl(&controller_, this), |
425 this, | 468 this, |
426 this, | 469 this, |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
654 continue; | 697 continue; |
655 // Because a WebContents can only have one current RVH at a time, there will | 698 // Because a WebContents can only have one current RVH at a time, there will |
656 // be no duplicate WebContents here. | 699 // be no duplicate WebContents here. |
657 result.push_back(static_cast<WebContentsImpl*>(web_contents)); | 700 result.push_back(static_cast<WebContentsImpl*>(web_contents)); |
658 } | 701 } |
659 return result; | 702 return result; |
660 } | 703 } |
661 | 704 |
662 // static | 705 // static |
663 WebContentsImpl* WebContentsImpl::FromFrameTreeNode( | 706 WebContentsImpl* WebContentsImpl::FromFrameTreeNode( |
664 FrameTreeNode* frame_tree_node) { | 707 const FrameTreeNode* frame_tree_node) { |
665 return static_cast<WebContentsImpl*>( | 708 return static_cast<WebContentsImpl*>( |
666 WebContents::FromRenderFrameHost(frame_tree_node->current_frame_host())); | 709 WebContents::FromRenderFrameHost(frame_tree_node->current_frame_host())); |
667 } | 710 } |
668 | 711 |
669 // static | 712 // static |
670 WebContents* WebContentsImpl::FromRenderFrameHostID(int render_process_host_id, | 713 WebContents* WebContentsImpl::FromRenderFrameHostID(int render_process_host_id, |
671 int render_frame_host_id) { | 714 int render_frame_host_id) { |
672 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 715 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
673 RenderFrameHost* render_frame_host = | 716 RenderFrameHost* render_frame_host = |
674 RenderFrameHost::FromID(render_process_host_id, render_frame_host_id); | 717 RenderFrameHost::FromID(render_process_host_id, render_frame_host_id); |
675 if (!render_frame_host) | 718 if (!render_frame_host) |
676 return nullptr; | 719 return nullptr; |
677 | 720 |
678 return WebContents::FromRenderFrameHost(render_frame_host); | 721 return WebContents::FromRenderFrameHost(render_frame_host); |
679 } | 722 } |
680 | 723 |
724 // static | |
725 WebContentsImpl* WebContentsImpl::FromOuterFrameTreeNode( | |
726 const FrameTreeNode* frame_tree_node) { | |
727 return WebContentsImpl::FromFrameTreeNode(frame_tree_node)-> | |
728 node_.GetInnerWebContentsInFrame(frame_tree_node); | |
729 } | |
730 | |
681 RenderFrameHostManager* WebContentsImpl::GetRenderManagerForTesting() { | 731 RenderFrameHostManager* WebContentsImpl::GetRenderManagerForTesting() { |
682 return GetRenderManager(); | 732 return GetRenderManager(); |
683 } | 733 } |
684 | 734 |
685 bool WebContentsImpl::OnMessageReceived(RenderViewHostImpl* render_view_host, | 735 bool WebContentsImpl::OnMessageReceived(RenderViewHostImpl* render_view_host, |
686 const IPC::Message& message) { | 736 const IPC::Message& message) { |
687 RenderFrameHost* main_frame = render_view_host->GetMainFrame(); | 737 RenderFrameHost* main_frame = render_view_host->GetMainFrame(); |
688 if (main_frame) { | 738 if (main_frame) { |
689 WebUIImpl* web_ui = static_cast<RenderFrameHostImpl*>(main_frame)->web_ui(); | 739 WebUIImpl* web_ui = static_cast<RenderFrameHostImpl*>(main_frame)->web_ui(); |
690 if (web_ui && web_ui->OnMessageReceived(message)) | 740 if (web_ui && web_ui->OnMessageReceived(message)) |
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1026 } | 1076 } |
1027 | 1077 |
1028 WebContentsBindingSet* WebContentsImpl::GetBindingSet( | 1078 WebContentsBindingSet* WebContentsImpl::GetBindingSet( |
1029 const std::string& interface_name) { | 1079 const std::string& interface_name) { |
1030 auto it = binding_sets_.find(interface_name); | 1080 auto it = binding_sets_.find(interface_name); |
1031 if (it == binding_sets_.end()) | 1081 if (it == binding_sets_.end()) |
1032 return nullptr; | 1082 return nullptr; |
1033 return it->second; | 1083 return it->second; |
1034 } | 1084 } |
1035 | 1085 |
1086 std::vector<WebContentsImpl*> WebContentsImpl::GetWebContentsAndAllInner() { | |
1087 std::vector<WebContentsImpl*> all_contents(1, this); | |
1088 | |
1089 if (browser_plugin_embedder_) { | |
1090 GetBrowserContext()->GetGuestManager()->ForEachGuest( | |
1091 this, base::Bind(&GetWebContentsHelper, &all_contents)); | |
1092 } else { | |
1093 node_.GetAllInnerWebContents(&all_contents); | |
1094 } | |
1095 | |
1096 return all_contents; | |
1097 } | |
1098 | |
1036 void WebContentsImpl::UpdateDeviceScaleFactor(double device_scale_factor) { | 1099 void WebContentsImpl::UpdateDeviceScaleFactor(double device_scale_factor) { |
1037 SendPageMessage( | 1100 SendPageMessage( |
1038 new PageMsg_SetDeviceScaleFactor(MSG_ROUTING_NONE, device_scale_factor)); | 1101 new PageMsg_SetDeviceScaleFactor(MSG_ROUTING_NONE, device_scale_factor)); |
1039 } | 1102 } |
1040 | 1103 |
1041 void WebContentsImpl::GetScreenInfo(ScreenInfo* screen_info) { | 1104 void WebContentsImpl::GetScreenInfo(ScreenInfo* screen_info) { |
1042 if (GetView()) | 1105 if (GetView()) |
1043 GetView()->GetScreenInfo(screen_info); | 1106 GetView()->GetScreenInfo(screen_info); |
1044 } | 1107 } |
1045 | 1108 |
(...skipping 790 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1836 RenderWidgetHostImpl* WebContentsImpl::GetFocusedRenderWidgetHost( | 1899 RenderWidgetHostImpl* WebContentsImpl::GetFocusedRenderWidgetHost( |
1837 RenderWidgetHostImpl* receiving_widget) { | 1900 RenderWidgetHostImpl* receiving_widget) { |
1838 if (!SiteIsolationPolicy::AreCrossProcessFramesPossible()) | 1901 if (!SiteIsolationPolicy::AreCrossProcessFramesPossible()) |
1839 return receiving_widget; | 1902 return receiving_widget; |
1840 | 1903 |
1841 // Events for widgets other than the main frame (e.g., popup menus) should be | 1904 // Events for widgets other than the main frame (e.g., popup menus) should be |
1842 // forwarded directly to the widget they arrived on. | 1905 // forwarded directly to the widget they arrived on. |
1843 if (receiving_widget != GetMainFrame()->GetRenderWidgetHost()) | 1906 if (receiving_widget != GetMainFrame()->GetRenderWidgetHost()) |
1844 return receiving_widget; | 1907 return receiving_widget; |
1845 | 1908 |
1846 FrameTreeNode* focused_frame = | 1909 // If the focused WebContents is a guest WebContents, then get the focused |
1847 GetFocusedWebContents()->frame_tree_.GetFocusedFrame(); | 1910 // frame in the embedder WebContents instead. |
1911 FrameTreeNode* focused_frame = nullptr; | |
1912 WebContentsImpl* focused_contents = GetFocusedWebContents(); | |
1913 if (focused_contents->browser_plugin_guest_ && | |
1914 !GuestMode::IsCrossProcessFrameGuest(focused_contents)) { | |
1915 focused_frame = frame_tree_.GetFocusedFrame(); | |
1916 } else { | |
1917 focused_frame = GetFocusedWebContents()->frame_tree_.GetFocusedFrame(); | |
1918 } | |
ncarter (slow)
2017/03/27 23:21:37
Is this an orthogonal bugfix? What implications do
paulmeyer
2017/03/31 18:31:16
Actually, I don't think this is even necessary any
| |
1848 if (!focused_frame) | 1919 if (!focused_frame) |
1849 return receiving_widget; | 1920 return receiving_widget; |
1850 | 1921 |
1851 // The view may be null if a subframe's renderer process has crashed while | 1922 // The view may be null if a subframe's renderer process has crashed while |
1852 // the subframe has focus. Drop the event in that case. Do not give | 1923 // the subframe has focus. Drop the event in that case. Do not give |
1853 // it to the main frame, so that the user doesn't unexpectedly type into the | 1924 // it to the main frame, so that the user doesn't unexpectedly type into the |
1854 // wrong frame if a focused subframe renderer crashes while they type. | 1925 // wrong frame if a focused subframe renderer crashes while they type. |
1855 RenderWidgetHostView* view = focused_frame->current_frame_host()->GetView(); | 1926 RenderWidgetHostView* view = focused_frame->current_frame_host()->GetView(); |
1856 if (!view) | 1927 if (!view) |
1857 return nullptr; | 1928 return nullptr; |
(...skipping 1396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3254 | 3325 |
3255 void WebContentsImpl::Find(int request_id, | 3326 void WebContentsImpl::Find(int request_id, |
3256 const base::string16& search_text, | 3327 const base::string16& search_text, |
3257 const blink::WebFindOptions& options) { | 3328 const blink::WebFindOptions& options) { |
3258 // Cowardly refuse to search for no text. | 3329 // Cowardly refuse to search for no text. |
3259 if (search_text.empty()) { | 3330 if (search_text.empty()) { |
3260 NOTREACHED(); | 3331 NOTREACHED(); |
3261 return; | 3332 return; |
3262 } | 3333 } |
3263 | 3334 |
3264 // See if a top level browser plugin handles the find request first. | |
3265 // TODO(paulmeyer): Remove this after find-in-page works across GuestViews. | |
3266 if (browser_plugin_embedder_ && | |
3267 browser_plugin_embedder_->Find(request_id, search_text, options)) { | |
3268 return; | |
3269 } | |
3270 | |
3271 GetOrCreateFindRequestManager()->Find(request_id, search_text, options); | 3335 GetOrCreateFindRequestManager()->Find(request_id, search_text, options); |
3272 } | 3336 } |
3273 | 3337 |
3274 void WebContentsImpl::StopFinding(StopFindAction action) { | 3338 void WebContentsImpl::StopFinding(StopFindAction action) { |
3275 // See if a top level browser plugin handles the stop finding request first. | 3339 if (FindRequestManager* manager = GetFindRequestManager()) |
3276 // TODO(paulmeyer): Remove this after find-in-page works across GuestViews. | 3340 manager->StopFinding(action); |
3277 if (browser_plugin_embedder_ && | |
3278 browser_plugin_embedder_->StopFinding(action)) { | |
3279 return; | |
3280 } | |
3281 | |
3282 GetOrCreateFindRequestManager()->StopFinding(action); | |
3283 } | 3341 } |
3284 | 3342 |
3285 bool WebContentsImpl::WasRecentlyAudible() { | 3343 bool WebContentsImpl::WasRecentlyAudible() { |
3286 return audio_stream_monitor_.WasRecentlyAudible() || | 3344 return audio_stream_monitor_.WasRecentlyAudible() || |
3287 (browser_plugin_embedder_ && | 3345 (browser_plugin_embedder_ && |
3288 browser_plugin_embedder_->WereAnyGuestsRecentlyAudible()); | 3346 browser_plugin_embedder_->WereAnyGuestsRecentlyAudible()); |
3289 } | 3347 } |
3290 | 3348 |
3291 void WebContentsImpl::GetManifest(const GetManifestCallback& callback) { | 3349 void WebContentsImpl::GetManifest(const GetManifestCallback& callback) { |
3292 manifest_manager_host_->GetManifest(GetMainFrame(), callback); | 3350 manifest_manager_host_->GetManifest(GetMainFrame(), callback); |
(...skipping 1449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4742 GetMainFrame()->GetRenderWidgetHost()->SetPageFocus(true); | 4800 GetMainFrame()->GetRenderWidgetHost()->SetPageFocus(true); |
4743 GetOutermostWebContents()->node_.SetFocusedWebContents(this); | 4801 GetOutermostWebContents()->node_.SetFocusedWebContents(this); |
4744 } | 4802 } |
4745 | 4803 |
4746 void WebContentsImpl::SetFocusedFrame(FrameTreeNode* node, | 4804 void WebContentsImpl::SetFocusedFrame(FrameTreeNode* node, |
4747 SiteInstance* source) { | 4805 SiteInstance* source) { |
4748 // The PDF plugin still runs as a BrowserPlugin and must go through the | 4806 // The PDF plugin still runs as a BrowserPlugin and must go through the |
4749 // input redirection mechanism. It must not become focused direcly. | 4807 // input redirection mechanism. It must not become focused direcly. |
4750 if (!GuestMode::IsCrossProcessFrameGuest(this) && browser_plugin_guest_) { | 4808 if (!GuestMode::IsCrossProcessFrameGuest(this) && browser_plugin_guest_) { |
4751 frame_tree_.SetFocusedFrame(node, source); | 4809 frame_tree_.SetFocusedFrame(node, source); |
4810 if (GetFocusedWebContents() != this) | |
4811 GetOutermostWebContents()->node_.SetFocusedWebContents(this); | |
4752 return; | 4812 return; |
4753 } | 4813 } |
4754 | 4814 |
4755 SetAsFocusedWebContentsIfNecessary(); | 4815 SetAsFocusedWebContentsIfNecessary(); |
4756 | 4816 |
4757 frame_tree_.SetFocusedFrame(node, source); | 4817 frame_tree_.SetFocusedFrame(node, source); |
4758 } | 4818 } |
4759 | 4819 |
4760 void WebContentsImpl::OnFocusedElementChangedInFrame( | 4820 void WebContentsImpl::OnFocusedElementChangedInFrame( |
4761 RenderFrameHostImpl* frame, | 4821 RenderFrameHostImpl* frame, |
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5194 ->CreateWebUIControllerForURL(web_ui.get(), url); | 5254 ->CreateWebUIControllerForURL(web_ui.get(), url); |
5195 if (controller) { | 5255 if (controller) { |
5196 web_ui->AddMessageHandler(base::MakeUnique<GenericHandler>()); | 5256 web_ui->AddMessageHandler(base::MakeUnique<GenericHandler>()); |
5197 web_ui->SetController(controller); | 5257 web_ui->SetController(controller); |
5198 return web_ui; | 5258 return web_ui; |
5199 } | 5259 } |
5200 | 5260 |
5201 return nullptr; | 5261 return nullptr; |
5202 } | 5262 } |
5203 | 5263 |
5264 FindRequestManager* WebContentsImpl::GetFindRequestManager() { | |
5265 for (WebContentsImpl* contents = this; contents; | |
5266 contents = contents->GetOuterWebContents()) { | |
5267 if (contents->find_request_manager_) | |
5268 return contents->find_request_manager_.get(); | |
5269 } | |
5270 | |
5271 return nullptr; | |
5272 } | |
5273 | |
5204 FindRequestManager* WebContentsImpl::GetOrCreateFindRequestManager() { | 5274 FindRequestManager* WebContentsImpl::GetOrCreateFindRequestManager() { |
5205 // TODO(paulmeyer): This method will need to access (or potentially create) | 5275 if (FindRequestManager* manager = GetFindRequestManager()) |
5206 // the FindRequestManager in the outermost WebContents once find-in-page | 5276 return manager; |
5207 // across GuestViews is implemented. | 5277 |
5208 if (!find_request_manager_) | 5278 // No existing FindRequestManager found, so one must be created. |
5209 find_request_manager_.reset(new FindRequestManager(this)); | 5279 find_request_manager_.reset(new FindRequestManager(this)); |
5280 | |
5281 // Concurrent find sessions must not overlap, so destroy any existing | |
5282 // FindRequestManagers in any inner WebContentses. | |
5283 for (WebContentsImpl* contents : GetWebContentsAndAllInner()) { | |
5284 if (contents == this) | |
5285 continue; | |
5286 if (contents->find_request_manager_) { | |
5287 contents->find_request_manager_->StopFinding( | |
5288 content::STOP_FIND_ACTION_CLEAR_SELECTION); | |
5289 contents->find_request_manager_.release(); | |
5290 } | |
5291 } | |
5210 | 5292 |
5211 return find_request_manager_.get(); | 5293 return find_request_manager_.get(); |
5212 } | 5294 } |
5213 | 5295 |
5214 void WebContentsImpl::NotifyFindReply(int request_id, | 5296 void WebContentsImpl::NotifyFindReply(int request_id, |
5215 int number_of_matches, | 5297 int number_of_matches, |
5216 const gfx::Rect& selection_rect, | 5298 const gfx::Rect& selection_rect, |
5217 int active_match_ordinal, | 5299 int active_match_ordinal, |
5218 bool final_update) { | 5300 bool final_update) { |
5219 if (delegate_ && !is_being_destroyed_) { | 5301 if (delegate_ && !is_being_destroyed_) { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5251 | 5333 |
5252 void WebContentsImpl::SetHasPersistentVideo(bool has_persistent_video) { | 5334 void WebContentsImpl::SetHasPersistentVideo(bool has_persistent_video) { |
5253 if (has_persistent_video_ == has_persistent_video) | 5335 if (has_persistent_video_ == has_persistent_video) |
5254 return; | 5336 return; |
5255 | 5337 |
5256 has_persistent_video_ = has_persistent_video; | 5338 has_persistent_video_ = has_persistent_video; |
5257 NotifyPreferencesChanged(); | 5339 NotifyPreferencesChanged(); |
5258 media_web_contents_observer()->RequestPersistentVideo(has_persistent_video); | 5340 media_web_contents_observer()->RequestPersistentVideo(has_persistent_video); |
5259 } | 5341 } |
5260 | 5342 |
5343 void WebContentsImpl::BrowserPluginGuestWillDestroy() { | |
5344 WebContentsImpl* outermost = GetOutermostWebContents(); | |
5345 if (this != outermost && ContainsOrIsFocusedWebContents()) | |
5346 outermost->SetAsFocusedWebContentsIfNecessary(); | |
5347 } | |
5348 | |
5261 #if defined(OS_ANDROID) | 5349 #if defined(OS_ANDROID) |
5262 void WebContentsImpl::NotifyFindMatchRectsReply( | 5350 void WebContentsImpl::NotifyFindMatchRectsReply( |
5263 int version, | 5351 int version, |
5264 const std::vector<gfx::RectF>& rects, | 5352 const std::vector<gfx::RectF>& rects, |
5265 const gfx::RectF& active_rect) { | 5353 const gfx::RectF& active_rect) { |
5266 if (delegate_) | 5354 if (delegate_) |
5267 delegate_->FindMatchRectsReply(this, version, rects, active_rect); | 5355 delegate_->FindMatchRectsReply(this, version, rects, active_rect); |
5268 } | 5356 } |
5269 #endif | 5357 #endif |
5270 | 5358 |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5393 RenderViewHost* render_view_host = RenderViewHost::From(render_widget_host); | 5481 RenderViewHost* render_view_host = RenderViewHost::From(render_widget_host); |
5394 if (!render_view_host) | 5482 if (!render_view_host) |
5395 continue; | 5483 continue; |
5396 render_view_host_set.insert(render_view_host); | 5484 render_view_host_set.insert(render_view_host); |
5397 } | 5485 } |
5398 for (RenderViewHost* render_view_host : render_view_host_set) | 5486 for (RenderViewHost* render_view_host : render_view_host_set) |
5399 render_view_host->OnWebkitPreferencesChanged(); | 5487 render_view_host->OnWebkitPreferencesChanged(); |
5400 } | 5488 } |
5401 | 5489 |
5402 } // namespace content | 5490 } // namespace content |
OLD | NEW |