| 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 21 matching lines...) Expand all Loading... |
| 32 #include "chrome/common/pref_names.h" | 32 #include "chrome/common/pref_names.h" |
| 33 #include "chrome/common/url_constants.h" | 33 #include "chrome/common/url_constants.h" |
| 34 #include "components/app_modal/javascript_dialog_manager.h" | 34 #include "components/app_modal/javascript_dialog_manager.h" |
| 35 #include "components/pref_registry/pref_registry_syncable.h" | 35 #include "components/pref_registry/pref_registry_syncable.h" |
| 36 #include "components/prefs/scoped_user_pref_update.h" | 36 #include "components/prefs/scoped_user_pref_update.h" |
| 37 #include "components/sync_preferences/pref_service_syncable.h" | 37 #include "components/sync_preferences/pref_service_syncable.h" |
| 38 #include "components/zoom/page_zoom.h" | 38 #include "components/zoom/page_zoom.h" |
| 39 #include "components/zoom/zoom_controller.h" | 39 #include "components/zoom/zoom_controller.h" |
| 40 #include "content/public/browser/browser_thread.h" | 40 #include "content/public/browser/browser_thread.h" |
| 41 #include "content/public/browser/devtools_agent_host.h" | 41 #include "content/public/browser/devtools_agent_host.h" |
| 42 #include "content/public/browser/keyboard_event_processing_result.h" |
| 42 #include "content/public/browser/native_web_keyboard_event.h" | 43 #include "content/public/browser/native_web_keyboard_event.h" |
| 43 #include "content/public/browser/navigation_controller.h" | 44 #include "content/public/browser/navigation_controller.h" |
| 44 #include "content/public/browser/navigation_entry.h" | 45 #include "content/public/browser/navigation_entry.h" |
| 45 #include "content/public/browser/render_frame_host.h" | 46 #include "content/public/browser/render_frame_host.h" |
| 46 #include "content/public/browser/render_process_host.h" | 47 #include "content/public/browser/render_process_host.h" |
| 47 #include "content/public/browser/render_view_host.h" | 48 #include "content/public/browser/render_view_host.h" |
| 48 #include "content/public/browser/render_widget_host_view.h" | 49 #include "content/public/browser/render_widget_host_view.h" |
| 49 #include "content/public/browser/user_metrics.h" | 50 #include "content/public/browser/user_metrics.h" |
| 50 #include "content/public/browser/web_contents.h" | 51 #include "content/public/browser/web_contents.h" |
| 51 #include "content/public/common/content_client.h" | 52 #include "content/public/common/content_client.h" |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 public content::WebContentsDelegate { | 116 public content::WebContentsDelegate { |
| 116 public: | 117 public: |
| 117 DevToolsToolboxDelegate( | 118 DevToolsToolboxDelegate( |
| 118 WebContents* toolbox_contents, | 119 WebContents* toolbox_contents, |
| 119 DevToolsWindow::ObserverWithAccessor* web_contents_observer); | 120 DevToolsWindow::ObserverWithAccessor* web_contents_observer); |
| 120 ~DevToolsToolboxDelegate() override; | 121 ~DevToolsToolboxDelegate() override; |
| 121 | 122 |
| 122 content::WebContents* OpenURLFromTab( | 123 content::WebContents* OpenURLFromTab( |
| 123 content::WebContents* source, | 124 content::WebContents* source, |
| 124 const content::OpenURLParams& params) override; | 125 const content::OpenURLParams& params) override; |
| 125 bool PreHandleKeyboardEvent(content::WebContents* source, | 126 content::KeyboardEventProcessingResult PreHandleKeyboardEvent( |
| 126 const content::NativeWebKeyboardEvent& event, | 127 content::WebContents* source, |
| 127 bool* is_keyboard_shortcut) override; | 128 const content::NativeWebKeyboardEvent& event) override; |
| 128 void HandleKeyboardEvent( | 129 void HandleKeyboardEvent( |
| 129 content::WebContents* source, | 130 content::WebContents* source, |
| 130 const content::NativeWebKeyboardEvent& event) override; | 131 const content::NativeWebKeyboardEvent& event) override; |
| 131 void WebContentsDestroyed() override; | 132 void WebContentsDestroyed() override; |
| 132 | 133 |
| 133 private: | 134 private: |
| 134 BrowserWindow* GetInspectedBrowserWindow(); | 135 BrowserWindow* GetInspectedBrowserWindow(); |
| 135 DevToolsWindow::ObserverWithAccessor* inspected_contents_observer_; | 136 DevToolsWindow::ObserverWithAccessor* inspected_contents_observer_; |
| 136 DISALLOW_COPY_AND_ASSIGN(DevToolsToolboxDelegate); | 137 DISALLOW_COPY_AND_ASSIGN(DevToolsToolboxDelegate); |
| 137 }; | 138 }; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 150 content::WebContents* source, | 151 content::WebContents* source, |
| 151 const content::OpenURLParams& params) { | 152 const content::OpenURLParams& params) { |
| 152 DCHECK(source == web_contents()); | 153 DCHECK(source == web_contents()); |
| 153 if (!params.url.SchemeIs(content::kChromeDevToolsScheme)) | 154 if (!params.url.SchemeIs(content::kChromeDevToolsScheme)) |
| 154 return NULL; | 155 return NULL; |
| 155 content::NavigationController::LoadURLParams load_url_params(params.url); | 156 content::NavigationController::LoadURLParams load_url_params(params.url); |
| 156 source->GetController().LoadURLWithParams(load_url_params); | 157 source->GetController().LoadURLWithParams(load_url_params); |
| 157 return source; | 158 return source; |
| 158 } | 159 } |
| 159 | 160 |
| 160 bool DevToolsToolboxDelegate::PreHandleKeyboardEvent( | 161 content::KeyboardEventProcessingResult |
| 162 DevToolsToolboxDelegate::PreHandleKeyboardEvent( |
| 161 content::WebContents* source, | 163 content::WebContents* source, |
| 162 const content::NativeWebKeyboardEvent& event, | 164 const content::NativeWebKeyboardEvent& event) { |
| 163 bool* is_keyboard_shortcut) { | |
| 164 BrowserWindow* window = GetInspectedBrowserWindow(); | 165 BrowserWindow* window = GetInspectedBrowserWindow(); |
| 165 if (window) | 166 if (window) |
| 166 return window->PreHandleKeyboardEvent(event, is_keyboard_shortcut); | 167 return window->PreHandleKeyboardEvent(event); |
| 167 return false; | 168 return content::KeyboardEventProcessingResult::NOT_HANDLED; |
| 168 } | 169 } |
| 169 | 170 |
| 170 void DevToolsToolboxDelegate::HandleKeyboardEvent( | 171 void DevToolsToolboxDelegate::HandleKeyboardEvent( |
| 171 content::WebContents* source, | 172 content::WebContents* source, |
| 172 const content::NativeWebKeyboardEvent& event) { | 173 const content::NativeWebKeyboardEvent& event) { |
| 173 if (event.windowsKeyCode == 0x08) { | 174 if (event.windowsKeyCode == 0x08) { |
| 174 // Do not navigate back in history on Windows (http://crbug.com/74156). | 175 // Do not navigate back in history on Windows (http://crbug.com/74156). |
| 175 return; | 176 return; |
| 176 } | 177 } |
| 177 BrowserWindow* window = GetInspectedBrowserWindow(); | 178 BrowserWindow* window = GetInspectedBrowserWindow(); |
| (...skipping 915 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1093 } else { | 1094 } else { |
| 1094 bool should_proceed; | 1095 bool should_proceed; |
| 1095 inspected_web_contents->GetDelegate()->BeforeUnloadFired( | 1096 inspected_web_contents->GetDelegate()->BeforeUnloadFired( |
| 1096 inspected_web_contents, false, &should_proceed); | 1097 inspected_web_contents, false, &should_proceed); |
| 1097 DCHECK(!should_proceed); | 1098 DCHECK(!should_proceed); |
| 1098 } | 1099 } |
| 1099 *proceed_to_fire_unload = false; | 1100 *proceed_to_fire_unload = false; |
| 1100 } | 1101 } |
| 1101 } | 1102 } |
| 1102 | 1103 |
| 1103 bool DevToolsWindow::PreHandleKeyboardEvent( | 1104 content::KeyboardEventProcessingResult DevToolsWindow::PreHandleKeyboardEvent( |
| 1104 WebContents* source, | 1105 WebContents* source, |
| 1105 const content::NativeWebKeyboardEvent& event, | 1106 const content::NativeWebKeyboardEvent& event) { |
| 1106 bool* is_keyboard_shortcut) { | |
| 1107 BrowserWindow* inspected_window = GetInspectedBrowserWindow(); | 1107 BrowserWindow* inspected_window = GetInspectedBrowserWindow(); |
| 1108 if (inspected_window) { | 1108 if (inspected_window) { |
| 1109 return inspected_window->PreHandleKeyboardEvent(event, | 1109 return inspected_window->PreHandleKeyboardEvent(event); |
| 1110 is_keyboard_shortcut); | |
| 1111 } | 1110 } |
| 1112 return false; | 1111 return content::KeyboardEventProcessingResult::NOT_HANDLED; |
| 1113 } | 1112 } |
| 1114 | 1113 |
| 1115 void DevToolsWindow::HandleKeyboardEvent( | 1114 void DevToolsWindow::HandleKeyboardEvent( |
| 1116 WebContents* source, | 1115 WebContents* source, |
| 1117 const content::NativeWebKeyboardEvent& event) { | 1116 const content::NativeWebKeyboardEvent& event) { |
| 1118 if (event.windowsKeyCode == 0x08) { | 1117 if (event.windowsKeyCode == 0x08) { |
| 1119 // Do not navigate back in history on Windows (http://crbug.com/74156). | 1118 // Do not navigate back in history on Windows (http://crbug.com/74156). |
| 1120 return; | 1119 return; |
| 1121 } | 1120 } |
| 1122 BrowserWindow* inspected_window = GetInspectedBrowserWindow(); | 1121 BrowserWindow* inspected_window = GetInspectedBrowserWindow(); |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1409 bool DevToolsWindow::ReloadInspectedWebContents(bool bypass_cache) { | 1408 bool DevToolsWindow::ReloadInspectedWebContents(bool bypass_cache) { |
| 1410 // Only route reload via front-end if the agent is attached. | 1409 // Only route reload via front-end if the agent is attached. |
| 1411 WebContents* wc = GetInspectedWebContents(); | 1410 WebContents* wc = GetInspectedWebContents(); |
| 1412 if (!wc || wc->GetCrashedStatus() != base::TERMINATION_STATUS_STILL_RUNNING) | 1411 if (!wc || wc->GetCrashedStatus() != base::TERMINATION_STATUS_STILL_RUNNING) |
| 1413 return false; | 1412 return false; |
| 1414 base::Value bypass_cache_value(bypass_cache); | 1413 base::Value bypass_cache_value(bypass_cache); |
| 1415 bindings_->CallClientFunction("DevToolsAPI.reloadInspectedPage", | 1414 bindings_->CallClientFunction("DevToolsAPI.reloadInspectedPage", |
| 1416 &bypass_cache_value, nullptr, nullptr); | 1415 &bypass_cache_value, nullptr, nullptr); |
| 1417 return true; | 1416 return true; |
| 1418 } | 1417 } |
| OLD | NEW |