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 557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
568 for (auto& observer : observers_) | 568 for (auto& observer : observers_) |
569 observer.ResetWebContents(); | 569 observer.ResetWebContents(); |
570 | 570 |
571 SetDelegate(NULL); | 571 SetDelegate(NULL); |
572 } | 572 } |
573 | 573 |
574 WebContentsImpl* WebContentsImpl::CreateWithOpener( | 574 WebContentsImpl* WebContentsImpl::CreateWithOpener( |
575 const WebContents::CreateParams& params, | 575 const WebContents::CreateParams& params, |
576 FrameTreeNode* opener) { | 576 FrameTreeNode* opener) { |
577 TRACE_EVENT0("browser", "WebContentsImpl::CreateWithOpener"); | 577 TRACE_EVENT0("browser", "WebContentsImpl::CreateWithOpener"); |
| 578 LOG(ERROR) << "WCI::CreateWithOpener: " |
| 579 << " source_wc:" << params.source_web_contents |
| 580 << " opener:" << opener |
| 581 << " disposition:" << (int) params.disposition |
| 582 << " context_menu:" << params.created_from_context_menu; |
578 WebContentsImpl* new_contents = new WebContentsImpl(params.browser_context); | 583 WebContentsImpl* new_contents = new WebContentsImpl(params.browser_context); |
579 | 584 |
580 FrameTreeNode* new_root = new_contents->GetFrameTree()->root(); | 585 FrameTreeNode* new_root = new_contents->GetFrameTree()->root(); |
581 | 586 |
582 if (!params.opener_suppressed && opener) { | 587 if (!params.opener_suppressed && opener) { |
583 new_root->SetOpener(opener); | 588 new_root->SetOpener(opener); |
584 new_contents->created_with_opener_ = true; | 589 new_contents->created_with_opener_ = true; |
585 } | 590 } |
586 | 591 |
587 // If the opener is sandboxed, a new popup must inherit the opener's sandbox | 592 // If the opener is sandboxed, a new popup must inherit the opener's sandbox |
(...skipping 18 matching lines...) Expand all Loading... |
606 | 611 |
607 if (params.guest_delegate) { | 612 if (params.guest_delegate) { |
608 // This makes |new_contents| act as a guest. | 613 // This makes |new_contents| act as a guest. |
609 // For more info, see comment above class BrowserPluginGuest. | 614 // For more info, see comment above class BrowserPluginGuest. |
610 BrowserPluginGuest::Create(new_contents, params.guest_delegate); | 615 BrowserPluginGuest::Create(new_contents, params.guest_delegate); |
611 // We are instantiating a WebContents for browser plugin. Set its subframe | 616 // We are instantiating a WebContents for browser plugin. Set its subframe |
612 // bit to true. | 617 // bit to true. |
613 new_contents->is_subframe_ = true; | 618 new_contents->is_subframe_ = true; |
614 } | 619 } |
615 new_contents->Init(params); | 620 new_contents->Init(params); |
| 621 |
| 622 if (params.source_web_contents && |
| 623 (params.created_from_context_menu || opener)) { |
| 624 LOG(ERROR) << "WCI::CreateWithOpener: " |
| 625 << " dispatching notification"; |
| 626 WebContentsImpl* opener_contents = |
| 627 static_cast<WebContentsImpl*>(params.source_web_contents); |
| 628 RenderFrameHost* opener_rfh = RenderFrameHost::FromID( |
| 629 params.opener_render_process_id, params.opener_render_frame_id); |
| 630 for (auto& observer : opener_contents->observers_) { |
| 631 observer.DidOpenRequestedURL(new_contents, |
| 632 opener_rfh ? opener_rfh |
| 633 : opener_contents->GetMainFrame(), |
| 634 params.target_url, |
| 635 params.referrer, |
| 636 params.disposition, params.transition); |
| 637 } |
| 638 } |
| 639 |
616 return new_contents; | 640 return new_contents; |
617 } | 641 } |
618 | 642 |
619 // static | 643 // static |
620 std::vector<WebContentsImpl*> WebContentsImpl::GetAllWebContents() { | 644 std::vector<WebContentsImpl*> WebContentsImpl::GetAllWebContents() { |
621 std::vector<WebContentsImpl*> result; | 645 std::vector<WebContentsImpl*> result; |
622 std::unique_ptr<RenderWidgetHostIterator> widgets( | 646 std::unique_ptr<RenderWidgetHostIterator> widgets( |
623 RenderWidgetHostImpl::GetRenderWidgetHosts()); | 647 RenderWidgetHostImpl::GetRenderWidgetHosts()); |
624 while (RenderWidgetHost* rwh = widgets->GetNextHost()) { | 648 while (RenderWidgetHost* rwh = widgets->GetNextHost()) { |
625 RenderViewHost* rvh = RenderViewHost::From(rwh); | 649 RenderViewHost* rvh = RenderViewHost::From(rwh); |
(...skipping 1423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2049 create_params.main_frame_widget_routing_id = main_frame_widget_route_id; | 2073 create_params.main_frame_widget_routing_id = main_frame_widget_route_id; |
2050 create_params.main_frame_name = params.frame_name; | 2074 create_params.main_frame_name = params.frame_name; |
2051 create_params.opener_render_process_id = render_process_id; | 2075 create_params.opener_render_process_id = render_process_id; |
2052 create_params.opener_render_frame_id = params.opener_render_frame_id; | 2076 create_params.opener_render_frame_id = params.opener_render_frame_id; |
2053 create_params.opener_suppressed = params.opener_suppressed; | 2077 create_params.opener_suppressed = params.opener_suppressed; |
2054 if (params.disposition == WindowOpenDisposition::NEW_BACKGROUND_TAB) | 2078 if (params.disposition == WindowOpenDisposition::NEW_BACKGROUND_TAB) |
2055 create_params.initially_hidden = true; | 2079 create_params.initially_hidden = true; |
2056 create_params.renderer_initiated_creation = | 2080 create_params.renderer_initiated_creation = |
2057 main_frame_route_id != MSG_ROUTING_NONE; | 2081 main_frame_route_id != MSG_ROUTING_NONE; |
2058 | 2082 |
| 2083 create_params.source_web_contents = this; |
| 2084 create_params.target_url = params.target_url; |
| 2085 create_params.disposition = params.disposition; |
| 2086 create_params.referrer = params.referrer; |
| 2087 // TODO(nasko): Check what page transition is needed. |
| 2088 create_params.transition = ui::PAGE_TRANSITION_LINK; |
| 2089 |
2059 WebContentsImpl* new_contents = NULL; | 2090 WebContentsImpl* new_contents = NULL; |
2060 if (!is_guest) { | 2091 if (!is_guest) { |
2061 create_params.context = view_->GetNativeView(); | 2092 create_params.context = view_->GetNativeView(); |
2062 create_params.initial_size = GetContainerBounds().size(); | 2093 create_params.initial_size = GetContainerBounds().size(); |
2063 new_contents = static_cast<WebContentsImpl*>( | 2094 new_contents = static_cast<WebContentsImpl*>( |
2064 WebContents::Create(create_params)); | 2095 WebContents::Create(create_params)); |
2065 } else { | 2096 } else { |
2066 new_contents = GetBrowserPluginGuest()->CreateNewGuestWindow(create_params); | 2097 new_contents = GetBrowserPluginGuest()->CreateNewGuestWindow(create_params); |
2067 } | 2098 } |
2068 new_contents->GetController().SetSessionStorageNamespace( | 2099 new_contents->GetController().SetSessionStorageNamespace( |
(...skipping 1219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3288 | 3319 |
3289 void WebContentsImpl::DidStartNavigationToPendingEntry(const GURL& url, | 3320 void WebContentsImpl::DidStartNavigationToPendingEntry(const GURL& url, |
3290 ReloadType reload_type) { | 3321 ReloadType reload_type) { |
3291 // Notify observers about navigation. | 3322 // Notify observers about navigation. |
3292 for (auto& observer : observers_) | 3323 for (auto& observer : observers_) |
3293 observer.DidStartNavigationToPendingEntry(url, reload_type); | 3324 observer.DidStartNavigationToPendingEntry(url, reload_type); |
3294 } | 3325 } |
3295 | 3326 |
3296 void WebContentsImpl::RequestOpenURL(RenderFrameHostImpl* render_frame_host, | 3327 void WebContentsImpl::RequestOpenURL(RenderFrameHostImpl* render_frame_host, |
3297 const OpenURLParams& params) { | 3328 const OpenURLParams& params) { |
3298 // OpenURL can blow away the source RFH. Use the process/frame routing ID as a | 3329 OpenURL(params); |
3299 // weak pointer of sorts. | |
3300 const int32_t process_id = render_frame_host->GetProcess()->GetID(); | |
3301 const int32_t frame_id = render_frame_host->GetRoutingID(); | |
3302 | |
3303 WebContents* new_contents = OpenURL(params); | |
3304 | |
3305 if (new_contents && RenderFrameHost::FromID(process_id, frame_id)) { | |
3306 // Notify observers. | |
3307 for (auto& observer : observers_) { | |
3308 observer.DidOpenRequestedURL(new_contents, render_frame_host, params.url, | |
3309 params.referrer, params.disposition, | |
3310 params.transition); | |
3311 } | |
3312 } | |
3313 } | 3330 } |
3314 | 3331 |
3315 bool WebContentsImpl::ShouldTransferNavigation(bool is_main_frame_navigation) { | 3332 bool WebContentsImpl::ShouldTransferNavigation(bool is_main_frame_navigation) { |
3316 if (!delegate_) | 3333 if (!delegate_) |
3317 return true; | 3334 return true; |
3318 return delegate_->ShouldTransferNavigation(is_main_frame_navigation); | 3335 return delegate_->ShouldTransferNavigation(is_main_frame_navigation); |
3319 } | 3336 } |
3320 | 3337 |
3321 bool WebContentsImpl::ShouldPreserveAbortedURLs() { | 3338 bool WebContentsImpl::ShouldPreserveAbortedURLs() { |
3322 if (!delegate_) | 3339 if (!delegate_) |
(...skipping 1864 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5187 dialog_manager_ = dialog_manager; | 5204 dialog_manager_ = dialog_manager; |
5188 } | 5205 } |
5189 | 5206 |
5190 void WebContentsImpl::RemoveBindingSet(const std::string& interface_name) { | 5207 void WebContentsImpl::RemoveBindingSet(const std::string& interface_name) { |
5191 auto it = binding_sets_.find(interface_name); | 5208 auto it = binding_sets_.find(interface_name); |
5192 if (it != binding_sets_.end()) | 5209 if (it != binding_sets_.end()) |
5193 binding_sets_.erase(it); | 5210 binding_sets_.erase(it); |
5194 } | 5211 } |
5195 | 5212 |
5196 } // namespace content | 5213 } // namespace content |
OLD | NEW |