Chromium Code Reviews| 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_view_devtools_agent_host.h" | 5 #include "content/browser/devtools/render_view_devtools_agent_host.h" |
| 6 | 6 |
| 7 #include "base/base64.h" | 7 #include "base/base64.h" |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "content/browser/child_process_security_policy_impl.h" | 10 #include "content/browser/child_process_security_policy_impl.h" |
| 11 #include "content/browser/devtools/devtools_manager_impl.h" | 11 #include "content/browser/devtools/devtools_manager_impl.h" |
| 12 #include "content/browser/devtools/devtools_protocol.h" | 12 #include "content/browser/devtools/devtools_protocol.h" |
| 13 #include "content/browser/devtools/devtools_protocol_constants.h" | |
| 13 #include "content/browser/devtools/renderer_overrides_handler.h" | 14 #include "content/browser/devtools/renderer_overrides_handler.h" |
| 14 #include "content/browser/renderer_host/render_process_host_impl.h" | 15 #include "content/browser/renderer_host/render_process_host_impl.h" |
| 15 #include "content/browser/renderer_host/render_view_host_impl.h" | 16 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 16 #include "content/browser/site_instance_impl.h" | 17 #include "content/browser/site_instance_impl.h" |
| 17 #include "content/browser/web_contents/web_contents_impl.h" | 18 #include "content/browser/web_contents/web_contents_impl.h" |
| 18 #include "content/common/devtools_messages.h" | 19 #include "content/common/devtools_messages.h" |
| 19 #include "content/public/browser/content_browser_client.h" | 20 #include "content/public/browser/content_browser_client.h" |
| 20 #include "content/public/browser/notification_service.h" | 21 #include "content/public/browser/notification_service.h" |
| 21 #include "content/public/browser/notification_types.h" | 22 #include "content/public/browser/notification_types.h" |
| 22 #include "content/public/browser/render_widget_host_view.h" | 23 #include "content/public/browser/render_widget_host_view.h" |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 41 if (rvh == (*it)->render_view_host()) | 42 if (rvh == (*it)->render_view_host()) |
| 42 return *it; | 43 return *it; |
| 43 } | 44 } |
| 44 return NULL; | 45 return NULL; |
| 45 } | 46 } |
| 46 | 47 |
| 47 } // namespace | 48 } // namespace |
| 48 | 49 |
| 49 using WebKit::WebDevToolsAgent; | 50 using WebKit::WebDevToolsAgent; |
| 50 | 51 |
| 51 class DevToolsAgentHostRvhObserver : public RenderViewHostObserver { | 52 class RenderViewDevToolsAgentHost::DevToolsAgentHostRvhObserver |
|
pfeldman
2013/03/21 06:30:08
Why did this change?
Vladislav Kaznacheev
2013/03/21 07:24:02
yurys asked me to do that earlier in this review (
| |
| 53 : public RenderViewHostObserver { | |
| 52 public: | 54 public: |
| 53 DevToolsAgentHostRvhObserver(RenderViewHost* rvh, | 55 DevToolsAgentHostRvhObserver(RenderViewHost* rvh, |
| 54 RenderViewDevToolsAgentHost* agent_host) | 56 RenderViewDevToolsAgentHost* agent_host) |
| 55 : RenderViewHostObserver(rvh), | 57 : RenderViewHostObserver(rvh), |
| 56 agent_host_(agent_host) { | 58 agent_host_(agent_host) { |
| 57 } | 59 } |
| 58 virtual ~DevToolsAgentHostRvhObserver() {} | 60 virtual ~DevToolsAgentHostRvhObserver() {} |
| 59 | 61 |
| 60 // RenderViewHostObserver overrides. | 62 // RenderViewHostObserver overrides. |
| 61 virtual void RenderViewHostDestroyed(RenderViewHost* rvh) OVERRIDE { | 63 virtual void RenderViewHostDestroyed(RenderViewHost* rvh) OVERRIDE { |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 264 return; | 266 return; |
| 265 | 267 |
| 266 if (render_view_host_ == dest_rvh && static_cast<RenderViewHostImpl*>( | 268 if (render_view_host_ == dest_rvh && static_cast<RenderViewHostImpl*>( |
| 267 render_view_host_)->render_view_termination_status() == | 269 render_view_host_)->render_view_termination_status() == |
| 268 base::TERMINATION_STATUS_STILL_RUNNING) | 270 base::TERMINATION_STATUS_STILL_RUNNING) |
| 269 return; | 271 return; |
| 270 DisconnectRenderViewHost(); | 272 DisconnectRenderViewHost(); |
| 271 ConnectRenderViewHost(dest_rvh, true); | 273 ConnectRenderViewHost(dest_rvh, true); |
| 272 } | 274 } |
| 273 | 275 |
| 276 void RenderViewDevToolsAgentHost::RenderViewGone( | |
| 277 base::TerminationStatus status) { | |
| 278 switch(status) { | |
| 279 case base::TERMINATION_STATUS_ABNORMAL_TERMINATION: | |
| 280 case base::TERMINATION_STATUS_PROCESS_WAS_KILLED: | |
| 281 case base::TERMINATION_STATUS_PROCESS_CRASHED: | |
| 282 RenderViewCrashed(); | |
| 283 break; | |
| 284 default: | |
| 285 break; | |
| 286 } | |
| 287 } | |
| 288 | |
| 274 void RenderViewDevToolsAgentHost::ConnectRenderViewHost(RenderViewHost* rvh, | 289 void RenderViewDevToolsAgentHost::ConnectRenderViewHost(RenderViewHost* rvh, |
| 275 bool reattach) { | 290 bool reattach) { |
| 276 render_view_host_ = rvh; | 291 render_view_host_ = rvh; |
| 277 rvh_observer_.reset(new DevToolsAgentHostRvhObserver(rvh, this)); | 292 rvh_observer_.reset(new DevToolsAgentHostRvhObserver(rvh, this)); |
| 278 if (reattach) | 293 if (reattach) |
| 279 Reattach(state_); | 294 Reattach(state_); |
| 280 } | 295 } |
| 281 | 296 |
| 282 void RenderViewDevToolsAgentHost::DisconnectRenderViewHost() { | 297 void RenderViewDevToolsAgentHost::DisconnectRenderViewHost() { |
| 283 NotifyClientDetaching(); | 298 NotifyClientDetaching(); |
| 284 rvh_observer_.reset(); | 299 rvh_observer_.reset(); |
| 285 render_view_host_ = NULL; | 300 render_view_host_ = NULL; |
| 286 } | 301 } |
| 287 | 302 |
| 288 void RenderViewDevToolsAgentHost::RenderViewHostDestroyed( | 303 void RenderViewDevToolsAgentHost::RenderViewHostDestroyed( |
| 289 RenderViewHost* rvh) { | 304 RenderViewHost* rvh) { |
| 290 DCHECK(render_view_host_); | 305 DCHECK(render_view_host_); |
| 291 scoped_refptr<RenderViewDevToolsAgentHost> protect(this); | 306 scoped_refptr<RenderViewDevToolsAgentHost> protect(this); |
| 292 NotifyCloseListener(); | 307 NotifyCloseListener(); |
| 293 render_view_host_ = NULL; | 308 render_view_host_ = NULL; |
| 294 Release(); | 309 Release(); |
| 295 } | 310 } |
| 296 | 311 |
| 312 void RenderViewDevToolsAgentHost::RenderViewCrashed() { | |
| 313 scoped_ptr<DevToolsProtocol::Event> event( | |
| 314 DevToolsProtocol::CreateEvent( | |
| 315 devtools::Inspector::targetCrashed::kName, NULL)); | |
| 316 DevToolsManagerImpl::GetInstance()-> | |
| 317 DispatchOnInspectorFrontend(this, event->Serialize()); | |
| 318 } | |
| 319 | |
| 297 bool RenderViewDevToolsAgentHost::OnRvhMessageReceived( | 320 bool RenderViewDevToolsAgentHost::OnRvhMessageReceived( |
| 298 const IPC::Message& message) { | 321 const IPC::Message& message) { |
| 299 bool handled = true; | 322 bool handled = true; |
| 300 IPC_BEGIN_MESSAGE_MAP(RenderViewDevToolsAgentHost, message) | 323 IPC_BEGIN_MESSAGE_MAP(RenderViewDevToolsAgentHost, message) |
| 301 IPC_MESSAGE_HANDLER(DevToolsClientMsg_DispatchOnInspectorFrontend, | 324 IPC_MESSAGE_HANDLER(DevToolsClientMsg_DispatchOnInspectorFrontend, |
| 302 OnDispatchOnInspectorFrontend) | 325 OnDispatchOnInspectorFrontend) |
| 303 IPC_MESSAGE_HANDLER(DevToolsHostMsg_SaveAgentRuntimeState, | 326 IPC_MESSAGE_HANDLER(DevToolsHostMsg_SaveAgentRuntimeState, |
| 304 OnSaveAgentRuntimeState) | 327 OnSaveAgentRuntimeState) |
| 305 IPC_MESSAGE_HANDLER(DevToolsHostMsg_ClearBrowserCache, OnClearBrowserCache) | 328 IPC_MESSAGE_HANDLER(DevToolsHostMsg_ClearBrowserCache, OnClearBrowserCache) |
| 306 IPC_MESSAGE_HANDLER(DevToolsHostMsg_ClearBrowserCookies, | 329 IPC_MESSAGE_HANDLER(DevToolsHostMsg_ClearBrowserCookies, |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 376 snapshot_bounds)) | 399 snapshot_bounds)) |
| 377 return false; | 400 return false; |
| 378 | 401 |
| 379 return base::Base64Encode(base::StringPiece( | 402 return base::Base64Encode(base::StringPiece( |
| 380 reinterpret_cast<char*>(&*png.begin()), | 403 reinterpret_cast<char*>(&*png.begin()), |
| 381 png.size()), | 404 png.size()), |
| 382 base_64_data); | 405 base_64_data); |
| 383 } | 406 } |
| 384 | 407 |
| 385 } // namespace content | 408 } // namespace content |
| OLD | NEW |