| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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/debugger/devtools_manager.h" | 5 #include "content/browser/debugger/devtools_manager.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "content/browser/browser_thread.h" | 10 #include "content/browser/browser_thread.h" |
| 11 #include "content/browser/browsing_instance.h" | 11 #include "content/browser/browsing_instance.h" |
| 12 #include "content/browser/child_process_security_policy.h" | 12 #include "content/browser/child_process_security_policy.h" |
| 13 #include "content/browser/content_browser_client.h" | 13 #include "content/browser/content_browser_client.h" |
| 14 #include "content/browser/debugger/devtools_client_host.h" | 14 #include "content/browser/debugger/devtools_client_host.h" |
| 15 #include "content/browser/debugger/devtools_netlog_observer.h" | 15 #include "content/browser/debugger/devtools_netlog_observer.h" |
| 16 #include "content/browser/debugger/render_view_devtools_agent_host.h" |
| 16 #include "content/browser/renderer_host/render_view_host.h" | 17 #include "content/browser/renderer_host/render_view_host.h" |
| 17 #include "content/browser/site_instance.h" | |
| 18 #include "content/browser/tab_contents/tab_contents.h" | 18 #include "content/browser/tab_contents/tab_contents.h" |
| 19 #include "content/common/content_client.h" | 19 #include "content/common/content_client.h" |
| 20 #include "content/common/devtools_messages.h" | 20 #include "content/common/devtools_messages.h" |
| 21 #include "content/common/notification_service.h" | |
| 22 #include "googleurl/src/gurl.h" | 21 #include "googleurl/src/gurl.h" |
| 23 | 22 |
| 24 // static | 23 // static |
| 25 DevToolsManager* DevToolsManager::GetInstance() { | 24 DevToolsManager* DevToolsManager::GetInstance() { |
| 26 return content::GetContentClient()->browser()->GetDevToolsManager(); | 25 return content::GetContentClient()->browser()->GetDevToolsManager(); |
| 27 } | 26 } |
| 28 | 27 |
| 29 DevToolsManager::DevToolsManager() | 28 DevToolsManager::DevToolsManager() |
| 30 : last_orphan_cookie_(0) { | 29 : last_orphan_cookie_(0) { |
| 31 registrar_.Add(this, content::NOTIFICATION_RENDER_VIEW_HOST_DELETED, | |
| 32 NotificationService::AllSources()); | |
| 33 } | 30 } |
| 34 | 31 |
| 35 DevToolsManager::~DevToolsManager() { | 32 DevToolsManager::~DevToolsManager() { |
| 36 DCHECK(inspected_rvh_to_client_host_.empty()); | 33 DCHECK(agent_to_client_host_.empty()); |
| 37 DCHECK(client_host_to_inspected_rvh_.empty()); | 34 DCHECK(client_to_agent_host_.empty()); |
| 38 // By the time we destroy devtools manager, all orphan client hosts should | 35 // By the time we destroy devtools manager, all orphan client hosts should |
| 39 // have been delelted, no need to notify them upon tab closing. | 36 // have been delelted, no need to notify them upon tab closing. |
| 40 DCHECK(orphan_client_hosts_.empty()); | 37 DCHECK(orphan_client_hosts_.empty()); |
| 41 } | 38 } |
| 42 | 39 |
| 43 DevToolsClientHost* DevToolsManager::GetDevToolsClientHostFor( | 40 DevToolsClientHost* DevToolsManager::GetDevToolsClientHostFor( |
| 44 RenderViewHost* inspected_rvh) { | 41 RenderViewHost* inspected_rvh) { |
| 45 InspectedRvhToClientHostMap::iterator it = | 42 DevToolsAgentHost* agent_host = RenderViewDevToolsAgentHost::FindFor( |
| 46 inspected_rvh_to_client_host_.find(inspected_rvh); | 43 inspected_rvh); |
| 47 if (it != inspected_rvh_to_client_host_.end()) | 44 return GetDevToolsClientHostFor(agent_host); |
| 45 } |
| 46 |
| 47 DevToolsClientHost* DevToolsManager::GetDevToolsClientHostFor( |
| 48 DevToolsAgentHost* agent_host) { |
| 49 AgentToClientHostMap::iterator it = agent_to_client_host_.find(agent_host); |
| 50 if (it != agent_to_client_host_.end()) |
| 48 return it->second; | 51 return it->second; |
| 49 return NULL; | 52 return NULL; |
| 50 } | 53 } |
| 51 | 54 |
| 52 void DevToolsManager::RegisterDevToolsClientHostFor( | 55 void DevToolsManager::RegisterDevToolsClientHostFor( |
| 53 RenderViewHost* inspected_rvh, | 56 RenderViewHost* inspected_rvh, |
| 54 DevToolsClientHost* client_host) { | 57 DevToolsClientHost* client_host) { |
| 55 DCHECK(!GetDevToolsClientHostFor(inspected_rvh)); | 58 DCHECK(!GetDevToolsClientHostFor(inspected_rvh)); |
| 56 | 59 |
| 57 DevToolsRuntimeProperties initial_properties; | 60 DevToolsRuntimeProperties initial_properties; |
| 58 BindClientHost(inspected_rvh, client_host, initial_properties); | 61 DevToolsAgentHost* agent_host = RenderViewDevToolsAgentHost::FindFor( |
| 62 inspected_rvh); |
| 63 BindClientHost(agent_host, client_host, initial_properties); |
| 59 client_host->set_close_listener(this); | 64 client_host->set_close_listener(this); |
| 60 SendAttachToAgent(inspected_rvh); | 65 SendAttachToAgent(agent_host); |
| 61 } | 66 } |
| 62 | 67 |
| 63 bool DevToolsManager::ForwardToDevToolsAgent(DevToolsClientHost* from, | 68 bool DevToolsManager::ForwardToDevToolsAgent(DevToolsClientHost* from, |
| 64 const IPC::Message& message) { | 69 const IPC::Message& message) { |
| 65 RenderViewHost* inspected_rvh = GetInspectedRenderViewHost(from); | 70 DevToolsAgentHost* agent_host = GetAgentHost(from); |
| 66 if (!inspected_rvh) | 71 if (!agent_host) |
| 67 return false; | 72 return false; |
| 68 | 73 |
| 69 IPC::Message* m = new IPC::Message(message); | 74 agent_host->SendMessageToAgent(new IPC::Message(message)); |
| 70 m->set_routing_id(inspected_rvh->routing_id()); | |
| 71 inspected_rvh->Send(m); | |
| 72 return true; | 75 return true; |
| 73 } | 76 } |
| 74 | 77 |
| 75 void DevToolsManager::ForwardToDevToolsClient(RenderViewHost* inspected_rvh, | 78 void DevToolsManager::ForwardToDevToolsClient(RenderViewHost* inspected_rvh, |
| 76 const IPC::Message& message) { | 79 const IPC::Message& message) { |
| 77 DevToolsClientHost* client_host = GetDevToolsClientHostFor(inspected_rvh); | 80 DevToolsClientHost* client_host = GetDevToolsClientHostFor(inspected_rvh); |
| 78 if (!client_host) { | 81 if (!client_host) { |
| 79 // Client window was closed while there were messages | 82 // Client window was closed while there were messages |
| 80 // being sent to it. | 83 // being sent to it. |
| 81 return; | 84 return; |
| 82 } | 85 } |
| 83 client_host->SendMessageToClient(message); | 86 client_host->SendMessageToClient(message); |
| 84 } | 87 } |
| 85 | 88 |
| 86 void DevToolsManager::RuntimePropertyChanged(RenderViewHost* inspected_rvh, | 89 void DevToolsManager::RuntimePropertyChanged(RenderViewHost* inspected_rvh, |
| 87 const std::string& name, | 90 const std::string& name, |
| 88 const std::string& value) { | 91 const std::string& value) { |
| 92 DevToolsAgentHost* agent_host = RenderViewDevToolsAgentHost::FindFor( |
| 93 inspected_rvh); |
| 89 RuntimePropertiesMap::iterator it = | 94 RuntimePropertiesMap::iterator it = |
| 90 runtime_properties_map_.find(inspected_rvh); | 95 runtime_properties_map_.find(agent_host); |
| 91 if (it == runtime_properties_map_.end()) { | 96 if (it == runtime_properties_map_.end()) { |
| 92 std::pair<RenderViewHost*, DevToolsRuntimeProperties> value( | 97 std::pair<DevToolsAgentHost*, DevToolsRuntimeProperties> value( |
| 93 inspected_rvh, | 98 agent_host, |
| 94 DevToolsRuntimeProperties()); | 99 DevToolsRuntimeProperties()); |
| 95 it = runtime_properties_map_.insert(value).first; | 100 it = runtime_properties_map_.insert(value).first; |
| 96 } | 101 } |
| 97 it->second[name] = value; | 102 it->second[name] = value; |
| 98 } | 103 } |
| 99 | 104 |
| 100 void DevToolsManager::SendInspectElement(RenderViewHost* inspected_rvh, | 105 void DevToolsManager::SendInspectElement(RenderViewHost* inspected_rvh, |
| 101 int x, | 106 int x, |
| 102 int y) { | 107 int y) { |
| 103 inspected_rvh->Send(new DevToolsAgentMsg_InspectElement( | 108 inspected_rvh->Send(new DevToolsAgentMsg_InspectElement( |
| 104 inspected_rvh->routing_id(), | 109 inspected_rvh->routing_id(), |
| 105 x, | 110 x, |
| 106 y)); | 111 y)); |
| 107 } | 112 } |
| 108 | 113 |
| 109 void DevToolsManager::ClientHostClosing(DevToolsClientHost* host) { | 114 void DevToolsManager::ClientHostClosing(DevToolsClientHost* client_host) { |
| 110 RenderViewHost* inspected_rvh = GetInspectedRenderViewHost(host); | 115 DevToolsAgentHost* agent_host = GetAgentHost(client_host); |
| 111 if (!inspected_rvh) { | 116 if (!agent_host) { |
| 112 // It might be in the list of orphan client hosts, remove it from there. | 117 // It might be in the list of orphan client hosts, remove it from there. |
| 113 for (OrphanClientHosts::iterator it = orphan_client_hosts_.begin(); | 118 for (OrphanClientHosts::iterator it = orphan_client_hosts_.begin(); |
| 114 it != orphan_client_hosts_.end(); ++it) { | 119 it != orphan_client_hosts_.end(); ++it) { |
| 115 if (it->second.first == host) { | 120 if (it->second.first == client_host) { |
| 116 orphan_client_hosts_.erase(it->first); | 121 orphan_client_hosts_.erase(it->first); |
| 117 return; | 122 return; |
| 118 } | 123 } |
| 119 } | 124 } |
| 120 return; | 125 return; |
| 121 } | 126 } |
| 122 | 127 |
| 123 NotificationService::current()->Notify( | 128 agent_host->NotifyClientClosing(); |
| 124 content::NOTIFICATION_DEVTOOLS_WINDOW_CLOSING, | |
| 125 Source<content::BrowserContext>( | |
| 126 inspected_rvh->site_instance()->GetProcess()->browser_context()), | |
| 127 Details<RenderViewHost>(inspected_rvh)); | |
| 128 | 129 |
| 129 UnbindClientHost(inspected_rvh, host); | 130 UnbindClientHost(agent_host, client_host); |
| 130 } | 131 } |
| 131 | 132 |
| 132 void DevToolsManager::Observe(int type, | 133 void DevToolsManager::AgentHostClosing(DevToolsAgentHost* agent_host) { |
| 133 const NotificationSource& source, | 134 UnregisterDevToolsClientHostFor(agent_host); |
| 134 const NotificationDetails& details) { | |
| 135 DCHECK(type == content::NOTIFICATION_RENDER_VIEW_HOST_DELETED); | |
| 136 UnregisterDevToolsClientHostFor(Source<RenderViewHost>(source).ptr()); | |
| 137 } | 135 } |
| 138 | 136 |
| 139 RenderViewHost* DevToolsManager::GetInspectedRenderViewHost( | 137 DevToolsAgentHost* DevToolsManager::GetAgentHost( |
| 140 DevToolsClientHost* client_host) { | 138 DevToolsClientHost* client_host) { |
| 141 ClientHostToInspectedRvhMap::iterator it = | 139 ClientHostToInspectedRvhMap::iterator it = |
| 142 client_host_to_inspected_rvh_.find(client_host); | 140 client_to_agent_host_.find(client_host); |
| 143 if (it != client_host_to_inspected_rvh_.end()) | 141 if (it != client_to_agent_host_.end()) |
| 144 return it->second; | 142 return it->second; |
| 145 return NULL; | 143 return NULL; |
| 146 } | 144 } |
| 147 | 145 |
| 148 void DevToolsManager::UnregisterDevToolsClientHostFor( | 146 void DevToolsManager::UnregisterDevToolsClientHostFor( |
| 149 RenderViewHost* inspected_rvh) { | 147 RenderViewHost* inspected_rvh) { |
| 150 DevToolsClientHost* host = GetDevToolsClientHostFor(inspected_rvh); | 148 DevToolsAgentHost* agent_host = RenderViewDevToolsAgentHost::FindFor( |
| 151 if (!host) | 149 inspected_rvh); |
| 150 UnregisterDevToolsClientHostFor(agent_host); |
| 151 } |
| 152 |
| 153 void DevToolsManager::UnregisterDevToolsClientHostFor( |
| 154 DevToolsAgentHost* agent_host) { |
| 155 DevToolsClientHost* client_host = GetDevToolsClientHostFor(agent_host); |
| 156 if (!client_host) |
| 152 return; | 157 return; |
| 153 UnbindClientHost(inspected_rvh, host); | 158 UnbindClientHost(agent_host, client_host); |
| 154 host->InspectedTabClosing(); | 159 client_host->InspectedTabClosing(); |
| 155 } | 160 } |
| 156 | 161 |
| 157 void DevToolsManager::OnNavigatingToPendingEntry(RenderViewHost* rvh, | 162 void DevToolsManager::OnNavigatingToPendingEntry(RenderViewHost* rvh, |
| 158 RenderViewHost* dest_rvh, | 163 RenderViewHost* dest_rvh, |
| 159 const GURL& gurl) { | 164 const GURL& gurl) { |
| 160 int cookie = DetachClientHost(rvh); | 165 int cookie = DetachClientHost(rvh); |
| 161 if (cookie != -1) { | 166 if (cookie != -1) { |
| 162 // Navigating to URL in the inspected window. | 167 // Navigating to URL in the inspected window. |
| 163 AttachClientHost(cookie, dest_rvh); | 168 AttachClientHost(cookie, dest_rvh); |
| 164 | 169 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 175 return; // Didn't know about old_tab. | 180 return; // Didn't know about old_tab. |
| 176 int cookie = DetachClientHost(old_rvh); | 181 int cookie = DetachClientHost(old_rvh); |
| 177 if (cookie == -1) | 182 if (cookie == -1) |
| 178 return; // Didn't know about old_tab. | 183 return; // Didn't know about old_tab. |
| 179 | 184 |
| 180 client_host->TabReplaced(new_tab); | 185 client_host->TabReplaced(new_tab); |
| 181 AttachClientHost(cookie, new_tab->render_view_host()); | 186 AttachClientHost(cookie, new_tab->render_view_host()); |
| 182 } | 187 } |
| 183 | 188 |
| 184 int DevToolsManager::DetachClientHost(RenderViewHost* from_rvh) { | 189 int DevToolsManager::DetachClientHost(RenderViewHost* from_rvh) { |
| 185 DevToolsClientHost* client_host = GetDevToolsClientHostFor(from_rvh); | 190 DevToolsAgentHost* agent_host = RenderViewDevToolsAgentHost::FindFor( |
| 191 from_rvh); |
| 192 DevToolsClientHost* client_host = GetDevToolsClientHostFor(agent_host); |
| 186 if (!client_host) | 193 if (!client_host) |
| 187 return -1; | 194 return -1; |
| 188 | 195 |
| 189 int cookie = last_orphan_cookie_++; | 196 int cookie = last_orphan_cookie_++; |
| 190 orphan_client_hosts_[cookie] = | 197 orphan_client_hosts_[cookie] = |
| 191 std::pair<DevToolsClientHost*, DevToolsRuntimeProperties>( | 198 std::pair<DevToolsClientHost*, DevToolsRuntimeProperties>( |
| 192 client_host, runtime_properties_map_[from_rvh]); | 199 client_host, runtime_properties_map_[agent_host]); |
| 193 | 200 |
| 194 UnbindClientHost(from_rvh, client_host); | 201 UnbindClientHost(agent_host, client_host); |
| 195 return cookie; | 202 return cookie; |
| 196 } | 203 } |
| 197 | 204 |
| 198 void DevToolsManager::AttachClientHost(int client_host_cookie, | 205 void DevToolsManager::AttachClientHost(int client_host_cookie, |
| 199 RenderViewHost* to_rvh) { | 206 RenderViewHost* to_rvh) { |
| 200 OrphanClientHosts::iterator it = orphan_client_hosts_.find( | 207 OrphanClientHosts::iterator it = orphan_client_hosts_.find( |
| 201 client_host_cookie); | 208 client_host_cookie); |
| 202 if (it == orphan_client_hosts_.end()) | 209 if (it == orphan_client_hosts_.end()) |
| 203 return; | 210 return; |
| 204 | 211 |
| 205 DevToolsClientHost* client_host = (*it).second.first; | 212 DevToolsClientHost* client_host = (*it).second.first; |
| 206 BindClientHost(to_rvh, client_host, (*it).second.second); | 213 DevToolsAgentHost* agent_host = RenderViewDevToolsAgentHost::FindFor( |
| 207 SendAttachToAgent(to_rvh); | 214 to_rvh); |
| 215 BindClientHost(agent_host, client_host, (*it).second.second); |
| 216 SendAttachToAgent(agent_host); |
| 208 | 217 |
| 209 orphan_client_hosts_.erase(client_host_cookie); | 218 orphan_client_hosts_.erase(client_host_cookie); |
| 210 } | 219 } |
| 211 | 220 |
| 212 void DevToolsManager::SendAttachToAgent(RenderViewHost* inspected_rvh) { | 221 void DevToolsManager::SendAttachToAgent(DevToolsAgentHost* agent_host) { |
| 213 if (inspected_rvh) { | 222 DevToolsRuntimeProperties properties; |
| 214 ChildProcessSecurityPolicy::GetInstance()->GrantReadRawCookies( | 223 RuntimePropertiesMap::iterator it = |
| 215 inspected_rvh->process()->id()); | 224 runtime_properties_map_.find(agent_host); |
| 216 | 225 if (it != runtime_properties_map_.end()) { |
| 217 DevToolsRuntimeProperties properties; | 226 properties = DevToolsRuntimeProperties(it->second.begin(), |
| 218 RuntimePropertiesMap::iterator it = | 227 it->second.end()); |
| 219 runtime_properties_map_.find(inspected_rvh); | |
| 220 if (it != runtime_properties_map_.end()) { | |
| 221 properties = DevToolsRuntimeProperties(it->second.begin(), | |
| 222 it->second.end()); | |
| 223 } | |
| 224 inspected_rvh->Send(new DevToolsAgentMsg_Attach( | |
| 225 inspected_rvh->routing_id(), | |
| 226 properties)); | |
| 227 } | 228 } |
| 229 agent_host->SendMessageToAgent(new DevToolsAgentMsg_Attach( |
| 230 MSG_ROUTING_NONE, |
| 231 properties)); |
| 228 } | 232 } |
| 229 | 233 |
| 230 void DevToolsManager::SendDetachToAgent(RenderViewHost* inspected_rvh) { | 234 void DevToolsManager::SendDetachToAgent(DevToolsAgentHost* agent_host) { |
| 231 if (inspected_rvh) { | 235 if (agent_host) { |
| 232 inspected_rvh->Send(new DevToolsAgentMsg_Detach( | 236 agent_host->SendMessageToAgent(new DevToolsAgentMsg_Detach( |
| 233 inspected_rvh->routing_id())); | 237 MSG_ROUTING_NONE)); |
| 234 } | 238 } |
| 235 } | 239 } |
| 236 | 240 |
| 237 void DevToolsManager::BindClientHost( | 241 void DevToolsManager::BindClientHost( |
| 238 RenderViewHost* inspected_rvh, | 242 DevToolsAgentHost* agent_host, |
| 239 DevToolsClientHost* client_host, | 243 DevToolsClientHost* client_host, |
| 240 const DevToolsRuntimeProperties& runtime_properties) { | 244 const DevToolsRuntimeProperties& runtime_properties) { |
| 241 DCHECK(inspected_rvh_to_client_host_.find(inspected_rvh) == | 245 DCHECK(agent_to_client_host_.find(agent_host) == |
| 242 inspected_rvh_to_client_host_.end()); | 246 agent_to_client_host_.end()); |
| 243 DCHECK(client_host_to_inspected_rvh_.find(client_host) == | 247 DCHECK(client_to_agent_host_.find(client_host) == |
| 244 client_host_to_inspected_rvh_.end()); | 248 client_to_agent_host_.end()); |
| 245 | 249 |
| 246 if (client_host_to_inspected_rvh_.empty()) { | 250 if (client_to_agent_host_.empty()) { |
| 247 BrowserThread::PostTask( | 251 BrowserThread::PostTask( |
| 248 BrowserThread::IO, | 252 BrowserThread::IO, |
| 249 FROM_HERE, | 253 FROM_HERE, |
| 250 NewRunnableFunction(&DevToolsNetLogObserver::Attach)); | 254 NewRunnableFunction(&DevToolsNetLogObserver::Attach)); |
| 251 } | 255 } |
| 252 inspected_rvh_to_client_host_[inspected_rvh] = client_host; | 256 agent_to_client_host_[agent_host] = client_host; |
| 253 client_host_to_inspected_rvh_[client_host] = inspected_rvh; | 257 client_to_agent_host_[client_host] = agent_host; |
| 254 runtime_properties_map_[inspected_rvh] = runtime_properties; | 258 runtime_properties_map_[agent_host] = runtime_properties; |
| 259 agent_host->set_close_listener(this); |
| 260 |
| 261 int process_id = agent_host->GetRenderProcessId(); |
| 262 if (process_id != -1) |
| 263 ChildProcessSecurityPolicy::GetInstance()->GrantReadRawCookies(process_id); |
| 255 } | 264 } |
| 256 | 265 |
| 257 void DevToolsManager::UnbindClientHost(RenderViewHost* inspected_rvh, | 266 void DevToolsManager::UnbindClientHost(DevToolsAgentHost* agent_host, |
| 258 DevToolsClientHost* client_host) { | 267 DevToolsClientHost* client_host) { |
| 259 DCHECK(inspected_rvh_to_client_host_.find(inspected_rvh)->second == | 268 DCHECK(agent_host); |
| 269 DCHECK(agent_to_client_host_.find(agent_host)->second == |
| 260 client_host); | 270 client_host); |
| 261 DCHECK(client_host_to_inspected_rvh_.find(client_host)->second == | 271 DCHECK(client_to_agent_host_.find(client_host)->second == |
| 262 inspected_rvh); | 272 agent_host); |
| 273 agent_host->set_close_listener(NULL); |
| 263 | 274 |
| 264 inspected_rvh_to_client_host_.erase(inspected_rvh); | 275 agent_to_client_host_.erase(agent_host); |
| 265 client_host_to_inspected_rvh_.erase(client_host); | 276 client_to_agent_host_.erase(client_host); |
| 266 runtime_properties_map_.erase(inspected_rvh); | 277 runtime_properties_map_.erase(agent_host); |
| 267 | 278 |
| 268 if (client_host_to_inspected_rvh_.empty()) { | 279 if (client_to_agent_host_.empty()) { |
| 269 BrowserThread::PostTask( | 280 BrowserThread::PostTask( |
| 270 BrowserThread::IO, | 281 BrowserThread::IO, |
| 271 FROM_HERE, | 282 FROM_HERE, |
| 272 NewRunnableFunction(&DevToolsNetLogObserver::Detach)); | 283 NewRunnableFunction(&DevToolsNetLogObserver::Detach)); |
| 273 } | 284 } |
| 274 SendDetachToAgent(inspected_rvh); | 285 SendDetachToAgent(agent_host); |
| 275 | 286 |
| 276 int process_id = inspected_rvh->process()->id(); | 287 int process_id = agent_host->GetRenderProcessId(); |
| 277 for (InspectedRvhToClientHostMap::iterator it = | 288 if (process_id == -1) |
| 278 inspected_rvh_to_client_host_.begin(); | 289 return; |
| 279 it != inspected_rvh_to_client_host_.end(); | 290 for (AgentToClientHostMap::iterator it = agent_to_client_host_.begin(); |
| 291 it != agent_to_client_host_.end(); |
| 280 ++it) { | 292 ++it) { |
| 281 if (it->first->process()->id() == process_id) | 293 if (it->first->GetRenderProcessId() == process_id) |
| 282 return; | 294 return; |
| 283 } | 295 } |
| 284 // We've disconnected from the last renderer -> revoke cookie permissions. | 296 // We've disconnected from the last renderer -> revoke cookie permissions. |
| 285 ChildProcessSecurityPolicy::GetInstance()->RevokeReadRawCookies(process_id); | 297 ChildProcessSecurityPolicy::GetInstance()->RevokeReadRawCookies(process_id); |
| 286 } | 298 } |
| 287 | 299 |
| 288 void DevToolsManager::CloseAllClientHosts() { | 300 void DevToolsManager::CloseAllClientHosts() { |
| 289 std::vector<RenderViewHost*> rhvs; | 301 std::vector<DevToolsAgentHost*> agents; |
| 290 for (InspectedRvhToClientHostMap::iterator it = | 302 for (AgentToClientHostMap::iterator it = |
| 291 inspected_rvh_to_client_host_.begin(); | 303 agent_to_client_host_.begin(); |
| 292 it != inspected_rvh_to_client_host_.end(); ++it) { | 304 it != agent_to_client_host_.end(); ++it) { |
| 293 rhvs.push_back(it->first); | 305 agents.push_back(it->first); |
| 294 } | 306 } |
| 295 for (std::vector<RenderViewHost*>::iterator it = rhvs.begin(); | 307 for (std::vector<DevToolsAgentHost*>::iterator it = agents.begin(); |
| 296 it != rhvs.end(); ++it) { | 308 it != agents.end(); ++it) { |
| 297 UnregisterDevToolsClientHostFor(*it); | 309 UnregisterDevToolsClientHostFor(*it); |
| 298 } | 310 } |
| 299 } | 311 } |
| OLD | NEW |