| 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/auto_reset.h" |  | 
| 10 #include "base/message_loop.h" | 9 #include "base/message_loop.h" | 
| 11 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" | 
| 12 #include "chrome/browser/io_thread.h" | 11 #include "chrome/browser/io_thread.h" | 
| 13 #include "chrome/browser/prefs/pref_service.h" | 12 #include "chrome/browser/prefs/pref_service.h" | 
| 14 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" | 
| 15 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 14 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 
| 16 #include "chrome/common/pref_names.h" | 15 #include "chrome/common/pref_names.h" | 
| 17 #include "content/browser/browsing_instance.h" | 16 #include "content/browser/browsing_instance.h" | 
| 18 #include "content/browser/child_process_security_policy.h" | 17 #include "content/browser/child_process_security_policy.h" | 
| 19 #include "content/browser/debugger/devtools_client_host.h" | 18 #include "content/browser/debugger/devtools_client_host.h" | 
| 20 #include "content/browser/debugger/devtools_netlog_observer.h" | 19 #include "content/browser/debugger/devtools_netlog_observer.h" | 
| 21 #include "content/browser/debugger/devtools_window.h" |  | 
| 22 #include "content/browser/renderer_host/render_view_host.h" | 20 #include "content/browser/renderer_host/render_view_host.h" | 
| 23 #include "content/browser/site_instance.h" | 21 #include "content/browser/site_instance.h" | 
| 24 #include "content/common/devtools_messages.h" | 22 #include "content/common/devtools_messages.h" | 
| 25 #include "content/common/notification_service.h" | 23 #include "content/common/notification_service.h" | 
| 26 #include "googleurl/src/gurl.h" | 24 #include "googleurl/src/gurl.h" | 
| 27 | 25 | 
| 28 // static | 26 // static | 
| 29 DevToolsManager* DevToolsManager::GetInstance() { | 27 DevToolsManager* DevToolsManager::GetInstance() { | 
| 30   // http://crbug.com/47806 this method may be called when BrowserProcess | 28   // http://crbug.com/47806 this method may be called when BrowserProcess | 
| 31   // has already been destroyed. | 29   // has already been destroyed. | 
| 32   if (!g_browser_process) | 30   if (!g_browser_process) | 
| 33     return NULL; | 31     return NULL; | 
| 34   return g_browser_process->devtools_manager(); | 32   return g_browser_process->devtools_manager(); | 
| 35 } | 33 } | 
| 36 | 34 | 
| 37 // static | 35 // static | 
| 38 void DevToolsManager::RegisterUserPrefs(PrefService* prefs) { | 36 void DevToolsManager::RegisterUserPrefs(PrefService* prefs) { | 
| 39   prefs->RegisterBooleanPref(prefs::kDevToolsOpenDocked, | 37   prefs->RegisterBooleanPref(prefs::kDevToolsOpenDocked, | 
| 40                              true, | 38                              true, | 
| 41                              PrefService::UNSYNCABLE_PREF); | 39                              PrefService::UNSYNCABLE_PREF); | 
| 42 } | 40 } | 
| 43 | 41 | 
| 44 DevToolsManager::DevToolsManager() | 42 DevToolsManager::DevToolsManager() | 
| 45     : inspected_rvh_for_reopen_(NULL), | 43     : last_orphan_cookie_(0) { | 
| 46       in_initial_show_(false), |  | 
| 47       last_orphan_cookie_(0) { |  | 
| 48   registrar_.Add(this, NotificationType::RENDER_VIEW_HOST_DELETED, | 44   registrar_.Add(this, NotificationType::RENDER_VIEW_HOST_DELETED, | 
| 49                  NotificationService::AllSources()); | 45                  NotificationService::AllSources()); | 
| 50 } | 46 } | 
| 51 | 47 | 
| 52 DevToolsManager::~DevToolsManager() { | 48 DevToolsManager::~DevToolsManager() { | 
| 53   DCHECK(inspected_rvh_to_client_host_.empty()); | 49   DCHECK(inspected_rvh_to_client_host_.empty()); | 
| 54   DCHECK(client_host_to_inspected_rvh_.empty()); | 50   DCHECK(client_host_to_inspected_rvh_.empty()); | 
| 55   // By the time we destroy devtools manager, all orphan client hosts should | 51   // By the time we destroy devtools manager, all orphan client hosts should | 
| 56   // have been delelted, no need to notify them upon tab closing. | 52   // have been delelted, no need to notify them upon tab closing. | 
| 57   DCHECK(orphan_client_hosts_.empty()); | 53   DCHECK(orphan_client_hosts_.empty()); | 
| (...skipping 12 matching lines...) Expand all  Loading... | 
| 70     RenderViewHost* inspected_rvh, | 66     RenderViewHost* inspected_rvh, | 
| 71     DevToolsClientHost* client_host) { | 67     DevToolsClientHost* client_host) { | 
| 72   DCHECK(!GetDevToolsClientHostFor(inspected_rvh)); | 68   DCHECK(!GetDevToolsClientHostFor(inspected_rvh)); | 
| 73 | 69 | 
| 74   DevToolsRuntimeProperties initial_properties; | 70   DevToolsRuntimeProperties initial_properties; | 
| 75   BindClientHost(inspected_rvh, client_host, initial_properties); | 71   BindClientHost(inspected_rvh, client_host, initial_properties); | 
| 76   client_host->set_close_listener(this); | 72   client_host->set_close_listener(this); | 
| 77   SendAttachToAgent(inspected_rvh); | 73   SendAttachToAgent(inspected_rvh); | 
| 78 } | 74 } | 
| 79 | 75 | 
| 80 void DevToolsManager::ForwardToDevToolsAgent( |  | 
| 81     RenderViewHost* client_rvh, |  | 
| 82     const IPC::Message& message) { |  | 
| 83   DevToolsClientHost* client_host = FindOwnerDevToolsClientHost(client_rvh); |  | 
| 84   if (client_host) |  | 
| 85     ForwardToDevToolsAgent(client_host, message); |  | 
| 86 } |  | 
| 87 |  | 
| 88 void DevToolsManager::ForwardToDevToolsAgent(DevToolsClientHost* from, | 76 void DevToolsManager::ForwardToDevToolsAgent(DevToolsClientHost* from, | 
| 89                                              const IPC::Message& message) { | 77                                              const IPC::Message& message) { | 
| 90   RenderViewHost* inspected_rvh = GetInspectedRenderViewHost(from); | 78   RenderViewHost* inspected_rvh = GetInspectedRenderViewHost(from); | 
| 91   if (!inspected_rvh) { | 79   if (!inspected_rvh) { | 
| 92     // TODO(yurys): notify client that the agent is no longer available | 80     // TODO(yurys): notify client that the agent is no longer available | 
| 93     NOTREACHED(); | 81     NOTREACHED(); | 
| 94     return; | 82     return; | 
| 95   } | 83   } | 
| 96 | 84 | 
| 97   IPC::Message* m = new IPC::Message(message); | 85   IPC::Message* m = new IPC::Message(message); | 
| 98   m->set_routing_id(inspected_rvh->routing_id()); | 86   m->set_routing_id(inspected_rvh->routing_id()); | 
| 99   inspected_rvh->Send(m); | 87   inspected_rvh->Send(m); | 
| 100 } | 88 } | 
| 101 | 89 | 
| 102 void DevToolsManager::ForwardToDevToolsClient(RenderViewHost* inspected_rvh, | 90 void DevToolsManager::ForwardToDevToolsClient(RenderViewHost* inspected_rvh, | 
| 103                                               const IPC::Message& message) { | 91                                               const IPC::Message& message) { | 
| 104   DevToolsClientHost* client_host = GetDevToolsClientHostFor(inspected_rvh); | 92   DevToolsClientHost* client_host = GetDevToolsClientHostFor(inspected_rvh); | 
| 105   if (!client_host) { | 93   if (!client_host) { | 
| 106     // Client window was closed while there were messages | 94     // Client window was closed while there were messages | 
| 107     // being sent to it. | 95     // being sent to it. | 
| 108     return; | 96     return; | 
| 109   } | 97   } | 
| 110   client_host->SendMessageToClient(message); | 98   client_host->SendMessageToClient(message); | 
| 111 } | 99 } | 
| 112 | 100 | 
| 113 void DevToolsManager::ActivateWindow(RenderViewHost* client_rvh) { |  | 
| 114   DevToolsClientHost* client_host = FindOwnerDevToolsClientHost(client_rvh); |  | 
| 115   if (!client_host) |  | 
| 116     return; |  | 
| 117 |  | 
| 118   DevToolsWindow* window = client_host->AsDevToolsWindow(); |  | 
| 119   DCHECK(window); |  | 
| 120   window->Activate(); |  | 
| 121 } |  | 
| 122 |  | 
| 123 void DevToolsManager::CloseWindow(RenderViewHost* client_rvh) { |  | 
| 124   DevToolsClientHost* client_host = FindOwnerDevToolsClientHost(client_rvh); |  | 
| 125   if (client_host) { |  | 
| 126     DevToolsWindow* window = client_host->AsDevToolsWindow(); |  | 
| 127     DCHECK(window); |  | 
| 128     window->Close(); |  | 
| 129   } |  | 
| 130 } |  | 
| 131 |  | 
| 132 void DevToolsManager::RequestDockWindow(RenderViewHost* client_rvh) { |  | 
| 133   ReopenWindow(client_rvh, true); |  | 
| 134 } |  | 
| 135 |  | 
| 136 void DevToolsManager::RequestUndockWindow(RenderViewHost* client_rvh) { |  | 
| 137   ReopenWindow(client_rvh, false); |  | 
| 138 } |  | 
| 139 |  | 
| 140 void DevToolsManager::OpenDevToolsWindow(RenderViewHost* inspected_rvh) { |  | 
| 141   ToggleDevToolsWindow( |  | 
| 142       inspected_rvh, |  | 
| 143       true, |  | 
| 144       DEVTOOLS_TOGGLE_ACTION_NONE); |  | 
| 145 } |  | 
| 146 |  | 
| 147 void DevToolsManager::ToggleDevToolsWindow( |  | 
| 148     RenderViewHost* inspected_rvh, |  | 
| 149     DevToolsToggleAction action) { |  | 
| 150   ToggleDevToolsWindow(inspected_rvh, false, action); |  | 
| 151 } |  | 
| 152 |  | 
| 153 void DevToolsManager::RuntimePropertyChanged(RenderViewHost* inspected_rvh, | 101 void DevToolsManager::RuntimePropertyChanged(RenderViewHost* inspected_rvh, | 
| 154                                              const std::string& name, | 102                                              const std::string& name, | 
| 155                                              const std::string& value) { | 103                                              const std::string& value) { | 
| 156   RuntimePropertiesMap::iterator it = | 104   RuntimePropertiesMap::iterator it = | 
| 157       runtime_properties_map_.find(inspected_rvh); | 105       runtime_properties_map_.find(inspected_rvh); | 
| 158   if (it == runtime_properties_map_.end()) { | 106   if (it == runtime_properties_map_.end()) { | 
| 159     std::pair<RenderViewHost*, DevToolsRuntimeProperties> value( | 107     std::pair<RenderViewHost*, DevToolsRuntimeProperties> value( | 
| 160         inspected_rvh, | 108         inspected_rvh, | 
| 161         DevToolsRuntimeProperties()); | 109         DevToolsRuntimeProperties()); | 
| 162     it = runtime_properties_map_.insert(value).first; | 110     it = runtime_properties_map_.insert(value).first; | 
| 163   } | 111   } | 
| 164   it->second[name] = value; | 112   it->second[name] = value; | 
| 165 } | 113 } | 
| 166 | 114 | 
| 167 void DevToolsManager::InspectElement(RenderViewHost* inspected_rvh, | 115 void DevToolsManager::SendInspectElement(RenderViewHost* inspected_rvh, | 
| 168                                      int x, | 116                                          int x, | 
| 169                                      int y) { | 117                                          int y) { | 
| 170   IPC::Message* m = new DevToolsAgentMsg_InspectElement(x, y); | 118   IPC::Message* m = new DevToolsAgentMsg_InspectElement(x, y); | 
| 171   m->set_routing_id(inspected_rvh->routing_id()); | 119   m->set_routing_id(inspected_rvh->routing_id()); | 
| 172   inspected_rvh->Send(m); | 120   inspected_rvh->Send(m); | 
| 173   // TODO(loislo): we should initiate DevTools window opening from within |  | 
| 174   // renderer. Otherwise, we still can hit a race condition here. |  | 
| 175   OpenDevToolsWindow(inspected_rvh); |  | 
| 176 } | 121 } | 
| 177 | 122 | 
| 178 void DevToolsManager::ClientHostClosing(DevToolsClientHost* host) { | 123 void DevToolsManager::ClientHostClosing(DevToolsClientHost* host) { | 
| 179   RenderViewHost* inspected_rvh = GetInspectedRenderViewHost(host); | 124   RenderViewHost* inspected_rvh = GetInspectedRenderViewHost(host); | 
| 180   if (!inspected_rvh) { | 125   if (!inspected_rvh) { | 
| 181     // It might be in the list of orphan client hosts, remove it from there. | 126     // It might be in the list of orphan client hosts, remove it from there. | 
| 182     for (OrphanClientHosts::iterator it = orphan_client_hosts_.begin(); | 127     for (OrphanClientHosts::iterator it = orphan_client_hosts_.begin(); | 
| 183          it != orphan_client_hosts_.end(); ++it) { | 128          it != orphan_client_hosts_.end(); ++it) { | 
| 184       if (it->second.first == host) { | 129       if (it->second.first == host) { | 
| 185         orphan_client_hosts_.erase(it->first); | 130         orphan_client_hosts_.erase(it->first); | 
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 218   DevToolsClientHost* host = GetDevToolsClientHostFor(inspected_rvh); | 163   DevToolsClientHost* host = GetDevToolsClientHostFor(inspected_rvh); | 
| 219   if (!host) | 164   if (!host) | 
| 220     return; | 165     return; | 
| 221   UnbindClientHost(inspected_rvh, host); | 166   UnbindClientHost(inspected_rvh, host); | 
| 222   host->InspectedTabClosing(); | 167   host->InspectedTabClosing(); | 
| 223 } | 168 } | 
| 224 | 169 | 
| 225 void DevToolsManager::OnNavigatingToPendingEntry(RenderViewHost* rvh, | 170 void DevToolsManager::OnNavigatingToPendingEntry(RenderViewHost* rvh, | 
| 226                                                  RenderViewHost* dest_rvh, | 171                                                  RenderViewHost* dest_rvh, | 
| 227                                                  const GURL& gurl) { | 172                                                  const GURL& gurl) { | 
| 228   if (in_initial_show_) { |  | 
| 229     // Mute this even in case it is caused by the initial show routines. |  | 
| 230     return; |  | 
| 231   } |  | 
| 232 |  | 
| 233   int cookie = DetachClientHost(rvh); | 173   int cookie = DetachClientHost(rvh); | 
| 234   if (cookie != -1) { | 174   if (cookie != -1) { | 
| 235     // Navigating to URL in the inspected window. | 175     // Navigating to URL in the inspected window. | 
| 236     AttachClientHost(cookie, dest_rvh); | 176     AttachClientHost(cookie, dest_rvh); | 
| 237 | 177 | 
| 238     DevToolsClientHost* client_host = GetDevToolsClientHostFor(dest_rvh); | 178     DevToolsClientHost* client_host = GetDevToolsClientHostFor(dest_rvh); | 
| 239     client_host->FrameNavigating(gurl.spec()); | 179     client_host->FrameNavigating(gurl.spec()); | 
| 240 |  | 
| 241     return; |  | 
| 242   } |  | 
| 243 |  | 
| 244   // Iterate over client hosts and if there is one that has render view host |  | 
| 245   // changing, reopen entire client window (this must be caused by the user |  | 
| 246   // manually refreshing its content). |  | 
| 247   for (ClientHostToInspectedRvhMap::iterator it = |  | 
| 248            client_host_to_inspected_rvh_.begin(); |  | 
| 249        it != client_host_to_inspected_rvh_.end(); ++it) { |  | 
| 250     DevToolsWindow* window = it->first->AsDevToolsWindow(); |  | 
| 251     if (window && window->GetRenderViewHost() == rvh) { |  | 
| 252       inspected_rvh_for_reopen_ = it->second; |  | 
| 253       MessageLoop::current()->PostTask(FROM_HERE, |  | 
| 254           NewRunnableMethod(this, |  | 
| 255                             &DevToolsManager::ForceReopenWindow)); |  | 
| 256       return; |  | 
| 257     } |  | 
| 258   } | 180   } | 
| 259 } | 181 } | 
| 260 | 182 | 
| 261 void DevToolsManager::TabReplaced(TabContentsWrapper* old_tab, | 183 void DevToolsManager::TabReplaced(TabContentsWrapper* old_tab, | 
| 262                                   TabContentsWrapper* new_tab) { | 184                                   TabContentsWrapper* new_tab) { | 
| 263   RenderViewHost* old_rvh = old_tab->tab_contents()->render_view_host(); | 185   RenderViewHost* old_rvh = old_tab->tab_contents()->render_view_host(); | 
| 264   DevToolsClientHost* client_host = GetDevToolsClientHostFor(old_rvh); | 186   DevToolsClientHost* client_host = GetDevToolsClientHostFor(old_rvh); | 
| 265   if (!client_host) | 187   if (!client_host) | 
| 266     return;  // Didn't know about old_tab. | 188     return;  // Didn't know about old_tab. | 
| 267   int cookie = DetachClientHost(old_rvh); | 189   int cookie = DetachClientHost(old_rvh); | 
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 319 } | 241 } | 
| 320 | 242 | 
| 321 void DevToolsManager::SendDetachToAgent(RenderViewHost* inspected_rvh) { | 243 void DevToolsManager::SendDetachToAgent(RenderViewHost* inspected_rvh) { | 
| 322   if (inspected_rvh) { | 244   if (inspected_rvh) { | 
| 323     IPC::Message* m = new DevToolsAgentMsg_Detach(); | 245     IPC::Message* m = new DevToolsAgentMsg_Detach(); | 
| 324     m->set_routing_id(inspected_rvh->routing_id()); | 246     m->set_routing_id(inspected_rvh->routing_id()); | 
| 325     inspected_rvh->Send(m); | 247     inspected_rvh->Send(m); | 
| 326   } | 248   } | 
| 327 } | 249 } | 
| 328 | 250 | 
| 329 void DevToolsManager::ForceReopenWindow() { |  | 
| 330   if (inspected_rvh_for_reopen_) { |  | 
| 331     RenderViewHost* inspected_rvn = inspected_rvh_for_reopen_; |  | 
| 332     UnregisterDevToolsClientHostFor(inspected_rvn); |  | 
| 333     OpenDevToolsWindow(inspected_rvn); |  | 
| 334   } |  | 
| 335 } |  | 
| 336 |  | 
| 337 DevToolsClientHost* DevToolsManager::FindOwnerDevToolsClientHost( |  | 
| 338     RenderViewHost* client_rvh) { |  | 
| 339   for (InspectedRvhToClientHostMap::iterator it = |  | 
| 340            inspected_rvh_to_client_host_.begin(); |  | 
| 341        it != inspected_rvh_to_client_host_.end(); |  | 
| 342        ++it) { |  | 
| 343     DevToolsWindow* win = it->second->AsDevToolsWindow(); |  | 
| 344     if (!win) |  | 
| 345       continue; |  | 
| 346     if (client_rvh == win->GetRenderViewHost()) |  | 
| 347       return it->second; |  | 
| 348   } |  | 
| 349   return NULL; |  | 
| 350 } |  | 
| 351 |  | 
| 352 void DevToolsManager::ReopenWindow(RenderViewHost* client_rvh, bool docked) { |  | 
| 353   DevToolsClientHost* client_host = FindOwnerDevToolsClientHost(client_rvh); |  | 
| 354   if (!client_host) |  | 
| 355     return; |  | 
| 356   RenderViewHost* inspected_rvh = GetInspectedRenderViewHost(client_host); |  | 
| 357   DCHECK(inspected_rvh); |  | 
| 358   inspected_rvh->process()->profile()->GetPrefs()->SetBoolean( |  | 
| 359       prefs::kDevToolsOpenDocked, docked); |  | 
| 360 |  | 
| 361   DevToolsWindow* window = client_host->AsDevToolsWindow(); |  | 
| 362   DCHECK(window); |  | 
| 363   window->SetDocked(docked); |  | 
| 364 } |  | 
| 365 |  | 
| 366 void DevToolsManager::ToggleDevToolsWindow( |  | 
| 367     RenderViewHost* inspected_rvh, |  | 
| 368     bool force_open, |  | 
| 369     DevToolsToggleAction action) { |  | 
| 370   bool do_open = force_open; |  | 
| 371   DevToolsClientHost* host = GetDevToolsClientHostFor(inspected_rvh); |  | 
| 372 |  | 
| 373   if (host != NULL && host->AsDevToolsWindow() == NULL) { |  | 
| 374     // Break remote debugging / extension debugging session. |  | 
| 375     UnregisterDevToolsClientHostFor(inspected_rvh); |  | 
| 376     host = NULL; |  | 
| 377   } |  | 
| 378 |  | 
| 379   if (!host) { |  | 
| 380     bool docked = inspected_rvh->process()->profile()->GetPrefs()-> |  | 
| 381         GetBoolean(prefs::kDevToolsOpenDocked); |  | 
| 382     host = new DevToolsWindow( |  | 
| 383         inspected_rvh->site_instance()->browsing_instance()->profile(), |  | 
| 384         inspected_rvh, |  | 
| 385         docked); |  | 
| 386     RegisterDevToolsClientHostFor(inspected_rvh, host); |  | 
| 387     do_open = true; |  | 
| 388   } |  | 
| 389 |  | 
| 390   DevToolsWindow* window = host->AsDevToolsWindow(); |  | 
| 391   // If window is docked and visible, we hide it on toggle. If window is |  | 
| 392   // undocked, we show (activate) it. |  | 
| 393   if (!window->is_docked() || do_open) { |  | 
| 394     AutoReset<bool> auto_reset_in_initial_show(&in_initial_show_, true); |  | 
| 395     window->Show(action); |  | 
| 396   } else { |  | 
| 397     UnregisterDevToolsClientHostFor(inspected_rvh); |  | 
| 398   } |  | 
| 399 } |  | 
| 400 |  | 
| 401 void DevToolsManager::BindClientHost( | 251 void DevToolsManager::BindClientHost( | 
| 402     RenderViewHost* inspected_rvh, | 252     RenderViewHost* inspected_rvh, | 
| 403     DevToolsClientHost* client_host, | 253     DevToolsClientHost* client_host, | 
| 404     const DevToolsRuntimeProperties& runtime_properties) { | 254     const DevToolsRuntimeProperties& runtime_properties) { | 
| 405   DCHECK(inspected_rvh_to_client_host_.find(inspected_rvh) == | 255   DCHECK(inspected_rvh_to_client_host_.find(inspected_rvh) == | 
| 406       inspected_rvh_to_client_host_.end()); | 256       inspected_rvh_to_client_host_.end()); | 
| 407   DCHECK(client_host_to_inspected_rvh_.find(client_host) == | 257   DCHECK(client_host_to_inspected_rvh_.find(client_host) == | 
| 408       client_host_to_inspected_rvh_.end()); | 258       client_host_to_inspected_rvh_.end()); | 
| 409 | 259 | 
| 410   if (client_host_to_inspected_rvh_.empty()) { | 260   if (client_host_to_inspected_rvh_.empty()) { | 
| (...skipping 19 matching lines...) Expand all  Loading... | 
| 430   client_host_to_inspected_rvh_.erase(client_host); | 280   client_host_to_inspected_rvh_.erase(client_host); | 
| 431   runtime_properties_map_.erase(inspected_rvh); | 281   runtime_properties_map_.erase(inspected_rvh); | 
| 432 | 282 | 
| 433   if (client_host_to_inspected_rvh_.empty()) { | 283   if (client_host_to_inspected_rvh_.empty()) { | 
| 434     BrowserThread::PostTask( | 284     BrowserThread::PostTask( | 
| 435         BrowserThread::IO, | 285         BrowserThread::IO, | 
| 436         FROM_HERE, | 286         FROM_HERE, | 
| 437         NewRunnableFunction(&DevToolsNetLogObserver::Detach)); | 287         NewRunnableFunction(&DevToolsNetLogObserver::Detach)); | 
| 438   } | 288   } | 
| 439   SendDetachToAgent(inspected_rvh); | 289   SendDetachToAgent(inspected_rvh); | 
| 440   if (inspected_rvh_for_reopen_ == inspected_rvh) |  | 
| 441     inspected_rvh_for_reopen_ = NULL; |  | 
| 442 | 290 | 
| 443   int process_id = inspected_rvh->process()->id(); | 291   int process_id = inspected_rvh->process()->id(); | 
| 444   for (InspectedRvhToClientHostMap::iterator it = | 292   for (InspectedRvhToClientHostMap::iterator it = | 
| 445            inspected_rvh_to_client_host_.begin(); | 293            inspected_rvh_to_client_host_.begin(); | 
| 446        it != inspected_rvh_to_client_host_.end(); | 294        it != inspected_rvh_to_client_host_.end(); | 
| 447        ++it) { | 295        ++it) { | 
| 448     if (it->first->process()->id() == process_id) | 296     if (it->first->process()->id() == process_id) | 
| 449       return; | 297       return; | 
| 450   } | 298   } | 
| 451   // We've disconnected from the last renderer -> revoke cookie permissions. | 299   // We've disconnected from the last renderer -> revoke cookie permissions. | 
| 452   ChildProcessSecurityPolicy::GetInstance()->RevokeReadRawCookies(process_id); | 300   ChildProcessSecurityPolicy::GetInstance()->RevokeReadRawCookies(process_id); | 
| 453 } | 301 } | 
| 454 | 302 | 
| 455 void DevToolsManager::CloseAllClientHosts() { | 303 void DevToolsManager::CloseAllClientHosts() { | 
| 456   std::vector<RenderViewHost*> rhvs; | 304   std::vector<RenderViewHost*> rhvs; | 
| 457   for (InspectedRvhToClientHostMap::iterator it = | 305   for (InspectedRvhToClientHostMap::iterator it = | 
| 458            inspected_rvh_to_client_host_.begin(); | 306            inspected_rvh_to_client_host_.begin(); | 
| 459        it != inspected_rvh_to_client_host_.end(); ++it) { | 307        it != inspected_rvh_to_client_host_.end(); ++it) { | 
| 460     rhvs.push_back(it->first); | 308     rhvs.push_back(it->first); | 
| 461   } | 309   } | 
| 462   for (std::vector<RenderViewHost*>::iterator it = rhvs.begin(); | 310   for (std::vector<RenderViewHost*>::iterator it = rhvs.begin(); | 
| 463        it != rhvs.end(); ++it) { | 311        it != rhvs.end(); ++it) { | 
| 464     UnregisterDevToolsClientHostFor(*it); | 312     UnregisterDevToolsClientHostFor(*it); | 
| 465   } | 313   } | 
| 466 } | 314 } | 
| OLD | NEW | 
|---|