| 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/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| (...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 499 if (!web_contents()) | 499 if (!web_contents()) |
| 500 return; | 500 return; |
| 501 | 501 |
| 502 frame_trace_recorder_.reset(new DevToolsFrameTraceRecorder()); | 502 frame_trace_recorder_.reset(new DevToolsFrameTraceRecorder()); |
| 503 #if defined(OS_ANDROID) | 503 #if defined(OS_ANDROID) |
| 504 power_save_blocker_.reset(static_cast<PowerSaveBlockerImpl*>( | 504 power_save_blocker_.reset(static_cast<PowerSaveBlockerImpl*>( |
| 505 CreatePowerSaveBlocker( | 505 CreatePowerSaveBlocker( |
| 506 PowerSaveBlocker::kPowerSaveBlockPreventDisplaySleep, | 506 PowerSaveBlocker::kPowerSaveBlockPreventDisplaySleep, |
| 507 PowerSaveBlocker::kReasonOther, "DevTools") | 507 PowerSaveBlocker::kReasonOther, "DevTools") |
| 508 .release())); | 508 .release())); |
| 509 power_save_blocker_->InitDisplaySleepBlocker(web_contents()); | 509 if (web_contents()->GetNativeView()) { |
| 510 view_weak_factory_.reset(new base::WeakPtrFactory<ui::ViewAndroid>( |
| 511 web_contents()->GetNativeView())); |
| 512 power_save_blocker_->InitDisplaySleepBlocker( |
| 513 view_weak_factory_->GetWeakPtr()); |
| 514 } |
| 510 #endif | 515 #endif |
| 511 | 516 |
| 512 // TODO(kaznacheev): Move this call back to DevToolsManager when | 517 // TODO(kaznacheev): Move this call back to DevToolsManager when |
| 513 // extensions::ProcessManager no longer relies on this notification. | 518 // extensions::ProcessManager no longer relies on this notification. |
| 514 DevToolsAgentHostImpl::NotifyCallbacks(this, true); | 519 DevToolsAgentHostImpl::NotifyCallbacks(this, true); |
| 515 } | 520 } |
| 516 | 521 |
| 517 void RenderFrameDevToolsAgentHost::OnClientDetached() { | 522 void RenderFrameDevToolsAgentHost::OnClientDetached() { |
| 518 #if defined(OS_ANDROID) | 523 #if defined(OS_ANDROID) |
| 519 power_save_blocker_.reset(); | 524 power_save_blocker_.reset(); |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 746 const GURL& validated_url, | 751 const GURL& validated_url, |
| 747 int error_code, | 752 int error_code, |
| 748 const base::string16& error_description, | 753 const base::string16& error_description, |
| 749 bool was_ignored_by_handler) { | 754 bool was_ignored_by_handler) { |
| 750 if (IsBrowserSideNavigationEnabled()) | 755 if (IsBrowserSideNavigationEnabled()) |
| 751 return; | 756 return; |
| 752 if (pending_ && pending_->host() == render_frame_host) | 757 if (pending_ && pending_->host() == render_frame_host) |
| 753 DiscardPending(); | 758 DiscardPending(); |
| 754 } | 759 } |
| 755 | 760 |
| 761 void RenderFrameDevToolsAgentHost::WebContentsDestroyed() { |
| 762 #if defined(OS_ANDROID) |
| 763 view_weak_factory_.reset(); |
| 764 #endif |
| 765 } |
| 766 |
| 756 void RenderFrameDevToolsAgentHost:: | 767 void RenderFrameDevToolsAgentHost:: |
| 757 DispatchBufferedProtocolMessagesIfNecessary() { | 768 DispatchBufferedProtocolMessagesIfNecessary() { |
| 758 if (navigating_handles_.empty() && | 769 if (navigating_handles_.empty() && |
| 759 in_navigation_protocol_message_buffer_.size()) { | 770 in_navigation_protocol_message_buffer_.size()) { |
| 760 DCHECK(current_); | 771 DCHECK(current_); |
| 761 for (const auto& pair : in_navigation_protocol_message_buffer_) { | 772 for (const auto& pair : in_navigation_protocol_message_buffer_) { |
| 762 current_->DispatchProtocolMessage( | 773 current_->DispatchProtocolMessage( |
| 763 pair.second.session_id, pair.first, pair.second.method, | 774 pair.second.session_id, pair.first, pair.second.method, |
| 764 pair.second.message); | 775 pair.second.message); |
| 765 } | 776 } |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 911 RenderFrameHost* host) { | 922 RenderFrameHost* host) { |
| 912 return (current_ && current_->host() == host) || | 923 return (current_ && current_->host() == host) || |
| 913 (pending_ && pending_->host() == host); | 924 (pending_ && pending_->host() == host); |
| 914 } | 925 } |
| 915 | 926 |
| 916 bool RenderFrameDevToolsAgentHost::IsChildFrame() { | 927 bool RenderFrameDevToolsAgentHost::IsChildFrame() { |
| 917 return current_ && current_->host()->GetParent(); | 928 return current_ && current_->host()->GetParent(); |
| 918 } | 929 } |
| 919 | 930 |
| 920 } // namespace content | 931 } // namespace content |
| OLD | NEW |