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" |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/metrics/histogram_macros.h" | 12 #include "base/metrics/histogram_macros.h" |
| 13 #include "base/metrics/user_metrics.h" |
13 #include "base/time/time.h" | 14 #include "base/time/time.h" |
14 #include "base/values.h" | 15 #include "base/values.h" |
15 #include "chrome/browser/certificate_viewer.h" | 16 #include "chrome/browser/certificate_viewer.h" |
16 #include "chrome/browser/data_use_measurement/data_use_web_contents_observer.h" | 17 #include "chrome/browser/data_use_measurement/data_use_web_contents_observer.h" |
17 #include "chrome/browser/file_select_helper.h" | 18 #include "chrome/browser/file_select_helper.h" |
18 #include "chrome/browser/infobars/infobar_service.h" | 19 #include "chrome/browser/infobars/infobar_service.h" |
19 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
20 #include "chrome/browser/sessions/session_tab_helper.h" | 21 #include "chrome/browser/sessions/session_tab_helper.h" |
21 #include "chrome/browser/task_manager/web_contents_tags.h" | 22 #include "chrome/browser/task_manager/web_contents_tags.h" |
22 #include "chrome/browser/ui/browser.h" | 23 #include "chrome/browser/ui/browser.h" |
(...skipping 17 matching lines...) Expand all Loading... |
40 #include "content/public/browser/browser_thread.h" | 41 #include "content/public/browser/browser_thread.h" |
41 #include "content/public/browser/devtools_agent_host.h" | 42 #include "content/public/browser/devtools_agent_host.h" |
42 #include "content/public/browser/keyboard_event_processing_result.h" | 43 #include "content/public/browser/keyboard_event_processing_result.h" |
43 #include "content/public/browser/native_web_keyboard_event.h" | 44 #include "content/public/browser/native_web_keyboard_event.h" |
44 #include "content/public/browser/navigation_controller.h" | 45 #include "content/public/browser/navigation_controller.h" |
45 #include "content/public/browser/navigation_entry.h" | 46 #include "content/public/browser/navigation_entry.h" |
46 #include "content/public/browser/render_frame_host.h" | 47 #include "content/public/browser/render_frame_host.h" |
47 #include "content/public/browser/render_process_host.h" | 48 #include "content/public/browser/render_process_host.h" |
48 #include "content/public/browser/render_view_host.h" | 49 #include "content/public/browser/render_view_host.h" |
49 #include "content/public/browser/render_widget_host_view.h" | 50 #include "content/public/browser/render_widget_host_view.h" |
50 #include "content/public/browser/user_metrics.h" | |
51 #include "content/public/browser/web_contents.h" | 51 #include "content/public/browser/web_contents.h" |
52 #include "content/public/common/content_client.h" | 52 #include "content/public/common/content_client.h" |
53 #include "content/public/common/url_constants.h" | 53 #include "content/public/common/url_constants.h" |
54 #include "net/base/escape.h" | 54 #include "net/base/escape.h" |
55 #include "third_party/WebKit/public/platform/WebGestureEvent.h" | 55 #include "third_party/WebKit/public/platform/WebGestureEvent.h" |
56 #include "third_party/WebKit/public/platform/WebInputEvent.h" | 56 #include "third_party/WebKit/public/platform/WebInputEvent.h" |
57 #include "third_party/WebKit/public/public_features.h" | 57 #include "third_party/WebKit/public/public_features.h" |
58 #include "ui/base/page_transition_types.h" | 58 #include "ui/base/page_transition_types.h" |
59 #include "ui/events/keycodes/dom/keycode_converter.h" | 59 #include "ui/events/keycodes/dom/keycode_converter.h" |
60 #include "ui/events/keycodes/keyboard_code_conversion.h" | 60 #include "ui/events/keycodes/keyboard_code_conversion.h" |
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
460 if (!window) | 460 if (!window) |
461 return; | 461 return; |
462 window->bindings_->AttachTo(worker_agent); | 462 window->bindings_->AttachTo(worker_agent); |
463 } | 463 } |
464 window->ScheduleShow(DevToolsToggleAction::Show()); | 464 window->ScheduleShow(DevToolsToggleAction::Show()); |
465 } | 465 } |
466 | 466 |
467 // static | 467 // static |
468 DevToolsWindow* DevToolsWindow::CreateDevToolsWindowForWorker( | 468 DevToolsWindow* DevToolsWindow::CreateDevToolsWindowForWorker( |
469 Profile* profile) { | 469 Profile* profile) { |
470 content::RecordAction(base::UserMetricsAction("DevTools_InspectWorker")); | 470 base::RecordAction(base::UserMetricsAction("DevTools_InspectWorker")); |
471 return Create(profile, nullptr, kFrontendWorker, std::string(), false, "", | 471 return Create(profile, nullptr, kFrontendWorker, std::string(), false, "", |
472 ""); | 472 ""); |
473 } | 473 } |
474 | 474 |
475 // static | 475 // static |
476 void DevToolsWindow::OpenDevToolsWindow( | 476 void DevToolsWindow::OpenDevToolsWindow( |
477 content::WebContents* inspected_web_contents) { | 477 content::WebContents* inspected_web_contents) { |
478 ToggleDevToolsWindow( | 478 ToggleDevToolsWindow( |
479 inspected_web_contents, true, DevToolsToggleAction::Show(), ""); | 479 inspected_web_contents, true, DevToolsToggleAction::Show(), ""); |
480 } | 480 } |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
597 bool force_open, | 597 bool force_open, |
598 const DevToolsToggleAction& action, | 598 const DevToolsToggleAction& action, |
599 const std::string& settings) { | 599 const std::string& settings) { |
600 scoped_refptr<DevToolsAgentHost> agent( | 600 scoped_refptr<DevToolsAgentHost> agent( |
601 DevToolsAgentHost::GetOrCreateFor(inspected_web_contents)); | 601 DevToolsAgentHost::GetOrCreateFor(inspected_web_contents)); |
602 DevToolsWindow* window = FindDevToolsWindow(agent.get()); | 602 DevToolsWindow* window = FindDevToolsWindow(agent.get()); |
603 bool do_open = force_open; | 603 bool do_open = force_open; |
604 if (!window) { | 604 if (!window) { |
605 Profile* profile = Profile::FromBrowserContext( | 605 Profile* profile = Profile::FromBrowserContext( |
606 inspected_web_contents->GetBrowserContext()); | 606 inspected_web_contents->GetBrowserContext()); |
607 content::RecordAction( | 607 base::RecordAction(base::UserMetricsAction("DevTools_InspectRenderer")); |
608 base::UserMetricsAction("DevTools_InspectRenderer")); | |
609 std::string panel = ""; | 608 std::string panel = ""; |
610 switch (action.type()) { | 609 switch (action.type()) { |
611 case DevToolsToggleAction::kInspect: | 610 case DevToolsToggleAction::kInspect: |
612 case DevToolsToggleAction::kShowElementsPanel: | 611 case DevToolsToggleAction::kShowElementsPanel: |
613 panel = "elements"; | 612 panel = "elements"; |
614 break; | 613 break; |
615 case DevToolsToggleAction::kShowConsolePanel: | 614 case DevToolsToggleAction::kShowConsolePanel: |
616 panel = "console"; | 615 panel = "console"; |
617 break; | 616 break; |
618 case DevToolsToggleAction::kShow: | 617 case DevToolsToggleAction::kShow: |
(...skipping 789 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1408 bool DevToolsWindow::ReloadInspectedWebContents(bool bypass_cache) { | 1407 bool DevToolsWindow::ReloadInspectedWebContents(bool bypass_cache) { |
1409 // Only route reload via front-end if the agent is attached. | 1408 // Only route reload via front-end if the agent is attached. |
1410 WebContents* wc = GetInspectedWebContents(); | 1409 WebContents* wc = GetInspectedWebContents(); |
1411 if (!wc || wc->GetCrashedStatus() != base::TERMINATION_STATUS_STILL_RUNNING) | 1410 if (!wc || wc->GetCrashedStatus() != base::TERMINATION_STATUS_STILL_RUNNING) |
1412 return false; | 1411 return false; |
1413 base::Value bypass_cache_value(bypass_cache); | 1412 base::Value bypass_cache_value(bypass_cache); |
1414 bindings_->CallClientFunction("DevToolsAPI.reloadInspectedPage", | 1413 bindings_->CallClientFunction("DevToolsAPI.reloadInspectedPage", |
1415 &bypass_cache_value, nullptr, nullptr); | 1414 &bypass_cache_value, nullptr, nullptr); |
1416 return true; | 1415 return true; |
1417 } | 1416 } |
OLD | NEW |