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 542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
553 const scoped_refptr<content::DevToolsAgentHost>& agent_host, | 553 const scoped_refptr<content::DevToolsAgentHost>& agent_host, |
554 bool is_worker, | 554 bool is_worker, |
555 bool is_v8_only) { | 555 bool is_v8_only) { |
556 DevToolsWindow* window = FindDevToolsWindow(agent_host.get()); | 556 DevToolsWindow* window = FindDevToolsWindow(agent_host.get()); |
557 if (!window) { | 557 if (!window) { |
558 window = Create(profile, GURL(), nullptr, is_worker, is_v8_only, | 558 window = Create(profile, GURL(), nullptr, is_worker, is_v8_only, |
559 DevToolsUI::GetProxyURL(frontend_url).spec(), false, std::string()); | 559 DevToolsUI::GetProxyURL(frontend_url).spec(), false, std::string()); |
560 if (!window) | 560 if (!window) |
561 return; | 561 return; |
562 window->bindings_->AttachTo(agent_host); | 562 window->bindings_->AttachTo(agent_host); |
| 563 window->close_on_detach_ = false; |
563 } | 564 } |
564 | 565 |
565 window->ScheduleShow(DevToolsToggleAction::Show()); | 566 window->ScheduleShow(DevToolsToggleAction::Show()); |
566 } | 567 } |
567 | 568 |
568 // static | 569 // static |
569 void DevToolsWindow::ToggleDevToolsWindow( | 570 void DevToolsWindow::ToggleDevToolsWindow( |
570 content::WebContents* inspected_web_contents, | 571 content::WebContents* inspected_web_contents, |
571 bool force_open, | 572 bool force_open, |
572 const DevToolsToggleAction& action, | 573 const DevToolsToggleAction& action, |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
771 DevToolsUIBindings* bindings, | 772 DevToolsUIBindings* bindings, |
772 WebContents* inspected_web_contents, | 773 WebContents* inspected_web_contents, |
773 bool can_dock) | 774 bool can_dock) |
774 : profile_(profile), | 775 : profile_(profile), |
775 main_web_contents_(main_web_contents), | 776 main_web_contents_(main_web_contents), |
776 toolbox_web_contents_(nullptr), | 777 toolbox_web_contents_(nullptr), |
777 bindings_(bindings), | 778 bindings_(bindings), |
778 browser_(nullptr), | 779 browser_(nullptr), |
779 is_docked_(true), | 780 is_docked_(true), |
780 can_dock_(can_dock), | 781 can_dock_(can_dock), |
| 782 close_on_detach_(true), |
781 // This initialization allows external front-end to work without changes. | 783 // This initialization allows external front-end to work without changes. |
782 // We don't wait for docking call, but instead immediately show undocked. | 784 // We don't wait for docking call, but instead immediately show undocked. |
783 // Passing "dockSide=undocked" parameter ensures proper UI. | 785 // Passing "dockSide=undocked" parameter ensures proper UI. |
784 life_stage_(can_dock ? kNotLoaded : kIsDockedSet), | 786 life_stage_(can_dock ? kNotLoaded : kIsDockedSet), |
785 action_on_load_(DevToolsToggleAction::NoOp()), | 787 action_on_load_(DevToolsToggleAction::NoOp()), |
786 intercepted_page_beforeunload_(false), | 788 intercepted_page_beforeunload_(false), |
787 ready_for_test_(false) { | 789 ready_for_test_(false) { |
788 // Set up delegate, so we get fully-functional window immediately. | 790 // Set up delegate, so we get fully-functional window immediately. |
789 // It will not appear in UI though until |life_stage_ == kLoadCompleted|. | 791 // It will not appear in UI though until |life_stage_ == kLoadCompleted|. |
790 main_web_contents_->SetDelegate(this); | 792 main_web_contents_->SetDelegate(this); |
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1191 ui::PAGE_TRANSITION_LINK); | 1193 ui::PAGE_TRANSITION_LINK); |
1192 } | 1194 } |
1193 } | 1195 } |
1194 | 1196 |
1195 void DevToolsWindow::SetWhitelistedShortcuts( | 1197 void DevToolsWindow::SetWhitelistedShortcuts( |
1196 const std::string& message) { | 1198 const std::string& message) { |
1197 event_forwarder_->SetWhitelistedShortcuts(message); | 1199 event_forwarder_->SetWhitelistedShortcuts(message); |
1198 } | 1200 } |
1199 | 1201 |
1200 void DevToolsWindow::InspectedContentsClosing() { | 1202 void DevToolsWindow::InspectedContentsClosing() { |
| 1203 if (!close_on_detach_) |
| 1204 return; |
1201 intercepted_page_beforeunload_ = false; | 1205 intercepted_page_beforeunload_ = false; |
1202 life_stage_ = kClosing; | 1206 life_stage_ = kClosing; |
1203 main_web_contents_->ClosePage(); | 1207 main_web_contents_->ClosePage(); |
1204 } | 1208 } |
1205 | 1209 |
1206 InfoBarService* DevToolsWindow::GetInfoBarService() { | 1210 InfoBarService* DevToolsWindow::GetInfoBarService() { |
1207 return is_docked_ ? | 1211 return is_docked_ ? |
1208 InfoBarService::FromWebContents(GetInspectedWebContents()) : | 1212 InfoBarService::FromWebContents(GetInspectedWebContents()) : |
1209 InfoBarService::FromWebContents(main_web_contents_); | 1213 InfoBarService::FromWebContents(main_web_contents_); |
1210 } | 1214 } |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1370 bool DevToolsWindow::ReloadInspectedWebContents(bool bypass_cache) { | 1374 bool DevToolsWindow::ReloadInspectedWebContents(bool bypass_cache) { |
1371 // Only route reload via front-end if the agent is attached. | 1375 // Only route reload via front-end if the agent is attached. |
1372 WebContents* wc = GetInspectedWebContents(); | 1376 WebContents* wc = GetInspectedWebContents(); |
1373 if (!wc || wc->GetCrashedStatus() != base::TERMINATION_STATUS_STILL_RUNNING) | 1377 if (!wc || wc->GetCrashedStatus() != base::TERMINATION_STATUS_STILL_RUNNING) |
1374 return false; | 1378 return false; |
1375 base::FundamentalValue bypass_cache_value(bypass_cache); | 1379 base::FundamentalValue bypass_cache_value(bypass_cache); |
1376 bindings_->CallClientFunction("DevToolsAPI.reloadInspectedPage", | 1380 bindings_->CallClientFunction("DevToolsAPI.reloadInspectedPage", |
1377 &bypass_cache_value, nullptr, nullptr); | 1381 &bypass_cache_value, nullptr, nullptr); |
1378 return true; | 1382 return true; |
1379 } | 1383 } |
OLD | NEW |