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 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
415 // Manually call the observer methods for the root frame tree node. It is | 415 // Manually call the observer methods for the root frame tree node. It is |
416 // necessary to manually delete all objects tracking navigations | 416 // necessary to manually delete all objects tracking navigations |
417 // (NavigationHandle, NavigationRequest) for observers to be properly | 417 // (NavigationHandle, NavigationRequest) for observers to be properly |
418 // notified of these navigations stopping before the WebContents is | 418 // notified of these navigations stopping before the WebContents is |
419 // destroyed. | 419 // destroyed. |
420 RenderFrameHostManager* root = GetRenderManager(); | 420 RenderFrameHostManager* root = GetRenderManager(); |
421 | 421 |
422 if (root->pending_frame_host()) { | 422 if (root->pending_frame_host()) { |
423 root->pending_frame_host()->SetRenderFrameCreated(false); | 423 root->pending_frame_host()->SetRenderFrameCreated(false); |
424 root->pending_frame_host()->SetNavigationHandle( | 424 root->pending_frame_host()->SetNavigationHandle( |
425 scoped_ptr<NavigationHandleImpl>()); | 425 std::unique_ptr<NavigationHandleImpl>()); |
426 } | 426 } |
427 root->current_frame_host()->SetRenderFrameCreated(false); | 427 root->current_frame_host()->SetRenderFrameCreated(false); |
428 root->current_frame_host()->SetNavigationHandle( | 428 root->current_frame_host()->SetNavigationHandle( |
429 scoped_ptr<NavigationHandleImpl>()); | 429 std::unique_ptr<NavigationHandleImpl>()); |
430 | 430 |
431 // PlzNavigate: clear up state specific to browser-side navigation. | 431 // PlzNavigate: clear up state specific to browser-side navigation. |
432 if (IsBrowserSideNavigationEnabled()) { | 432 if (IsBrowserSideNavigationEnabled()) { |
433 // Do not update state as the WebContents is being destroyed. | 433 // Do not update state as the WebContents is being destroyed. |
434 frame_tree_.root()->ResetNavigationRequest(true); | 434 frame_tree_.root()->ResetNavigationRequest(true); |
435 if (root->speculative_frame_host()) { | 435 if (root->speculative_frame_host()) { |
436 root->speculative_frame_host()->SetRenderFrameCreated(false); | 436 root->speculative_frame_host()->SetRenderFrameCreated(false); |
437 root->speculative_frame_host()->SetNavigationHandle( | 437 root->speculative_frame_host()->SetNavigationHandle( |
438 scoped_ptr<NavigationHandleImpl>()); | 438 std::unique_ptr<NavigationHandleImpl>()); |
439 } | 439 } |
440 } | 440 } |
441 | 441 |
442 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 442 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
443 FrameDeleted(root->current_frame_host())); | 443 FrameDeleted(root->current_frame_host())); |
444 | 444 |
445 if (root->pending_render_view_host()) { | 445 if (root->pending_render_view_host()) { |
446 FOR_EACH_OBSERVER(WebContentsObserver, | 446 FOR_EACH_OBSERVER(WebContentsObserver, |
447 observers_, | 447 observers_, |
448 RenderViewDeleted(root->pending_render_view_host())); | 448 RenderViewDeleted(root->pending_render_view_host())); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
507 // bit to true. | 507 // bit to true. |
508 new_contents->is_subframe_ = true; | 508 new_contents->is_subframe_ = true; |
509 } | 509 } |
510 new_contents->Init(params); | 510 new_contents->Init(params); |
511 return new_contents; | 511 return new_contents; |
512 } | 512 } |
513 | 513 |
514 // static | 514 // static |
515 std::vector<WebContentsImpl*> WebContentsImpl::GetAllWebContents() { | 515 std::vector<WebContentsImpl*> WebContentsImpl::GetAllWebContents() { |
516 std::vector<WebContentsImpl*> result; | 516 std::vector<WebContentsImpl*> result; |
517 scoped_ptr<RenderWidgetHostIterator> widgets( | 517 std::unique_ptr<RenderWidgetHostIterator> widgets( |
518 RenderWidgetHostImpl::GetRenderWidgetHosts()); | 518 RenderWidgetHostImpl::GetRenderWidgetHosts()); |
519 while (RenderWidgetHost* rwh = widgets->GetNextHost()) { | 519 while (RenderWidgetHost* rwh = widgets->GetNextHost()) { |
520 RenderViewHost* rvh = RenderViewHost::From(rwh); | 520 RenderViewHost* rvh = RenderViewHost::From(rwh); |
521 if (!rvh) | 521 if (!rvh) |
522 continue; | 522 continue; |
523 WebContents* web_contents = WebContents::FromRenderViewHost(rvh); | 523 WebContents* web_contents = WebContents::FromRenderViewHost(rvh); |
524 if (!web_contents) | 524 if (!web_contents) |
525 continue; | 525 continue; |
526 if (web_contents->GetRenderViewHost() != rvh) | 526 if (web_contents->GetRenderViewHost() != rvh) |
527 continue; | 527 continue; |
(...skipping 1616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2144 | 2144 |
2145 return widget_host_view; | 2145 return widget_host_view; |
2146 } | 2146 } |
2147 | 2147 |
2148 void WebContentsImpl::RequestMediaAccessPermission( | 2148 void WebContentsImpl::RequestMediaAccessPermission( |
2149 const MediaStreamRequest& request, | 2149 const MediaStreamRequest& request, |
2150 const MediaResponseCallback& callback) { | 2150 const MediaResponseCallback& callback) { |
2151 if (delegate_) { | 2151 if (delegate_) { |
2152 delegate_->RequestMediaAccessPermission(this, request, callback); | 2152 delegate_->RequestMediaAccessPermission(this, request, callback); |
2153 } else { | 2153 } else { |
2154 callback.Run(MediaStreamDevices(), | 2154 callback.Run(MediaStreamDevices(), MEDIA_DEVICE_FAILED_DUE_TO_SHUTDOWN, |
2155 MEDIA_DEVICE_FAILED_DUE_TO_SHUTDOWN, | 2155 std::unique_ptr<MediaStreamUI>()); |
2156 scoped_ptr<MediaStreamUI>()); | |
2157 } | 2156 } |
2158 } | 2157 } |
2159 | 2158 |
2160 bool WebContentsImpl::CheckMediaAccessPermission(const GURL& security_origin, | 2159 bool WebContentsImpl::CheckMediaAccessPermission(const GURL& security_origin, |
2161 MediaStreamType type) { | 2160 MediaStreamType type) { |
2162 DCHECK(type == MEDIA_DEVICE_AUDIO_CAPTURE || | 2161 DCHECK(type == MEDIA_DEVICE_AUDIO_CAPTURE || |
2163 type == MEDIA_DEVICE_VIDEO_CAPTURE); | 2162 type == MEDIA_DEVICE_VIDEO_CAPTURE); |
2164 return delegate_ && | 2163 return delegate_ && |
2165 delegate_->CheckMediaAccessPermission(this, security_origin, type); | 2164 delegate_->CheckMediaAccessPermission(this, security_origin, type); |
2166 } | 2165 } |
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2701 DownloadManager* dlm = | 2700 DownloadManager* dlm = |
2702 BrowserContext::GetDownloadManager(GetBrowserContext()); | 2701 BrowserContext::GetDownloadManager(GetBrowserContext()); |
2703 if (!dlm) | 2702 if (!dlm) |
2704 return; | 2703 return; |
2705 int64_t post_id = -1; | 2704 int64_t post_id = -1; |
2706 if (is_main_frame) { | 2705 if (is_main_frame) { |
2707 const NavigationEntry* entry = controller_.GetLastCommittedEntry(); | 2706 const NavigationEntry* entry = controller_.GetLastCommittedEntry(); |
2708 if (entry) | 2707 if (entry) |
2709 post_id = entry->GetPostID(); | 2708 post_id = entry->GetPostID(); |
2710 } | 2709 } |
2711 scoped_ptr<DownloadUrlParameters> params( | 2710 std::unique_ptr<DownloadUrlParameters> params( |
2712 DownloadUrlParameters::FromWebContents(this, url)); | 2711 DownloadUrlParameters::FromWebContents(this, url)); |
2713 params->set_referrer(referrer); | 2712 params->set_referrer(referrer); |
2714 params->set_post_id(post_id); | 2713 params->set_post_id(post_id); |
2715 if (post_id >= 0) | 2714 if (post_id >= 0) |
2716 params->set_method("POST"); | 2715 params->set_method("POST"); |
2717 params->set_prompt(true); | 2716 params->set_prompt(true); |
2718 | 2717 |
2719 if (headers.empty()) { | 2718 if (headers.empty()) { |
2720 params->set_prefer_cache(true); | 2719 params->set_prefer_cache(true); |
2721 } else { | 2720 } else { |
(...skipping 1452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4174 // current document. | 4173 // current document. |
4175 // | 4174 // |
4176 // TODO(dmazzoni): do this using a WebContentsObserver. | 4175 // TODO(dmazzoni): do this using a WebContentsObserver. |
4177 BrowserAccessibilityManager* manager = | 4176 BrowserAccessibilityManager* manager = |
4178 frame_tree_node->current_frame_host()->browser_accessibility_manager(); | 4177 frame_tree_node->current_frame_host()->browser_accessibility_manager(); |
4179 if (manager) | 4178 if (manager) |
4180 manager->UserIsNavigatingAway(); | 4179 manager->UserIsNavigatingAway(); |
4181 } | 4180 } |
4182 | 4181 |
4183 void WebContentsImpl::DidStopLoading() { | 4182 void WebContentsImpl::DidStopLoading() { |
4184 scoped_ptr<LoadNotificationDetails> details; | 4183 std::unique_ptr<LoadNotificationDetails> details; |
4185 | 4184 |
4186 // Use the last committed entry rather than the active one, in case a | 4185 // Use the last committed entry rather than the active one, in case a |
4187 // pending entry has been created. | 4186 // pending entry has been created. |
4188 NavigationEntry* entry = controller_.GetLastCommittedEntry(); | 4187 NavigationEntry* entry = controller_.GetLastCommittedEntry(); |
4189 Navigator* navigator = frame_tree_.root()->navigator(); | 4188 Navigator* navigator = frame_tree_.root()->navigator(); |
4190 | 4189 |
4191 // An entry may not exist for a stop when loading an initial blank page or | 4190 // An entry may not exist for a stop when loading an initial blank page or |
4192 // if an iframe injected by script into a blank page finishes loading. | 4191 // if an iframe injected by script into a blank page finishes loading. |
4193 if (entry) { | 4192 if (entry) { |
4194 base::TimeDelta elapsed = | 4193 base::TimeDelta elapsed = |
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4578 void WebContentsImpl::NotifyMainFrameSwappedFromRenderManager( | 4577 void WebContentsImpl::NotifyMainFrameSwappedFromRenderManager( |
4579 RenderViewHost* old_host, | 4578 RenderViewHost* old_host, |
4580 RenderViewHost* new_host) { | 4579 RenderViewHost* new_host) { |
4581 NotifyViewSwapped(old_host, new_host); | 4580 NotifyViewSwapped(old_host, new_host); |
4582 } | 4581 } |
4583 | 4582 |
4584 NavigationControllerImpl& WebContentsImpl::GetControllerForRenderManager() { | 4583 NavigationControllerImpl& WebContentsImpl::GetControllerForRenderManager() { |
4585 return GetController(); | 4584 return GetController(); |
4586 } | 4585 } |
4587 | 4586 |
4588 scoped_ptr<WebUIImpl> WebContentsImpl::CreateWebUIForRenderFrameHost( | 4587 std::unique_ptr<WebUIImpl> WebContentsImpl::CreateWebUIForRenderFrameHost( |
4589 const GURL& url) { | 4588 const GURL& url) { |
4590 return scoped_ptr<WebUIImpl>(static_cast<WebUIImpl*>(CreateWebUI( | 4589 return std::unique_ptr<WebUIImpl>( |
4591 url, std::string()))); | 4590 static_cast<WebUIImpl*>(CreateWebUI(url, std::string()))); |
4592 } | 4591 } |
4593 | 4592 |
4594 NavigationEntry* | 4593 NavigationEntry* |
4595 WebContentsImpl::GetLastCommittedNavigationEntryForRenderManager() { | 4594 WebContentsImpl::GetLastCommittedNavigationEntryForRenderManager() { |
4596 return controller_.GetLastCommittedEntry(); | 4595 return controller_.GetLastCommittedEntry(); |
4597 } | 4596 } |
4598 | 4597 |
4599 void WebContentsImpl::CreateRenderWidgetHostViewForRenderManager( | 4598 void WebContentsImpl::CreateRenderWidgetHostViewForRenderManager( |
4600 RenderViewHost* render_view_host) { | 4599 RenderViewHost* render_view_host) { |
4601 RenderWidgetHostViewBase* rwh_view = nullptr; | 4600 RenderWidgetHostViewBase* rwh_view = nullptr; |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4889 else | 4888 else |
4890 WasHidden(); | 4889 WasHidden(); |
4891 } | 4890 } |
4892 | 4891 |
4893 void WebContentsImpl::SetJavaScriptDialogManagerForTesting( | 4892 void WebContentsImpl::SetJavaScriptDialogManagerForTesting( |
4894 JavaScriptDialogManager* dialog_manager) { | 4893 JavaScriptDialogManager* dialog_manager) { |
4895 dialog_manager_ = dialog_manager; | 4894 dialog_manager_ = dialog_manager; |
4896 } | 4895 } |
4897 | 4896 |
4898 } // namespace content | 4897 } // namespace content |
OLD | NEW |