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/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
513 window->CloseWindow(); | 513 window->CloseWindow(); |
514 } | 514 } |
515 | 515 |
516 // static | 516 // static |
517 void DevToolsWindow::InspectElement( | 517 void DevToolsWindow::InspectElement( |
518 content::RenderFrameHost* inspected_frame_host, | 518 content::RenderFrameHost* inspected_frame_host, |
519 int x, | 519 int x, |
520 int y) { | 520 int y) { |
521 scoped_refptr<DevToolsAgentHost> agent( | 521 scoped_refptr<DevToolsAgentHost> agent( |
522 DevToolsAgentHost::GetOrCreateFor(inspected_frame_host)); | 522 DevToolsAgentHost::GetOrCreateFor(inspected_frame_host)); |
523 agent->InspectElement(x, y); | |
524 bool should_measure_time = FindDevToolsWindow(agent.get()) == NULL; | 523 bool should_measure_time = FindDevToolsWindow(agent.get()) == NULL; |
525 base::TimeTicks start_time = base::TimeTicks::Now(); | 524 base::TimeTicks start_time = base::TimeTicks::Now(); |
526 // TODO(loislo): we should initiate DevTools window opening from within | 525 // TODO(loislo): we should initiate DevTools window opening from within |
527 // renderer. Otherwise, we still can hit a race condition here. | 526 // renderer. Otherwise, we still can hit a race condition here. |
528 if (agent->GetType() == content::DevToolsAgentHost::TYPE_WEB_CONTENTS) { | 527 if (agent->GetType() == content::DevToolsAgentHost::TYPE_WEB_CONTENTS) { |
529 OpenDevToolsWindow(agent->GetWebContents()); | 528 OpenDevToolsWindow(agent->GetWebContents()); |
530 } else { | 529 } else { |
531 OpenDevToolsWindow(Profile::FromBrowserContext(agent->GetBrowserContext()), | 530 OpenDevToolsWindow(Profile::FromBrowserContext(agent->GetBrowserContext()), |
532 agent); | 531 agent); |
533 } | 532 } |
534 | 533 |
534 agent->InspectElement(x, y); | |
pfeldman
2015/11/13 17:38:12
Lets land this separately.
| |
535 | |
535 DevToolsWindow* window = FindDevToolsWindow(agent.get()); | 536 DevToolsWindow* window = FindDevToolsWindow(agent.get()); |
536 if (should_measure_time && window) | 537 if (should_measure_time && window) |
537 window->inspect_element_start_time_ = start_time; | 538 window->inspect_element_start_time_ = start_time; |
538 } | 539 } |
539 | 540 |
540 // static | 541 // static |
541 content::DevToolsExternalAgentProxyDelegate* | 542 content::DevToolsExternalAgentProxyDelegate* |
542 DevToolsWindow::CreateWebSocketAPIChannel(const std::string& path) { | 543 DevToolsWindow::CreateWebSocketAPIChannel(const std::string& path) { |
543 if (path.find("/devtools/frontend_api") != 0) | 544 if (path.find("/devtools/frontend_api") != 0) |
544 return nullptr; | 545 return nullptr; |
(...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1273 bool DevToolsWindow::ReloadInspectedWebContents(bool ignore_cache) { | 1274 bool DevToolsWindow::ReloadInspectedWebContents(bool ignore_cache) { |
1274 // Only route reload via front-end if the agent is attached. | 1275 // Only route reload via front-end if the agent is attached. |
1275 WebContents* wc = GetInspectedWebContents(); | 1276 WebContents* wc = GetInspectedWebContents(); |
1276 if (!wc || wc->GetCrashedStatus() != base::TERMINATION_STATUS_STILL_RUNNING) | 1277 if (!wc || wc->GetCrashedStatus() != base::TERMINATION_STATUS_STILL_RUNNING) |
1277 return false; | 1278 return false; |
1278 base::FundamentalValue ignore_cache_value(ignore_cache); | 1279 base::FundamentalValue ignore_cache_value(ignore_cache); |
1279 bindings_->CallClientFunction("DevToolsAPI.reloadInspectedPage", | 1280 bindings_->CallClientFunction("DevToolsAPI.reloadInspectedPage", |
1280 &ignore_cache_value, nullptr, nullptr); | 1281 &ignore_cache_value, nullptr, nullptr); |
1281 return true; | 1282 return true; |
1282 } | 1283 } |
OLD | NEW |