| 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 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 578 return; | 578 return; |
| 579 window->bindings_->AttachTo(agent_host); | 579 window->bindings_->AttachTo(agent_host); |
| 580 window->close_on_detach_ = false; | 580 window->close_on_detach_ = false; |
| 581 } | 581 } |
| 582 | 582 |
| 583 window->ScheduleShow(DevToolsToggleAction::Show()); | 583 window->ScheduleShow(DevToolsToggleAction::Show()); |
| 584 } | 584 } |
| 585 | 585 |
| 586 // static | 586 // static |
| 587 void DevToolsWindow::OpenNodeFrontendWindow(Profile* profile) { | 587 void DevToolsWindow::OpenNodeFrontendWindow(Profile* profile) { |
| 588 for (DevToolsWindow* window : g_instances.Get()) { | |
| 589 if (window->frontend_type_ == kFrontendNode) { | |
| 590 window->ActivateWindow(); | |
| 591 return; | |
| 592 } | |
| 593 } | |
| 594 | |
| 595 DevToolsWindow* window = | 588 DevToolsWindow* window = |
| 596 Create(profile, nullptr, kFrontendNode, std::string(), false, | 589 Create(profile, nullptr, kFrontendNode, std::string(), false, |
| 597 std::string(), std::string()); | 590 std::string(), std::string()); |
| 598 if (!window) | 591 if (!window) |
| 599 return; | 592 return; |
| 600 window->bindings_->AttachTo(DevToolsAgentHost::CreateForDiscovery()); | 593 window->bindings_->AttachTo(DevToolsAgentHost::CreateForDiscovery()); |
| 601 window->ScheduleShow(DevToolsToggleAction::Show()); | 594 window->ScheduleShow(DevToolsToggleAction::Show()); |
| 602 } | 595 } |
| 603 | 596 |
| 604 // static | 597 // static |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 806 void DevToolsWindow::OnPageCloseCanceled(WebContents* contents) { | 799 void DevToolsWindow::OnPageCloseCanceled(WebContents* contents) { |
| 807 DevToolsWindow* window = | 800 DevToolsWindow* window = |
| 808 DevToolsWindow::GetInstanceForInspectedWebContents(contents); | 801 DevToolsWindow::GetInstanceForInspectedWebContents(contents); |
| 809 if (!window) | 802 if (!window) |
| 810 return; | 803 return; |
| 811 window->intercepted_page_beforeunload_ = false; | 804 window->intercepted_page_beforeunload_ = false; |
| 812 // Propagate to devtools opened on devtools if any. | 805 // Propagate to devtools opened on devtools if any. |
| 813 DevToolsWindow::OnPageCloseCanceled(window->main_web_contents_); | 806 DevToolsWindow::OnPageCloseCanceled(window->main_web_contents_); |
| 814 } | 807 } |
| 815 | 808 |
| 816 DevToolsWindow::DevToolsWindow(FrontendType frontend_type, | 809 DevToolsWindow::DevToolsWindow(Profile* profile, |
| 817 Profile* profile, | |
| 818 WebContents* main_web_contents, | 810 WebContents* main_web_contents, |
| 819 DevToolsUIBindings* bindings, | 811 DevToolsUIBindings* bindings, |
| 820 WebContents* inspected_web_contents, | 812 WebContents* inspected_web_contents, |
| 821 bool can_dock) | 813 bool can_dock) |
| 822 : frontend_type_(frontend_type), | 814 : profile_(profile), |
| 823 profile_(profile), | |
| 824 main_web_contents_(main_web_contents), | 815 main_web_contents_(main_web_contents), |
| 825 toolbox_web_contents_(nullptr), | 816 toolbox_web_contents_(nullptr), |
| 826 bindings_(bindings), | 817 bindings_(bindings), |
| 827 browser_(nullptr), | 818 browser_(nullptr), |
| 828 is_docked_(true), | 819 is_docked_(true), |
| 829 can_dock_(can_dock), | 820 can_dock_(can_dock), |
| 830 close_on_detach_(true), | 821 close_on_detach_(true), |
| 831 // This initialization allows external front-end to work without changes. | 822 // This initialization allows external front-end to work without changes. |
| 832 // We don't wait for docking call, but instead immediately show undocked. | 823 // We don't wait for docking call, but instead immediately show undocked. |
| 833 // Passing "dockSide=undocked" parameter ensures proper UI. | 824 // Passing "dockSide=undocked" parameter ensures proper UI. |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 908 WebContents::Create(WebContents::CreateParams(profile))); | 899 WebContents::Create(WebContents::CreateParams(profile))); |
| 909 main_web_contents->GetController().LoadURL( | 900 main_web_contents->GetController().LoadURL( |
| 910 DecorateFrontendURL(url), content::Referrer(), | 901 DecorateFrontendURL(url), content::Referrer(), |
| 911 ui::PAGE_TRANSITION_AUTO_TOPLEVEL, std::string()); | 902 ui::PAGE_TRANSITION_AUTO_TOPLEVEL, std::string()); |
| 912 DevToolsUIBindings* bindings = | 903 DevToolsUIBindings* bindings = |
| 913 DevToolsUIBindings::ForWebContents(main_web_contents.get()); | 904 DevToolsUIBindings::ForWebContents(main_web_contents.get()); |
| 914 if (!bindings) | 905 if (!bindings) |
| 915 return nullptr; | 906 return nullptr; |
| 916 if (!settings.empty()) | 907 if (!settings.empty()) |
| 917 SetPreferencesFromJson(profile, settings); | 908 SetPreferencesFromJson(profile, settings); |
| 918 return new DevToolsWindow(frontend_type, profile, main_web_contents.release(), | 909 return new DevToolsWindow(profile, main_web_contents.release(), bindings, |
| 919 bindings, inspected_web_contents, can_dock); | 910 inspected_web_contents, can_dock); |
| 920 } | 911 } |
| 921 | 912 |
| 922 // static | 913 // static |
| 923 GURL DevToolsWindow::GetDevToolsURL(Profile* profile, | 914 GURL DevToolsWindow::GetDevToolsURL(Profile* profile, |
| 924 FrontendType frontend_type, | 915 FrontendType frontend_type, |
| 925 const std::string& frontend_url, | 916 const std::string& frontend_url, |
| 926 bool can_dock, | 917 bool can_dock, |
| 927 const std::string& panel) { | 918 const std::string& panel) { |
| 928 std::string url(!frontend_url.empty() ? frontend_url | 919 std::string url(!frontend_url.empty() ? frontend_url |
| 929 : chrome::kChromeUIDevToolsURL); | 920 : chrome::kChromeUIDevToolsURL); |
| (...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1436 bool DevToolsWindow::ReloadInspectedWebContents(bool bypass_cache) { | 1427 bool DevToolsWindow::ReloadInspectedWebContents(bool bypass_cache) { |
| 1437 // Only route reload via front-end if the agent is attached. | 1428 // Only route reload via front-end if the agent is attached. |
| 1438 WebContents* wc = GetInspectedWebContents(); | 1429 WebContents* wc = GetInspectedWebContents(); |
| 1439 if (!wc || wc->GetCrashedStatus() != base::TERMINATION_STATUS_STILL_RUNNING) | 1430 if (!wc || wc->GetCrashedStatus() != base::TERMINATION_STATUS_STILL_RUNNING) |
| 1440 return false; | 1431 return false; |
| 1441 base::Value bypass_cache_value(bypass_cache); | 1432 base::Value bypass_cache_value(bypass_cache); |
| 1442 bindings_->CallClientFunction("DevToolsAPI.reloadInspectedPage", | 1433 bindings_->CallClientFunction("DevToolsAPI.reloadInspectedPage", |
| 1443 &bypass_cache_value, nullptr, nullptr); | 1434 &bypass_cache_value, nullptr, nullptr); |
| 1444 return true; | 1435 return true; |
| 1445 } | 1436 } |
| OLD | NEW |