OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/frame_host/render_frame_host_impl.h" | 5 #include "content/browser/frame_host/render_frame_host_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
155 // WebView). | 155 // WebView). |
156 bool g_allow_injecting_javascript = false; | 156 bool g_allow_injecting_javascript = false; |
157 | 157 |
158 // The (process id, routing id) pair that identifies one RenderFrame. | 158 // The (process id, routing id) pair that identifies one RenderFrame. |
159 typedef std::pair<int32_t, int32_t> RenderFrameHostID; | 159 typedef std::pair<int32_t, int32_t> RenderFrameHostID; |
160 typedef base::hash_map<RenderFrameHostID, RenderFrameHostImpl*> | 160 typedef base::hash_map<RenderFrameHostID, RenderFrameHostImpl*> |
161 RoutingIDFrameMap; | 161 RoutingIDFrameMap; |
162 base::LazyInstance<RoutingIDFrameMap>::DestructorAtExit g_routing_id_frame_map = | 162 base::LazyInstance<RoutingIDFrameMap>::DestructorAtExit g_routing_id_frame_map = |
163 LAZY_INSTANCE_INITIALIZER; | 163 LAZY_INSTANCE_INITIALIZER; |
164 | 164 |
165 #if defined(OS_ANDROID) | |
166 using TokenFrameMap = base::hash_map<base::UnguessableToken, | |
167 RenderFrameHostImpl*, | |
168 base::UnguessableTokenHash>; | |
169 base::LazyInstance<TokenFrameMap>::Leaky g_token_frame_map = | |
170 LAZY_INSTANCE_INITIALIZER; | |
171 #endif | |
172 | |
165 // Translate a WebKit text direction into a base::i18n one. | 173 // Translate a WebKit text direction into a base::i18n one. |
166 base::i18n::TextDirection WebTextDirectionToChromeTextDirection( | 174 base::i18n::TextDirection WebTextDirectionToChromeTextDirection( |
167 blink::WebTextDirection dir) { | 175 blink::WebTextDirection dir) { |
168 switch (dir) { | 176 switch (dir) { |
169 case blink::kWebTextDirectionLeftToRight: | 177 case blink::kWebTextDirectionLeftToRight: |
170 return base::i18n::LEFT_TO_RIGHT; | 178 return base::i18n::LEFT_TO_RIGHT; |
171 case blink::kWebTextDirectionRightToLeft: | 179 case blink::kWebTextDirectionRightToLeft: |
172 return base::i18n::RIGHT_TO_LEFT; | 180 return base::i18n::RIGHT_TO_LEFT; |
173 default: | 181 default: |
174 NOTREACHED(); | 182 NOTREACHED(); |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
350 | 358 |
351 // static | 359 // static |
352 RenderFrameHostImpl* RenderFrameHostImpl::FromAXTreeID( | 360 RenderFrameHostImpl* RenderFrameHostImpl::FromAXTreeID( |
353 ui::AXTreeIDRegistry::AXTreeID ax_tree_id) { | 361 ui::AXTreeIDRegistry::AXTreeID ax_tree_id) { |
354 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 362 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
355 ui::AXTreeIDRegistry::FrameID frame_id = | 363 ui::AXTreeIDRegistry::FrameID frame_id = |
356 ui::AXTreeIDRegistry::GetInstance()->GetFrameID(ax_tree_id); | 364 ui::AXTreeIDRegistry::GetInstance()->GetFrameID(ax_tree_id); |
357 return RenderFrameHostImpl::FromID(frame_id.first, frame_id.second); | 365 return RenderFrameHostImpl::FromID(frame_id.first, frame_id.second); |
358 } | 366 } |
359 | 367 |
368 #if defined(OS_ANDROID) | |
369 // static | |
370 RenderFrameHostImpl* RenderFrameHostImpl::FromOverlayRoutingToken( | |
371 const base::UnguessableToken& token) { | |
372 DCHECK_CURRENTLY_ON(BrowserThread::UI); | |
373 auto it = g_token_frame_map.Get().find(token); | |
374 return it == g_token_frame_map.Get().end() ? nullptr : it->second; | |
375 } | |
376 #endif | |
377 | |
360 RenderFrameHostImpl::RenderFrameHostImpl(SiteInstance* site_instance, | 378 RenderFrameHostImpl::RenderFrameHostImpl(SiteInstance* site_instance, |
361 RenderViewHostImpl* render_view_host, | 379 RenderViewHostImpl* render_view_host, |
362 RenderFrameHostDelegate* delegate, | 380 RenderFrameHostDelegate* delegate, |
363 RenderWidgetHostDelegate* rwh_delegate, | 381 RenderWidgetHostDelegate* rwh_delegate, |
364 FrameTree* frame_tree, | 382 FrameTree* frame_tree, |
365 FrameTreeNode* frame_tree_node, | 383 FrameTreeNode* frame_tree_node, |
366 int32_t routing_id, | 384 int32_t routing_id, |
367 int32_t widget_routing_id, | 385 int32_t widget_routing_id, |
368 bool hidden, | 386 bool hidden, |
369 bool renderer_initiated_creation) | 387 bool renderer_initiated_creation) |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
454 // so we do it early while |this| object is still in a sane state. | 472 // so we do it early while |this| object is still in a sane state. |
455 navigation_handle_.reset(); | 473 navigation_handle_.reset(); |
456 | 474 |
457 // Release the WebUI instances before all else as the WebUI may accesses the | 475 // Release the WebUI instances before all else as the WebUI may accesses the |
458 // RenderFrameHost during cleanup. | 476 // RenderFrameHost during cleanup. |
459 ClearAllWebUI(); | 477 ClearAllWebUI(); |
460 | 478 |
461 GetProcess()->RemoveRoute(routing_id_); | 479 GetProcess()->RemoveRoute(routing_id_); |
462 g_routing_id_frame_map.Get().erase( | 480 g_routing_id_frame_map.Get().erase( |
463 RenderFrameHostID(GetProcess()->GetID(), routing_id_)); | 481 RenderFrameHostID(GetProcess()->GetID(), routing_id_)); |
482 #if defined(OS_ANDROID) | |
483 if (overlay_routing_token_) | |
484 g_token_frame_map.Get().erase(*overlay_routing_token_); | |
485 #endif | |
464 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, | 486 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, |
465 base::Bind(&NotifyRenderFrameDetachedOnIO, | 487 base::Bind(&NotifyRenderFrameDetachedOnIO, |
466 GetProcess()->GetID(), routing_id_)); | 488 GetProcess()->GetID(), routing_id_)); |
467 | 489 |
468 site_instance_->RemoveObserver(this); | 490 site_instance_->RemoveObserver(this); |
469 | 491 |
470 if (delegate_ && render_frame_created_) | 492 if (delegate_ && render_frame_created_) |
471 delegate_->RenderFrameDeleted(this); | 493 delegate_->RenderFrameDeleted(this); |
472 | 494 |
473 // If this was the last active frame in the SiteInstance, the | 495 // If this was the last active frame in the SiteInstance, the |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
507 | 529 |
508 int RenderFrameHostImpl::GetRoutingID() { | 530 int RenderFrameHostImpl::GetRoutingID() { |
509 return routing_id_; | 531 return routing_id_; |
510 } | 532 } |
511 | 533 |
512 ui::AXTreeIDRegistry::AXTreeID RenderFrameHostImpl::GetAXTreeID() { | 534 ui::AXTreeIDRegistry::AXTreeID RenderFrameHostImpl::GetAXTreeID() { |
513 return ui::AXTreeIDRegistry::GetInstance()->GetOrCreateAXTreeID( | 535 return ui::AXTreeIDRegistry::GetInstance()->GetOrCreateAXTreeID( |
514 GetProcess()->GetID(), routing_id_); | 536 GetProcess()->GetID(), routing_id_); |
515 } | 537 } |
516 | 538 |
539 #if defined(OS_ANDROID) | |
aelias_OOO_until_Jul13
2017/04/26 23:41:22
Likewise I would prefer OS_ANDROID be removed in r
liberato (no reviews please)
2017/05/02 17:05:12
Done.
| |
540 const base::UnguessableToken& RenderFrameHostImpl::GetOverlayRoutingToken() { | |
541 if (!overlay_routing_token_) { | |
542 overlay_routing_token_ = base::UnguessableToken::Create(); | |
543 g_token_frame_map.Get().emplace(*overlay_routing_token_, this); | |
544 } | |
545 | |
546 return *overlay_routing_token_; | |
547 } | |
548 #endif | |
549 | |
517 SiteInstanceImpl* RenderFrameHostImpl::GetSiteInstance() { | 550 SiteInstanceImpl* RenderFrameHostImpl::GetSiteInstance() { |
518 return site_instance_.get(); | 551 return site_instance_.get(); |
519 } | 552 } |
520 | 553 |
521 RenderProcessHost* RenderFrameHostImpl::GetProcess() { | 554 RenderProcessHost* RenderFrameHostImpl::GetProcess() { |
522 return process_; | 555 return process_; |
523 } | 556 } |
524 | 557 |
525 RenderFrameHostImpl* RenderFrameHostImpl::GetParent() { | 558 RenderFrameHostImpl* RenderFrameHostImpl::GetParent() { |
526 return parent_; | 559 return parent_; |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
811 IPC_MESSAGE_HANDLER(FrameHostMsg_FocusedNodeChanged, OnFocusedNodeChanged) | 844 IPC_MESSAGE_HANDLER(FrameHostMsg_FocusedNodeChanged, OnFocusedNodeChanged) |
812 IPC_MESSAGE_HANDLER(FrameHostMsg_SetHasReceivedUserGesture, | 845 IPC_MESSAGE_HANDLER(FrameHostMsg_SetHasReceivedUserGesture, |
813 OnSetHasReceivedUserGesture) | 846 OnSetHasReceivedUserGesture) |
814 #if BUILDFLAG(USE_EXTERNAL_POPUP_MENU) | 847 #if BUILDFLAG(USE_EXTERNAL_POPUP_MENU) |
815 IPC_MESSAGE_HANDLER(FrameHostMsg_ShowPopup, OnShowPopup) | 848 IPC_MESSAGE_HANDLER(FrameHostMsg_ShowPopup, OnShowPopup) |
816 IPC_MESSAGE_HANDLER(FrameHostMsg_HidePopup, OnHidePopup) | 849 IPC_MESSAGE_HANDLER(FrameHostMsg_HidePopup, OnHidePopup) |
817 #endif | 850 #endif |
818 #if defined(OS_ANDROID) | 851 #if defined(OS_ANDROID) |
819 IPC_MESSAGE_HANDLER(FrameHostMsg_NavigationHandledByEmbedder, | 852 IPC_MESSAGE_HANDLER(FrameHostMsg_NavigationHandledByEmbedder, |
820 OnNavigationHandledByEmbedder) | 853 OnNavigationHandledByEmbedder) |
854 IPC_MESSAGE_HANDLER(FrameHostMsg_RequestOverlayRoutingToken, | |
855 OnRequestOverlayRoutingToken) | |
821 #endif | 856 #endif |
822 IPC_MESSAGE_HANDLER(FrameHostMsg_ShowCreatedWindow, OnShowCreatedWindow) | 857 IPC_MESSAGE_HANDLER(FrameHostMsg_ShowCreatedWindow, OnShowCreatedWindow) |
823 IPC_END_MESSAGE_MAP() | 858 IPC_END_MESSAGE_MAP() |
824 | 859 |
825 // No further actions here, since we may have been deleted. | 860 // No further actions here, since we may have been deleted. |
826 return handled; | 861 return handled; |
827 } | 862 } |
828 | 863 |
829 void RenderFrameHostImpl::OnAssociatedInterfaceRequest( | 864 void RenderFrameHostImpl::OnAssociatedInterfaceRequest( |
830 const std::string& interface_name, | 865 const std::string& interface_name, |
(...skipping 1611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2442 } | 2477 } |
2443 #endif | 2478 #endif |
2444 | 2479 |
2445 #if defined(OS_ANDROID) | 2480 #if defined(OS_ANDROID) |
2446 void RenderFrameHostImpl::OnNavigationHandledByEmbedder() { | 2481 void RenderFrameHostImpl::OnNavigationHandledByEmbedder() { |
2447 if (navigation_handle_) | 2482 if (navigation_handle_) |
2448 navigation_handle_->set_net_error_code(net::ERR_ABORTED); | 2483 navigation_handle_->set_net_error_code(net::ERR_ABORTED); |
2449 | 2484 |
2450 OnDidStopLoading(); | 2485 OnDidStopLoading(); |
2451 } | 2486 } |
2487 | |
2488 void RenderFrameHostImpl::OnRequestOverlayRoutingToken() { | |
2489 // Make sure that we have a token. | |
2490 GetOverlayRoutingToken(); | |
2491 | |
2492 Send(new FrameMsg_SetOverlayRoutingToken(routing_id_, | |
2493 *overlay_routing_token_)); | |
2494 } | |
2452 #endif | 2495 #endif |
2453 | 2496 |
2454 void RenderFrameHostImpl::OnShowCreatedWindow(int pending_widget_routing_id, | 2497 void RenderFrameHostImpl::OnShowCreatedWindow(int pending_widget_routing_id, |
2455 WindowOpenDisposition disposition, | 2498 WindowOpenDisposition disposition, |
2456 const gfx::Rect& initial_rect, | 2499 const gfx::Rect& initial_rect, |
2457 bool user_gesture) { | 2500 bool user_gesture) { |
2458 delegate_->ShowCreatedWindow(GetProcess()->GetID(), pending_widget_routing_id, | 2501 delegate_->ShowCreatedWindow(GetProcess()->GetID(), pending_widget_routing_id, |
2459 disposition, initial_rect, user_gesture); | 2502 disposition, initial_rect, user_gesture); |
2460 } | 2503 } |
2461 | 2504 |
(...skipping 1219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3681 } | 3724 } |
3682 | 3725 |
3683 void RenderFrameHostImpl::ForwardGetInterfaceToRenderFrame( | 3726 void RenderFrameHostImpl::ForwardGetInterfaceToRenderFrame( |
3684 const std::string& interface_name, | 3727 const std::string& interface_name, |
3685 mojo::ScopedMessagePipeHandle pipe) { | 3728 mojo::ScopedMessagePipeHandle pipe) { |
3686 GetRemoteInterfaces()->GetInterface(interface_name, std::move(pipe)); | 3729 GetRemoteInterfaces()->GetInterface(interface_name, std::move(pipe)); |
3687 } | 3730 } |
3688 #endif | 3731 #endif |
3689 | 3732 |
3690 } // namespace content | 3733 } // namespace content |
OLD | NEW |