OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/devtools/devtools_window.h" | 5 #include "chrome/browser/devtools/devtools_window.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 | 60 |
61 namespace { | 61 namespace { |
62 | 62 |
63 typedef std::vector<DevToolsWindow*> DevToolsWindows; | 63 typedef std::vector<DevToolsWindow*> DevToolsWindows; |
64 base::LazyInstance<DevToolsWindows>::Leaky g_instances = | 64 base::LazyInstance<DevToolsWindows>::Leaky g_instances = |
65 LAZY_INSTANCE_INITIALIZER; | 65 LAZY_INSTANCE_INITIALIZER; |
66 | 66 |
67 static const char kKeyUpEventName[] = "keyup"; | 67 static const char kKeyUpEventName[] = "keyup"; |
68 static const char kKeyDownEventName[] = "keydown"; | 68 static const char kKeyDownEventName[] = "keydown"; |
69 | 69 |
| 70 void OpenDevToolsWindowForWorkerWithBrowserContext( |
| 71 content::BrowserContext* browser_context, |
| 72 DevToolsAgentHost* worker_agent) { |
| 73 DevToolsWindow::OpenDevToolsWindowForWorker( |
| 74 Profile::FromBrowserContext(browser_context), worker_agent); |
| 75 } |
| 76 |
70 } // namespace | 77 } // namespace |
71 | 78 |
72 // DevToolsEventForwarder ----------------------------------------------------- | 79 // DevToolsEventForwarder ----------------------------------------------------- |
73 | 80 |
74 class DevToolsEventForwarder { | 81 class DevToolsEventForwarder { |
75 public: | 82 public: |
76 explicit DevToolsEventForwarder(DevToolsWindow* window) | 83 explicit DevToolsEventForwarder(DevToolsWindow* window) |
77 : devtools_window_(window) {} | 84 : devtools_window_(window) {} |
78 | 85 |
79 // Registers whitelisted shortcuts with the forwarder. | 86 // Registers whitelisted shortcuts with the forwarder. |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 window = DevToolsWindow::CreateDevToolsWindowForWorker(profile); | 313 window = DevToolsWindow::CreateDevToolsWindowForWorker(profile); |
307 // Will disconnect the current client host if there is one. | 314 // Will disconnect the current client host if there is one. |
308 content::DevToolsManager::GetInstance()->RegisterDevToolsClientHostFor( | 315 content::DevToolsManager::GetInstance()->RegisterDevToolsClientHostFor( |
309 worker_agent, window->bindings_->frontend_host()); | 316 worker_agent, window->bindings_->frontend_host()); |
310 } | 317 } |
311 window->ScheduleShow(DevToolsToggleAction::Show()); | 318 window->ScheduleShow(DevToolsToggleAction::Show()); |
312 return window; | 319 return window; |
313 } | 320 } |
314 | 321 |
315 // static | 322 // static |
| 323 content::DevToolsManager::WindowOpenCallback |
| 324 DevToolsWindow::GetOpenDevToolsWindowForWorkerCallback() { |
| 325 return base::Bind(&OpenDevToolsWindowForWorkerWithBrowserContext); |
| 326 } |
| 327 |
| 328 // static |
316 DevToolsWindow* DevToolsWindow::CreateDevToolsWindowForWorker( | 329 DevToolsWindow* DevToolsWindow::CreateDevToolsWindowForWorker( |
317 Profile* profile) { | 330 Profile* profile) { |
318 content::RecordAction(base::UserMetricsAction("DevTools_InspectWorker")); | 331 content::RecordAction(base::UserMetricsAction("DevTools_InspectWorker")); |
319 return Create(profile, GURL(), NULL, true, false, false); | 332 return Create(profile, GURL(), NULL, true, false, false); |
320 } | 333 } |
321 | 334 |
322 // static | 335 // static |
323 DevToolsWindow* DevToolsWindow::OpenDevToolsWindow( | 336 DevToolsWindow* DevToolsWindow::OpenDevToolsWindow( |
324 content::RenderViewHost* inspected_rvh) { | 337 content::RenderViewHost* inspected_rvh) { |
325 return ToggleDevToolsWindow( | 338 return ToggleDevToolsWindow( |
(...skipping 828 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1154 closure.Run(); | 1167 closure.Run(); |
1155 return; | 1168 return; |
1156 } | 1169 } |
1157 load_completed_callback_ = closure; | 1170 load_completed_callback_ = closure; |
1158 } | 1171 } |
1159 | 1172 |
1160 bool DevToolsWindow::ForwardKeyboardEvent( | 1173 bool DevToolsWindow::ForwardKeyboardEvent( |
1161 const content::NativeWebKeyboardEvent& event) { | 1174 const content::NativeWebKeyboardEvent& event) { |
1162 return event_forwarder_->ForwardEvent(event); | 1175 return event_forwarder_->ForwardEvent(event); |
1163 } | 1176 } |
OLD | NEW |