| 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/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 734 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 745 WebContents* inspected_web_contents = GetInspectedWebContents(); | 745 WebContents* inspected_web_contents = GetInspectedWebContents(); |
| 746 if (inspected_web_contents) { | 746 if (inspected_web_contents) { |
| 747 inspected_web_contents->GetDelegate()->AddNewContents( | 747 inspected_web_contents->GetDelegate()->AddNewContents( |
| 748 source, new_contents, disposition, initial_pos, user_gesture, | 748 source, new_contents, disposition, initial_pos, user_gesture, |
| 749 was_blocked); | 749 was_blocked); |
| 750 } | 750 } |
| 751 } | 751 } |
| 752 | 752 |
| 753 void DevToolsWindow::CloseContents(WebContents* source) { | 753 void DevToolsWindow::CloseContents(WebContents* source) { |
| 754 CHECK(is_docked_); | 754 CHECK(is_docked_); |
| 755 // Do this first so that when GetDockedInstanceForInspectedTab is called |
| 756 // from UpdateDevTools it won't return this instance |
| 757 // see crbug.com/372504 |
| 758 content::DevToolsManager::GetInstance()->ClientHostClosing( |
| 759 bindings_->frontend_host()); |
| 755 // This will prevent any activity after frontend is loaded. | 760 // This will prevent any activity after frontend is loaded. |
| 756 action_on_load_ = DevToolsToggleAction::NoOp(); | 761 action_on_load_ = DevToolsToggleAction::NoOp(); |
| 757 ignore_set_is_docked_ = true; | 762 ignore_set_is_docked_ = true; |
| 758 // Update dev tools to reflect removed dev tools window. | 763 // Update dev tools to reflect removed dev tools window. |
| 759 BrowserWindow* inspected_window = GetInspectedBrowserWindow(); | 764 BrowserWindow* inspected_window = GetInspectedBrowserWindow(); |
| 760 if (inspected_window) | 765 if (inspected_window) |
| 761 inspected_window->UpdateDevTools(); | 766 inspected_window->UpdateDevTools(); |
| 762 // In case of docked web_contents_, we own it so delete here. | 767 // In case of docked web_contents_, we own it so delete here. |
| 763 // Embedding DevTools window will be deleted as a result of | 768 // Embedding DevTools window will be deleted as a result of |
| 764 // WebContentsDestroyed callback. | 769 // WebContentsDestroyed callback. |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1015 | 1020 |
| 1016 InfoBarService* DevToolsWindow::GetInfoBarService() { | 1021 InfoBarService* DevToolsWindow::GetInfoBarService() { |
| 1017 return is_docked_ ? | 1022 return is_docked_ ? |
| 1018 InfoBarService::FromWebContents(GetInspectedWebContents()) : | 1023 InfoBarService::FromWebContents(GetInspectedWebContents()) : |
| 1019 InfoBarService::FromWebContents(web_contents_); | 1024 InfoBarService::FromWebContents(web_contents_); |
| 1020 } | 1025 } |
| 1021 | 1026 |
| 1022 void DevToolsWindow::RenderProcessGone() { | 1027 void DevToolsWindow::RenderProcessGone() { |
| 1023 // Docked DevToolsWindow owns its web_contents_ and must delete it. | 1028 // Docked DevToolsWindow owns its web_contents_ and must delete it. |
| 1024 // Undocked web_contents_ are owned and handled by browser. | 1029 // Undocked web_contents_ are owned and handled by browser. |
| 1030 // see crbug.com/369932 |
| 1025 if (is_docked_) | 1031 if (is_docked_) |
| 1026 CloseContents(web_contents_); | 1032 CloseContents(web_contents_); |
| 1027 } | 1033 } |
| 1028 | 1034 |
| 1029 void DevToolsWindow::OnLoadCompleted() { | 1035 void DevToolsWindow::OnLoadCompleted() { |
| 1030 // First seed inspected tab id for extension APIs. | 1036 // First seed inspected tab id for extension APIs. |
| 1031 WebContents* inspected_web_contents = GetInspectedWebContents(); | 1037 WebContents* inspected_web_contents = GetInspectedWebContents(); |
| 1032 if (inspected_web_contents) { | 1038 if (inspected_web_contents) { |
| 1033 SessionTabHelper* session_tab_helper = | 1039 SessionTabHelper* session_tab_helper = |
| 1034 SessionTabHelper::FromWebContents(inspected_web_contents); | 1040 SessionTabHelper::FromWebContents(inspected_web_contents); |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1161 closure.Run(); | 1167 closure.Run(); |
| 1162 return; | 1168 return; |
| 1163 } | 1169 } |
| 1164 load_completed_callback_ = closure; | 1170 load_completed_callback_ = closure; |
| 1165 } | 1171 } |
| 1166 | 1172 |
| 1167 bool DevToolsWindow::ForwardKeyboardEvent( | 1173 bool DevToolsWindow::ForwardKeyboardEvent( |
| 1168 const content::NativeWebKeyboardEvent& event) { | 1174 const content::NativeWebKeyboardEvent& event) { |
| 1169 return event_forwarder_->ForwardEvent(event); | 1175 return event_forwarder_->ForwardEvent(event); |
| 1170 } | 1176 } |
| OLD | NEW |