| 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/devtools/render_frame_devtools_agent_host.h" | 5 #include "content/browser/devtools/render_frame_devtools_agent_host.h" |
| 6 | 6 |
| 7 #include <tuple> | 7 #include <tuple> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/guid.h" | 10 #include "base/guid.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 #include "content/browser/frame_host/navigation_handle_impl.h" | 36 #include "content/browser/frame_host/navigation_handle_impl.h" |
| 37 #include "content/browser/frame_host/render_frame_host_impl.h" | 37 #include "content/browser/frame_host/render_frame_host_impl.h" |
| 38 #include "content/browser/renderer_host/input/input_router_impl.h" | 38 #include "content/browser/renderer_host/input/input_router_impl.h" |
| 39 #include "content/browser/renderer_host/render_process_host_impl.h" | 39 #include "content/browser/renderer_host/render_process_host_impl.h" |
| 40 #include "content/browser/renderer_host/render_view_host_impl.h" | 40 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 41 #include "content/browser/site_instance_impl.h" | 41 #include "content/browser/site_instance_impl.h" |
| 42 #include "content/browser/web_contents/web_contents_impl.h" | 42 #include "content/browser/web_contents/web_contents_impl.h" |
| 43 #include "content/common/view_messages.h" | 43 #include "content/common/view_messages.h" |
| 44 #include "content/public/browser/browser_context.h" | 44 #include "content/public/browser/browser_context.h" |
| 45 #include "content/public/browser/content_browser_client.h" | 45 #include "content/public/browser/content_browser_client.h" |
| 46 #include "content/public/browser/navigation_handle.h" |
| 46 #include "content/public/browser/render_widget_host_iterator.h" | 47 #include "content/public/browser/render_widget_host_iterator.h" |
| 47 #include "content/public/browser/web_contents_delegate.h" | 48 #include "content/public/browser/web_contents_delegate.h" |
| 48 #include "content/public/common/browser_side_navigation_policy.h" | 49 #include "content/public/common/browser_side_navigation_policy.h" |
| 49 | 50 |
| 50 #if defined(OS_ANDROID) | 51 #if defined(OS_ANDROID) |
| 51 #include "content/public/browser/render_widget_host_view.h" | 52 #include "content/public/browser/render_widget_host_view.h" |
| 52 #include "device/power_save_blocker/power_save_blocker.h" | 53 #include "device/power_save_blocker/power_save_blocker.h" |
| 53 #endif | 54 #endif |
| 54 | 55 |
| 55 namespace content { | 56 namespace content { |
| (...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 629 } | 630 } |
| 630 } | 631 } |
| 631 DCHECK(CheckConsistency()); | 632 DCHECK(CheckConsistency()); |
| 632 } | 633 } |
| 633 | 634 |
| 634 void RenderFrameDevToolsAgentHost::DidFinishNavigation( | 635 void RenderFrameDevToolsAgentHost::DidFinishNavigation( |
| 635 NavigationHandle* navigation_handle) { | 636 NavigationHandle* navigation_handle) { |
| 636 // CommitPending may destruct |this|. | 637 // CommitPending may destruct |this|. |
| 637 scoped_refptr<RenderFrameDevToolsAgentHost> protect(this); | 638 scoped_refptr<RenderFrameDevToolsAgentHost> protect(this); |
| 638 | 639 |
| 639 if (!IsBrowserSideNavigationEnabled()) | 640 if (!IsBrowserSideNavigationEnabled()) { |
| 641 if (navigation_handle->IsErrorPage()) { |
| 642 if (pending_ && |
| 643 pending_->host() == navigation_handle->GetRenderFrameHost()) { |
| 644 DiscardPending(); |
| 645 } |
| 646 } else if (navigation_handle->HasCommitted()) { |
| 647 if (pending_ && |
| 648 pending_->host() == navigation_handle->GetRenderFrameHost()) { |
| 649 CommitPending(); |
| 650 } |
| 651 if (session()) |
| 652 protocol::TargetHandler::FromSession(session())->UpdateServiceWorkers(); |
| 653 } |
| 654 DCHECK(CheckConsistency()); |
| 640 return; | 655 return; |
| 656 } |
| 641 | 657 |
| 642 // If the navigation is not tracked, return; | 658 // If the navigation is not tracked, return; |
| 643 if (navigating_handles_.count(navigation_handle) == 0) | 659 if (navigating_handles_.count(navigation_handle) == 0) |
| 644 return; | 660 return; |
| 645 | 661 |
| 646 // Now that the navigation is finished, remove the handle from the list of | 662 // Now that the navigation is finished, remove the handle from the list of |
| 647 // navigating handles. | 663 // navigating handles. |
| 648 navigating_handles_.erase(navigation_handle); | 664 navigating_handles_.erase(navigation_handle); |
| 649 | 665 |
| 650 if (pending_handle_ == navigation_handle) { | 666 if (pending_handle_ == navigation_handle) { |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 865 DCHECK(CheckConsistency()); | 881 DCHECK(CheckConsistency()); |
| 866 } | 882 } |
| 867 | 883 |
| 868 void RenderFrameDevToolsAgentHost::DidDetachInterstitialPage() { | 884 void RenderFrameDevToolsAgentHost::DidDetachInterstitialPage() { |
| 869 protocol::PageHandler* page_handler = | 885 protocol::PageHandler* page_handler = |
| 870 session() ? protocol::PageHandler::FromSession(session()) : nullptr; | 886 session() ? protocol::PageHandler::FromSession(session()) : nullptr; |
| 871 if (page_handler) | 887 if (page_handler) |
| 872 page_handler->DidDetachInterstitialPage(); | 888 page_handler->DidDetachInterstitialPage(); |
| 873 } | 889 } |
| 874 | 890 |
| 875 void RenderFrameDevToolsAgentHost::DidCommitProvisionalLoadForFrame( | |
| 876 RenderFrameHost* render_frame_host, | |
| 877 const GURL& url, | |
| 878 ui::PageTransition transition_type) { | |
| 879 // CommitPending may destruct |this|. | |
| 880 scoped_refptr<RenderFrameDevToolsAgentHost> protect(this); | |
| 881 | |
| 882 if (IsBrowserSideNavigationEnabled()) | |
| 883 return; | |
| 884 if (pending_ && pending_->host() == render_frame_host) | |
| 885 CommitPending(); | |
| 886 DCHECK(CheckConsistency()); | |
| 887 if (session()) | |
| 888 protocol::TargetHandler::FromSession(session())->UpdateServiceWorkers(); | |
| 889 } | |
| 890 | |
| 891 void RenderFrameDevToolsAgentHost::DidFailProvisionalLoad( | |
| 892 RenderFrameHost* render_frame_host, | |
| 893 const GURL& validated_url, | |
| 894 int error_code, | |
| 895 const base::string16& error_description, | |
| 896 bool was_ignored_by_handler) { | |
| 897 if (IsBrowserSideNavigationEnabled()) | |
| 898 return; | |
| 899 if (pending_ && pending_->host() == render_frame_host) | |
| 900 DiscardPending(); | |
| 901 DCHECK(CheckConsistency()); | |
| 902 } | |
| 903 | |
| 904 void RenderFrameDevToolsAgentHost::WasShown() { | 891 void RenderFrameDevToolsAgentHost::WasShown() { |
| 905 CreatePowerSaveBlocker(); | 892 CreatePowerSaveBlocker(); |
| 906 } | 893 } |
| 907 | 894 |
| 908 void RenderFrameDevToolsAgentHost::WasHidden() { | 895 void RenderFrameDevToolsAgentHost::WasHidden() { |
| 909 #if defined(OS_ANDROID) | 896 #if defined(OS_ANDROID) |
| 910 power_save_blocker_.reset(); | 897 power_save_blocker_.reset(); |
| 911 #endif | 898 #endif |
| 912 } | 899 } |
| 913 | 900 |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1165 RenderFrameHost* host) { | 1152 RenderFrameHost* host) { |
| 1166 return (current_ && current_->host() == host) || | 1153 return (current_ && current_->host() == host) || |
| 1167 (pending_ && pending_->host() == host); | 1154 (pending_ && pending_->host() == host); |
| 1168 } | 1155 } |
| 1169 | 1156 |
| 1170 bool RenderFrameDevToolsAgentHost::IsChildFrame() { | 1157 bool RenderFrameDevToolsAgentHost::IsChildFrame() { |
| 1171 return current_ && current_->host()->GetParent(); | 1158 return current_ && current_->host()->GetParent(); |
| 1172 } | 1159 } |
| 1173 | 1160 |
| 1174 } // namespace content | 1161 } // namespace content |
| OLD | NEW |