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