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/debugger/render_view_devtools_agent_host.cc

Issue 7660010: DevTools: introduce DevToolsAgentHost (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "content/browser/debugger/render_view_devtools_agent_host.h"
6
7 #include "base/basictypes.h"
8 #include "content/browser/child_process_security_policy.h"
9 #include "content/browser/renderer_host/render_process_host.h"
10 #include "content/browser/renderer_host/render_view_host.h"
11 #include "content/browser/site_instance.h"
12 #include "content/common/notification_service.h"
13
14 RenderViewDevToolsAgentHost::Instances RenderViewDevToolsAgentHost::instances_;
15
16 DevToolsAgentHost* RenderViewDevToolsAgentHost::FindFor(
17 RenderViewHost* rvh) {
18 Instances::iterator it = instances_.find(rvh);
19 if (it != instances_.end())
20 return it->second;
21 return NULL;
22 }
23
24 DevToolsAgentHost* RenderViewDevToolsAgentHost::CreateFor(
25 RenderViewHost* rvh) {
26 DCHECK(!FindFor(rvh));
27 RenderViewDevToolsAgentHost* result = new RenderViewDevToolsAgentHost(rvh);
28 return result;
29 }
30
31 RenderViewDevToolsAgentHost::RenderViewDevToolsAgentHost(RenderViewHost* rvh)
32 : render_view_host_(rvh) {
33 ChildProcessSecurityPolicy::GetInstance()->GrantReadRawCookies(
34 rvh->process()->id());
35 registrar_.Add(this, content::NOTIFICATION_RENDER_VIEW_HOST_DELETED,
36 Source<RenderViewHost>(rvh));
37 instances_[rvh] = this;
38 }
39
40 void RenderViewDevToolsAgentHost::SendMessageToAgent(IPC::Message* msg) {
41 msg->set_routing_id(render_view_host_->routing_id());
42 render_view_host_->Send(msg);
43 }
44
45 void RenderViewDevToolsAgentHost::NotifyClientClosing() {
46 NotificationService::current()->Notify(
47 content::NOTIFICATION_DEVTOOLS_WINDOW_CLOSING,
48 Source<content::BrowserContext>(
49 render_view_host_->site_instance()->GetProcess()->browser_context()),
50 Details<RenderViewHost>(render_view_host_));
51 }
52
53 void RenderViewDevToolsAgentHost::ClientDetached() {
54 delete this;
55 }
56
57 void RenderViewDevToolsAgentHost::Observe(int type,
58 const NotificationSource& source,
59 const NotificationDetails& details) {
60 DCHECK(type == content::NOTIFICATION_RENDER_VIEW_HOST_DELETED);
61 NotifyCloseListener();
62 }
63
64 RenderViewDevToolsAgentHost::~RenderViewDevToolsAgentHost() {
65 instances_.erase(render_view_host_);
66
67 int process_id = render_view_host_->process()->id();
68 for (Instances::iterator it = instances_.begin();
69 it != instances_.end();
70 ++it) {
71 if (it->first->process()->id() == process_id)
72 return;
73 }
74 // We've disconnected from the last renderer -> revoke cookie permissions.
75 ChildProcessSecurityPolicy::GetInstance()->RevokeReadRawCookies(process_id);
76 }
77
OLDNEW
« no previous file with comments | « content/browser/debugger/render_view_devtools_agent_host.h ('k') | content/content_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698