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