OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "chrome/browser/debugger/devtools_manager.h" | 5 #include "chrome/browser/debugger/devtools_manager.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 | 124 |
125 void DevToolsManager::RequestDockWindow(RenderViewHost* client_rvh) { | 125 void DevToolsManager::RequestDockWindow(RenderViewHost* client_rvh) { |
126 ReopenWindow(client_rvh, true); | 126 ReopenWindow(client_rvh, true); |
127 } | 127 } |
128 | 128 |
129 void DevToolsManager::RequestUndockWindow(RenderViewHost* client_rvh) { | 129 void DevToolsManager::RequestUndockWindow(RenderViewHost* client_rvh) { |
130 ReopenWindow(client_rvh, false); | 130 ReopenWindow(client_rvh, false); |
131 } | 131 } |
132 | 132 |
133 void DevToolsManager::OpenDevToolsWindow(RenderViewHost* inspected_rvh) { | 133 void DevToolsManager::OpenDevToolsWindow(RenderViewHost* inspected_rvh) { |
134 ToggleDevToolsWindow(inspected_rvh, true, false); | 134 ToggleDevToolsWindow( |
| 135 inspected_rvh, |
| 136 true, |
| 137 DEVTOOLS_TOGGLE_ACTION_NONE); |
135 } | 138 } |
136 | 139 |
137 void DevToolsManager::ToggleDevToolsWindow(RenderViewHost* inspected_rvh, | 140 void DevToolsManager::ToggleDevToolsWindow( |
138 bool open_console) { | 141 RenderViewHost* inspected_rvh, |
139 ToggleDevToolsWindow(inspected_rvh, false, open_console); | 142 DevToolsToggleAction action) { |
| 143 ToggleDevToolsWindow(inspected_rvh, false, action); |
140 } | 144 } |
141 | 145 |
142 void DevToolsManager::RuntimeFeatureStateChanged(RenderViewHost* inspected_rvh, | 146 void DevToolsManager::RuntimeFeatureStateChanged(RenderViewHost* inspected_rvh, |
143 const std::string& feature, | 147 const std::string& feature, |
144 bool enabled) { | 148 bool enabled) { |
145 RuntimeFeaturesMap::iterator it = runtime_features_map_.find(inspected_rvh); | 149 RuntimeFeaturesMap::iterator it = runtime_features_map_.find(inspected_rvh); |
146 if (it == runtime_features_map_.end()) { | 150 if (it == runtime_features_map_.end()) { |
147 std::pair<RenderViewHost*, std::set<std::string> > value( | 151 std::pair<RenderViewHost*, std::set<std::string> > value( |
148 inspected_rvh, | 152 inspected_rvh, |
149 std::set<std::string>()); | 153 std::set<std::string>()); |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 RenderViewHost* inspected_rvh = GetInspectedRenderViewHost(client_host); | 342 RenderViewHost* inspected_rvh = GetInspectedRenderViewHost(client_host); |
339 DCHECK(inspected_rvh); | 343 DCHECK(inspected_rvh); |
340 inspected_rvh->process()->profile()->GetPrefs()->SetBoolean( | 344 inspected_rvh->process()->profile()->GetPrefs()->SetBoolean( |
341 prefs::kDevToolsOpenDocked, docked); | 345 prefs::kDevToolsOpenDocked, docked); |
342 | 346 |
343 DevToolsWindow* window = client_host->AsDevToolsWindow(); | 347 DevToolsWindow* window = client_host->AsDevToolsWindow(); |
344 DCHECK(window); | 348 DCHECK(window); |
345 window->SetDocked(docked); | 349 window->SetDocked(docked); |
346 } | 350 } |
347 | 351 |
348 void DevToolsManager::ToggleDevToolsWindow(RenderViewHost* inspected_rvh, | 352 void DevToolsManager::ToggleDevToolsWindow( |
349 bool force_open, | 353 RenderViewHost* inspected_rvh, |
350 bool open_console) { | 354 bool force_open, |
| 355 DevToolsToggleAction action) { |
351 bool do_open = force_open; | 356 bool do_open = force_open; |
352 DevToolsClientHost* host = GetDevToolsClientHostFor(inspected_rvh); | 357 DevToolsClientHost* host = GetDevToolsClientHostFor(inspected_rvh); |
353 if (!host) { | 358 if (!host) { |
354 bool docked = inspected_rvh->process()->profile()->GetPrefs()-> | 359 bool docked = inspected_rvh->process()->profile()->GetPrefs()-> |
355 GetBoolean(prefs::kDevToolsOpenDocked); | 360 GetBoolean(prefs::kDevToolsOpenDocked); |
356 host = new DevToolsWindow( | 361 host = new DevToolsWindow( |
357 inspected_rvh->site_instance()->browsing_instance()->profile(), | 362 inspected_rvh->site_instance()->browsing_instance()->profile(), |
358 inspected_rvh, | 363 inspected_rvh, |
359 docked); | 364 docked); |
360 RegisterDevToolsClientHostFor(inspected_rvh, host); | 365 RegisterDevToolsClientHostFor(inspected_rvh, host); |
361 do_open = true; | 366 do_open = true; |
362 } | 367 } |
363 DevToolsWindow* window = host->AsDevToolsWindow(); | 368 DevToolsWindow* window = host->AsDevToolsWindow(); |
364 if (!window) | 369 if (!window) |
365 return; | 370 return; |
366 | 371 |
367 // If window is docked and visible, we hide it on toggle. If window is | 372 // If window is docked and visible, we hide it on toggle. If window is |
368 // undocked, we show (activate) it. | 373 // undocked, we show (activate) it. |
369 if (!window->is_docked() || do_open) { | 374 if (!window->is_docked() || do_open) { |
370 AutoReset<bool> auto_reset_in_initial_show(&in_initial_show_, true); | 375 AutoReset<bool> auto_reset_in_initial_show(&in_initial_show_, true); |
371 window->Show(open_console); | 376 window->Show(action); |
372 } else | 377 } else { |
373 UnregisterDevToolsClientHostFor(inspected_rvh); | 378 UnregisterDevToolsClientHostFor(inspected_rvh); |
| 379 } |
374 } | 380 } |
375 | 381 |
376 void DevToolsManager::BindClientHost(RenderViewHost* inspected_rvh, | 382 void DevToolsManager::BindClientHost(RenderViewHost* inspected_rvh, |
377 DevToolsClientHost* client_host, | 383 DevToolsClientHost* client_host, |
378 const RuntimeFeatures& runtime_features) { | 384 const RuntimeFeatures& runtime_features) { |
379 DCHECK(inspected_rvh_to_client_host_.find(inspected_rvh) == | 385 DCHECK(inspected_rvh_to_client_host_.find(inspected_rvh) == |
380 inspected_rvh_to_client_host_.end()); | 386 inspected_rvh_to_client_host_.end()); |
381 DCHECK(client_host_to_inspected_rvh_.find(client_host) == | 387 DCHECK(client_host_to_inspected_rvh_.find(client_host) == |
382 client_host_to_inspected_rvh_.end()); | 388 client_host_to_inspected_rvh_.end()); |
383 | 389 |
384 inspected_rvh_to_client_host_[inspected_rvh] = client_host; | 390 inspected_rvh_to_client_host_[inspected_rvh] = client_host; |
385 client_host_to_inspected_rvh_[client_host] = inspected_rvh; | 391 client_host_to_inspected_rvh_[client_host] = inspected_rvh; |
386 runtime_features_map_[inspected_rvh] = runtime_features; | 392 runtime_features_map_[inspected_rvh] = runtime_features; |
387 } | 393 } |
388 | 394 |
389 void DevToolsManager::UnbindClientHost(RenderViewHost* inspected_rvh, | 395 void DevToolsManager::UnbindClientHost(RenderViewHost* inspected_rvh, |
390 DevToolsClientHost* client_host) { | 396 DevToolsClientHost* client_host) { |
391 DCHECK(inspected_rvh_to_client_host_.find(inspected_rvh)->second == | 397 DCHECK(inspected_rvh_to_client_host_.find(inspected_rvh)->second == |
392 client_host); | 398 client_host); |
393 DCHECK(client_host_to_inspected_rvh_.find(client_host)->second == | 399 DCHECK(client_host_to_inspected_rvh_.find(client_host)->second == |
394 inspected_rvh); | 400 inspected_rvh); |
395 | 401 |
396 inspected_rvh_to_client_host_.erase(inspected_rvh); | 402 inspected_rvh_to_client_host_.erase(inspected_rvh); |
397 client_host_to_inspected_rvh_.erase(client_host); | 403 client_host_to_inspected_rvh_.erase(client_host); |
398 runtime_features_map_.erase(inspected_rvh); | 404 runtime_features_map_.erase(inspected_rvh); |
399 } | 405 } |
OLD | NEW |