| 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 #include <algorithm> | 6 #include <algorithm> |
| 7 | 7 |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
| 10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
| 11 #include "base/lazy_instance.h" | 11 #include "base/lazy_instance.h" |
| 12 #include "base/metrics/histogram.h" |
| 12 #include "base/prefs/scoped_user_pref_update.h" | 13 #include "base/prefs/scoped_user_pref_update.h" |
| 13 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
| 14 #include "base/strings/string_util.h" | 15 #include "base/strings/string_util.h" |
| 15 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
| 17 #include "base/time/time.h" |
| 16 #include "base/values.h" | 18 #include "base/values.h" |
| 17 #include "chrome/browser/browser_process.h" | 19 #include "chrome/browser/browser_process.h" |
| 18 #include "chrome/browser/chrome_notification_types.h" | 20 #include "chrome/browser/chrome_notification_types.h" |
| 19 #include "chrome/browser/extensions/api/debugger/debugger_api.h" | 21 #include "chrome/browser/extensions/api/debugger/debugger_api.h" |
| 20 #include "chrome/browser/extensions/extension_service.h" | 22 #include "chrome/browser/extensions/extension_service.h" |
| 21 #include "chrome/browser/extensions/extension_system.h" | 23 #include "chrome/browser/extensions/extension_system.h" |
| 22 #include "chrome/browser/extensions/extension_web_contents_observer.h" | 24 #include "chrome/browser/extensions/extension_web_contents_observer.h" |
| 23 #include "chrome/browser/file_select_helper.h" | 25 #include "chrome/browser/file_select_helper.h" |
| 24 #include "chrome/browser/infobars/confirm_infobar_delegate.h" | 26 #include "chrome/browser/infobars/confirm_infobar_delegate.h" |
| 25 #include "chrome/browser/infobars/infobar.h" | 27 #include "chrome/browser/infobars/infobar.h" |
| (...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 460 return window; | 462 return window; |
| 461 } | 463 } |
| 462 | 464 |
| 463 // static | 465 // static |
| 464 void DevToolsWindow::InspectElement(content::RenderViewHost* inspected_rvh, | 466 void DevToolsWindow::InspectElement(content::RenderViewHost* inspected_rvh, |
| 465 int x, | 467 int x, |
| 466 int y) { | 468 int y) { |
| 467 scoped_refptr<DevToolsAgentHost> agent( | 469 scoped_refptr<DevToolsAgentHost> agent( |
| 468 DevToolsAgentHost::GetOrCreateFor(inspected_rvh)); | 470 DevToolsAgentHost::GetOrCreateFor(inspected_rvh)); |
| 469 agent->InspectElement(x, y); | 471 agent->InspectElement(x, y); |
| 472 bool should_measure_time = FindDevToolsWindow(agent.get()) == NULL; |
| 473 base::TimeTicks start_time = base::TimeTicks::Now(); |
| 470 // TODO(loislo): we should initiate DevTools window opening from within | 474 // TODO(loislo): we should initiate DevTools window opening from within |
| 471 // renderer. Otherwise, we still can hit a race condition here. | 475 // renderer. Otherwise, we still can hit a race condition here. |
| 472 OpenDevToolsWindow(inspected_rvh); | 476 DevToolsWindow* window = OpenDevToolsWindow(inspected_rvh); |
| 477 if (should_measure_time) |
| 478 window->inspect_element_start_time_ = start_time; |
| 473 } | 479 } |
| 474 | 480 |
| 475 // static | 481 // static |
| 476 int DevToolsWindow::GetMinimizedHeight() { | 482 int DevToolsWindow::GetMinimizedHeight() { |
| 477 const int kMinimizedDevToolsHeight = 24; | 483 const int kMinimizedDevToolsHeight = 24; |
| 478 return kMinimizedDevToolsHeight; | 484 return kMinimizedDevToolsHeight; |
| 479 } | 485 } |
| 480 | 486 |
| 481 void DevToolsWindow::InspectedContentsClosing() { | 487 void DevToolsWindow::InspectedContentsClosing() { |
| 482 intercepted_page_beforeunload_ = false; | 488 intercepted_page_beforeunload_ = false; |
| (...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 992 | 998 |
| 993 contents_insets_ = gfx::Insets(top, left, bottom, right); | 999 contents_insets_ = gfx::Insets(top, left, bottom, right); |
| 994 if (is_docked_) { | 1000 if (is_docked_) { |
| 995 // Update inspected window. | 1001 // Update inspected window. |
| 996 BrowserWindow* inspected_window = GetInspectedBrowserWindow(); | 1002 BrowserWindow* inspected_window = GetInspectedBrowserWindow(); |
| 997 if (inspected_window) | 1003 if (inspected_window) |
| 998 inspected_window->UpdateDevTools(); | 1004 inspected_window->UpdateDevTools(); |
| 999 } | 1005 } |
| 1000 } | 1006 } |
| 1001 | 1007 |
| 1008 void DevToolsWindow::InspectElementCompleted() { |
| 1009 if (!inspect_element_start_time_.is_null()) { |
| 1010 UMA_HISTOGRAM_TIMES("DevTools.InspectElement", |
| 1011 base::TimeTicks::Now() - inspect_element_start_time_); |
| 1012 inspect_element_start_time_ = base::TimeTicks(); |
| 1013 } |
| 1014 } |
| 1015 |
| 1002 void DevToolsWindow::MoveWindow(int x, int y) { | 1016 void DevToolsWindow::MoveWindow(int x, int y) { |
| 1003 if (!is_docked_) { | 1017 if (!is_docked_) { |
| 1004 gfx::Rect bounds = browser_->window()->GetBounds(); | 1018 gfx::Rect bounds = browser_->window()->GetBounds(); |
| 1005 bounds.Offset(x, y); | 1019 bounds.Offset(x, y); |
| 1006 browser_->window()->SetBounds(bounds); | 1020 browser_->window()->SetBounds(bounds); |
| 1007 } | 1021 } |
| 1008 } | 1022 } |
| 1009 | 1023 |
| 1010 void DevToolsWindow::SetIsDockedAndShowImmediatelyForTest(bool is_docked) { | 1024 void DevToolsWindow::SetIsDockedAndShowImmediatelyForTest(bool is_docked) { |
| 1011 DCHECK(!is_docked || can_dock_); | 1025 DCHECK(!is_docked || can_dock_); |
| (...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1473 if (load_state_ == kLoadCompleted) | 1487 if (load_state_ == kLoadCompleted) |
| 1474 LoadCompleted(); | 1488 LoadCompleted(); |
| 1475 } | 1489 } |
| 1476 | 1490 |
| 1477 void DevToolsWindow::LoadCompleted() { | 1491 void DevToolsWindow::LoadCompleted() { |
| 1478 Show(action_on_load_); | 1492 Show(action_on_load_); |
| 1479 action_on_load_ = DevToolsToggleAction::NoOp(); | 1493 action_on_load_ = DevToolsToggleAction::NoOp(); |
| 1480 UpdateTheme(); | 1494 UpdateTheme(); |
| 1481 AddDevToolsExtensionsToClient(); | 1495 AddDevToolsExtensionsToClient(); |
| 1482 } | 1496 } |
| OLD | NEW |