| 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 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 640 window->ScheduleShow(action); | 640 window->ScheduleShow(action); |
| 641 else | 641 else |
| 642 window->CloseWindow(); | 642 window->CloseWindow(); |
| 643 } | 643 } |
| 644 | 644 |
| 645 // static | 645 // static |
| 646 void DevToolsWindow::InspectElement( | 646 void DevToolsWindow::InspectElement( |
| 647 content::RenderFrameHost* inspected_frame_host, | 647 content::RenderFrameHost* inspected_frame_host, |
| 648 int x, | 648 int x, |
| 649 int y) { | 649 int y) { |
| 650 WebContents* web_contents = |
| 651 WebContents::FromRenderFrameHost(inspected_frame_host); |
| 650 scoped_refptr<DevToolsAgentHost> agent( | 652 scoped_refptr<DevToolsAgentHost> agent( |
| 651 DevToolsAgentHost::GetOrCreateFor(inspected_frame_host)); | 653 DevToolsAgentHost::GetOrCreateFor(web_contents)); |
| 652 bool should_measure_time = FindDevToolsWindow(agent.get()) == NULL; | 654 bool should_measure_time = FindDevToolsWindow(agent.get()) == NULL; |
| 653 base::TimeTicks start_time = base::TimeTicks::Now(); | 655 base::TimeTicks start_time = base::TimeTicks::Now(); |
| 654 // TODO(loislo): we should initiate DevTools window opening from within | 656 // TODO(loislo): we should initiate DevTools window opening from within |
| 655 // renderer. Otherwise, we still can hit a race condition here. | 657 // renderer. Otherwise, we still can hit a race condition here. |
| 656 if (agent->GetType() == content::DevToolsAgentHost::kTypePage) { | 658 OpenDevToolsWindow(web_contents, DevToolsToggleAction::ShowElementsPanel()); |
| 657 OpenDevToolsWindow(agent->GetWebContents(), | |
| 658 DevToolsToggleAction::ShowElementsPanel()); | |
| 659 } else { | |
| 660 OpenDevToolsWindowForFrame(Profile::FromBrowserContext( | |
| 661 agent->GetBrowserContext()), agent); | |
| 662 } | |
| 663 DevToolsWindow* window = FindDevToolsWindow(agent.get()); | 659 DevToolsWindow* window = FindDevToolsWindow(agent.get()); |
| 664 if (window) { | 660 if (window) { |
| 665 agent->InspectElement(window->bindings_, x, y); | 661 agent->InspectElement(window->bindings_, x, y); |
| 666 if (should_measure_time) | 662 if (should_measure_time) |
| 667 window->inspect_element_start_time_ = start_time; | 663 window->inspect_element_start_time_ = start_time; |
| 668 } | 664 } |
| 669 } | 665 } |
| 670 | 666 |
| 671 void DevToolsWindow::ScheduleShow(const DevToolsToggleAction& action) { | 667 void DevToolsWindow::ScheduleShow(const DevToolsToggleAction& action) { |
| 672 if (life_stage_ == kLoadCompleted) { | 668 if (life_stage_ == kLoadCompleted) { |
| (...skipping 760 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1433 bool DevToolsWindow::ReloadInspectedWebContents(bool bypass_cache) { | 1429 bool DevToolsWindow::ReloadInspectedWebContents(bool bypass_cache) { |
| 1434 // Only route reload via front-end if the agent is attached. | 1430 // Only route reload via front-end if the agent is attached. |
| 1435 WebContents* wc = GetInspectedWebContents(); | 1431 WebContents* wc = GetInspectedWebContents(); |
| 1436 if (!wc || wc->GetCrashedStatus() != base::TERMINATION_STATUS_STILL_RUNNING) | 1432 if (!wc || wc->GetCrashedStatus() != base::TERMINATION_STATUS_STILL_RUNNING) |
| 1437 return false; | 1433 return false; |
| 1438 base::Value bypass_cache_value(bypass_cache); | 1434 base::Value bypass_cache_value(bypass_cache); |
| 1439 bindings_->CallClientFunction("DevToolsAPI.reloadInspectedPage", | 1435 bindings_->CallClientFunction("DevToolsAPI.reloadInspectedPage", |
| 1440 &bypass_cache_value, nullptr, nullptr); | 1436 &bypass_cache_value, nullptr, nullptr); |
| 1441 return true; | 1437 return true; |
| 1442 } | 1438 } |
| OLD | NEW |