Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(44)

Side by Side Diff: content/browser/devtools/render_view_devtools_agent_host.cc

Issue 459403002: DevTools: Added service workers to remote debugging targets (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Made RVDTAH::GetURL consistent with tests Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/lazy_instance.h" 8 #include "base/lazy_instance.h"
9 #include "base/strings/utf_string_conversions.h"
9 #include "content/browser/child_process_security_policy_impl.h" 10 #include "content/browser/child_process_security_policy_impl.h"
10 #include "content/browser/devtools/devtools_manager_impl.h" 11 #include "content/browser/devtools/devtools_manager_impl.h"
11 #include "content/browser/devtools/devtools_power_handler.h" 12 #include "content/browser/devtools/devtools_power_handler.h"
12 #include "content/browser/devtools/devtools_protocol.h" 13 #include "content/browser/devtools/devtools_protocol.h"
13 #include "content/browser/devtools/devtools_protocol_constants.h" 14 #include "content/browser/devtools/devtools_protocol_constants.h"
14 #include "content/browser/devtools/devtools_tracing_handler.h" 15 #include "content/browser/devtools/devtools_tracing_handler.h"
15 #include "content/browser/devtools/renderer_overrides_handler.h" 16 #include "content/browser/devtools/renderer_overrides_handler.h"
16 #include "content/browser/renderer_host/render_process_host_impl.h" 17 #include "content/browser/renderer_host/render_process_host_impl.h"
17 #include "content/browser/renderer_host/render_view_host_impl.h" 18 #include "content/browser/renderer_host/render_view_host_impl.h"
18 #include "content/browser/site_instance_impl.h" 19 #include "content/browser/site_instance_impl.h"
19 #include "content/browser/web_contents/web_contents_impl.h" 20 #include "content/browser/web_contents/web_contents_impl.h"
20 #include "content/common/devtools_messages.h" 21 #include "content/common/devtools_messages.h"
21 #include "content/common/view_messages.h" 22 #include "content/common/view_messages.h"
22 #include "content/public/browser/content_browser_client.h" 23 #include "content/public/browser/content_browser_client.h"
23 #include "content/public/browser/devtools_manager_delegate.h" 24 #include "content/public/browser/devtools_manager_delegate.h"
24 #include "content/public/browser/notification_service.h" 25 #include "content/public/browser/notification_service.h"
25 #include "content/public/browser/notification_types.h" 26 #include "content/public/browser/notification_types.h"
26 #include "content/public/browser/render_widget_host_iterator.h" 27 #include "content/public/browser/render_widget_host_iterator.h"
28 #include "content/public/browser/web_contents_delegate.h"
27 29
28 #if defined(OS_ANDROID) 30 #if defined(OS_ANDROID)
29 #include "content/browser/power_save_blocker_impl.h" 31 #include "content/browser/power_save_blocker_impl.h"
30 #include "content/public/browser/render_widget_host_view.h" 32 #include "content/public/browser/render_widget_host_view.h"
31 #endif 33 #endif
32 34
33 namespace content { 35 namespace content {
34 36
35 typedef std::vector<RenderViewDevToolsAgentHost*> Instances; 37 typedef std::vector<RenderViewDevToolsAgentHost*> Instances;
36 38
(...skipping 28 matching lines...) Expand all
65 return FindAgentHost(web_contents) != NULL; 67 return FindAgentHost(web_contents) != NULL;
66 } 68 }
67 69
68 // static 70 // static
69 bool DevToolsAgentHost::IsDebuggerAttached(WebContents* web_contents) { 71 bool DevToolsAgentHost::IsDebuggerAttached(WebContents* web_contents) {
70 RenderViewDevToolsAgentHost* agent_host = FindAgentHost(web_contents); 72 RenderViewDevToolsAgentHost* agent_host = FindAgentHost(web_contents);
71 return agent_host && agent_host->IsAttached(); 73 return agent_host && agent_host->IsAttached();
72 } 74 }
73 75
74 //static 76 //static
75 std::vector<WebContents*> DevToolsAgentHost::GetInspectableWebContents() { 77 std::vector<WebContents*> DevToolsAgentHostImpl::GetInspectableWebContents() {
76 std::set<WebContents*> set; 78 std::set<WebContents*> set;
77 scoped_ptr<RenderWidgetHostIterator> widgets( 79 scoped_ptr<RenderWidgetHostIterator> widgets(
78 RenderWidgetHost::GetRenderWidgetHosts()); 80 RenderWidgetHost::GetRenderWidgetHosts());
79 while (RenderWidgetHost* widget = widgets->GetNextHost()) { 81 while (RenderWidgetHost* widget = widgets->GetNextHost()) {
80 // Ignore processes that don't have a connection, such as crashed contents. 82 // Ignore processes that don't have a connection, such as crashed contents.
81 if (!widget->GetProcess()->HasConnection()) 83 if (!widget->GetProcess()->HasConnection())
82 continue; 84 continue;
83 if (!widget->IsRenderView()) 85 if (!widget->IsRenderView())
84 continue; 86 continue;
85 87
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 } 372 }
371 373
372 void RenderViewDevToolsAgentHost::DisconnectWebContents() { 374 void RenderViewDevToolsAgentHost::DisconnectWebContents() {
373 DisconnectRenderViewHost(); 375 DisconnectRenderViewHost();
374 } 376 }
375 377
376 void RenderViewDevToolsAgentHost::ConnectWebContents(WebContents* wc) { 378 void RenderViewDevToolsAgentHost::ConnectWebContents(WebContents* wc) {
377 ConnectRenderViewHost(wc->GetRenderViewHost()); 379 ConnectRenderViewHost(wc->GetRenderViewHost());
378 } 380 }
379 381
382 DevToolsAgentHost::Type RenderViewDevToolsAgentHost::GetType() {
383 return TYPE_WEB_CONTENTS;
384 }
385
386 std::string RenderViewDevToolsAgentHost::GetTitle() {
387 if (WebContents* web_contents = GetWebContents())
388 return base::UTF16ToUTF8(web_contents->GetTitle());
389 return "";
390 }
391
392 GURL RenderViewDevToolsAgentHost::GetURL() {
393 if (WebContents* web_contents = GetWebContents())
394 return web_contents->GetVisibleURL();
395 return render_view_host_ ?
396 render_view_host_->GetMainFrame()->GetLastCommittedURL() : GURL();
397 }
398
399 bool RenderViewDevToolsAgentHost::Activate() {
400 if (render_view_host_) {
401 render_view_host_->GetDelegate()->Activate();
402 return true;
403 }
404 return false;
405 }
406
407 bool RenderViewDevToolsAgentHost::Close() {
408 if (render_view_host_) {
409 render_view_host_->ClosePage();
410 return true;
411 }
412 return false;
413 }
414
380 void RenderViewDevToolsAgentHost::ConnectRenderViewHost(RenderViewHost* rvh) { 415 void RenderViewDevToolsAgentHost::ConnectRenderViewHost(RenderViewHost* rvh) {
381 SetRenderViewHost(rvh); 416 SetRenderViewHost(rvh);
382 if (IsAttached()) 417 if (IsAttached())
383 Reattach(state_); 418 Reattach(state_);
384 } 419 }
385 420
386 void RenderViewDevToolsAgentHost::DisconnectRenderViewHost() { 421 void RenderViewDevToolsAgentHost::DisconnectRenderViewHost() {
387 ClientDetachedFromRenderer(); 422 ClientDetachedFromRenderer();
388 ClearRenderViewHost(); 423 ClearRenderViewHost();
389 } 424 }
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 scoped_refptr<DevToolsProtocol::Notification> notification = 478 scoped_refptr<DevToolsProtocol::Notification> notification =
444 DevToolsProtocol::ParseNotification(message); 479 DevToolsProtocol::ParseNotification(message);
445 480
446 if (notification) { 481 if (notification) {
447 tracing_handler_->HandleNotification(notification); 482 tracing_handler_->HandleNotification(notification);
448 } 483 }
449 SendMessageToClient(message); 484 SendMessageToClient(message);
450 } 485 }
451 486
452 } // namespace content 487 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/devtools/render_view_devtools_agent_host.h ('k') | content/public/browser/devtools_agent_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698