| 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 #ifndef CHROME_BROWSER_DEVTOOLS_DEVTOOLS_WINDOW_H_ | 5 #ifndef CHROME_BROWSER_DEVTOOLS_DEVTOOLS_WINDOW_H_ |
| 6 #define CHROME_BROWSER_DEVTOOLS_DEVTOOLS_WINDOW_H_ | 6 #define CHROME_BROWSER_DEVTOOLS_DEVTOOLS_WINDOW_H_ |
| 7 | 7 |
| 8 #include "chrome/browser/devtools/devtools_contents_resizing_strategy.h" | 8 #include "chrome/browser/devtools/devtools_contents_resizing_strategy.h" |
| 9 #include "chrome/browser/devtools/devtools_toggle_action.h" | 9 #include "chrome/browser/devtools/devtools_toggle_action.h" |
| 10 #include "chrome/browser/devtools/devtools_ui_bindings.h" | 10 #include "chrome/browser/devtools/devtools_ui_bindings.h" |
| 11 #include "content/public/browser/web_contents_delegate.h" | 11 #include "content/public/browser/web_contents_delegate.h" |
| 12 #include "content/public/browser/web_contents_observer.h" | 12 #include "content/public/browser/web_contents_observer.h" |
| 13 | 13 |
| 14 class Browser; | 14 class Browser; |
| 15 class BrowserWindow; | 15 class BrowserWindow; |
| 16 class DevToolsControllerTest; | 16 class DevToolsWindowTesting; |
| 17 class DevToolsEventForwarder; | 17 class DevToolsEventForwarder; |
| 18 | 18 |
| 19 namespace content { | 19 namespace content { |
| 20 class DevToolsAgentHost; | 20 class DevToolsAgentHost; |
| 21 struct NativeWebKeyboardEvent; | 21 struct NativeWebKeyboardEvent; |
| 22 class RenderViewHost; | 22 class RenderViewHost; |
| 23 } | 23 } |
| 24 | 24 |
| 25 namespace user_prefs { | 25 namespace user_prefs { |
| 26 class PrefRegistrySyncable; | 26 class PrefRegistrySyncable; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 | 65 |
| 66 // Open or reveal DevTools window, and perform the specified action. | 66 // Open or reveal DevTools window, and perform the specified action. |
| 67 static DevToolsWindow* OpenDevToolsWindow( | 67 static DevToolsWindow* OpenDevToolsWindow( |
| 68 content::RenderViewHost* inspected_rvh, | 68 content::RenderViewHost* inspected_rvh, |
| 69 const DevToolsToggleAction& action); | 69 const DevToolsToggleAction& action); |
| 70 | 70 |
| 71 // Open or reveal DevTools window, with no special action. | 71 // Open or reveal DevTools window, with no special action. |
| 72 static DevToolsWindow* OpenDevToolsWindow( | 72 static DevToolsWindow* OpenDevToolsWindow( |
| 73 content::RenderViewHost* inspected_rvh); | 73 content::RenderViewHost* inspected_rvh); |
| 74 | 74 |
| 75 static DevToolsWindow* OpenDevToolsWindowForTest( | |
| 76 content::RenderViewHost* inspected_rvh, bool is_docked); | |
| 77 static DevToolsWindow* OpenDevToolsWindowForTest( | |
| 78 Browser* browser, bool is_docked); | |
| 79 | |
| 80 // Perform specified action for current WebContents inside a |browser|. | 75 // Perform specified action for current WebContents inside a |browser|. |
| 81 // This may close currently open DevTools window. | 76 // This may close currently open DevTools window. |
| 82 static DevToolsWindow* ToggleDevToolsWindow( | 77 static DevToolsWindow* ToggleDevToolsWindow( |
| 83 Browser* browser, | 78 Browser* browser, |
| 84 const DevToolsToggleAction& action); | 79 const DevToolsToggleAction& action); |
| 85 | 80 |
| 86 // External frontend is always undocked. | 81 // External frontend is always undocked. |
| 87 static void OpenExternalFrontend( | 82 static void OpenExternalFrontend( |
| 88 Profile* profile, | 83 Profile* profile, |
| 89 const std::string& frontend_uri, | 84 const std::string& frontend_uri, |
| 90 content::DevToolsAgentHost* agent_host); | 85 content::DevToolsAgentHost* agent_host); |
| 91 | 86 |
| 92 // Worker frontend is always undocked. | 87 // Worker frontend is always undocked. |
| 93 static DevToolsWindow* OpenDevToolsWindowForWorker( | 88 static DevToolsWindow* OpenDevToolsWindowForWorker( |
| 94 Profile* profile, | 89 Profile* profile, |
| 95 content::DevToolsAgentHost* worker_agent); | 90 content::DevToolsAgentHost* worker_agent); |
| 96 | 91 |
| 97 static void InspectElement( | 92 static void InspectElement( |
| 98 content::RenderViewHost* inspected_rvh, int x, int y); | 93 content::RenderViewHost* inspected_rvh, int x, int y); |
| 99 | 94 |
| 100 Browser* browser_for_test() { return browser_; } | |
| 101 content::WebContents* web_contents_for_test() { return main_web_contents_; } | |
| 102 | |
| 103 // Sets closure to be called after load is done. If already loaded, calls | 95 // Sets closure to be called after load is done. If already loaded, calls |
| 104 // closure immediately. | 96 // closure immediately. |
| 105 void SetLoadCompletedCallback(const base::Closure& closure); | 97 void SetLoadCompletedCallback(const base::Closure& closure); |
| 106 | 98 |
| 107 // Forwards an unhandled keyboard event to the DevTools frontend. | 99 // Forwards an unhandled keyboard event to the DevTools frontend. |
| 108 bool ForwardKeyboardEvent(const content::NativeWebKeyboardEvent& event); | 100 bool ForwardKeyboardEvent(const content::NativeWebKeyboardEvent& event); |
| 109 | 101 |
| 110 // BeforeUnload interception //////////////////////////////////////////////// | 102 // BeforeUnload interception //////////////////////////////////////////////// |
| 111 | 103 |
| 112 // In order to preserve any edits the user may have made in devtools, the | 104 // In order to preserve any edits the user may have made in devtools, the |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 | 167 |
| 176 // Returns true if devtools window would like to hook beforeunload event | 168 // Returns true if devtools window would like to hook beforeunload event |
| 177 // of this |contents|. | 169 // of this |contents|. |
| 178 static bool NeedsToInterceptBeforeUnload(content::WebContents* contents); | 170 static bool NeedsToInterceptBeforeUnload(content::WebContents* contents); |
| 179 | 171 |
| 180 // Notify devtools window that closing of |contents| was cancelled | 172 // Notify devtools window that closing of |contents| was cancelled |
| 181 // by user. | 173 // by user. |
| 182 static void OnPageCloseCanceled(content::WebContents* contents); | 174 static void OnPageCloseCanceled(content::WebContents* contents); |
| 183 | 175 |
| 184 private: | 176 private: |
| 185 friend class DevToolsControllerTest; | 177 friend class DevToolsWindowTesting; |
| 186 friend class DevToolsSanityTest; | |
| 187 friend class BrowserWindowControllerTest; | |
| 188 | 178 |
| 189 // DevTools lifecycle typically follows this way: | 179 // DevTools lifecycle typically follows this way: |
| 190 // - Toggle/Open: client call; | 180 // - Toggle/Open: client call; |
| 191 // - Create; | 181 // - Create; |
| 192 // - ScheduleShow: setup window to be functional, but not yet show; | 182 // - ScheduleShow: setup window to be functional, but not yet show; |
| 193 // - DocumentOnLoadCompletedInMainFrame: frontend loaded; | 183 // - DocumentOnLoadCompletedInMainFrame: frontend loaded; |
| 194 // - SetIsDocked: frontend decided on docking state; | 184 // - SetIsDocked: frontend decided on docking state; |
| 195 // - OnLoadCompleted: ready to present frontend; | 185 // - OnLoadCompleted: ready to present frontend; |
| 196 // - Show: actually placing frontend WebContents to a Browser or docked place; | 186 // - Show: actually placing frontend WebContents to a Browser or docked place; |
| 197 // - DoAction: perform action passed in Toggle/Open; | 187 // - DoAction: perform action passed in Toggle/Open; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 210 DevToolsWindow(Profile* profile, | 200 DevToolsWindow(Profile* profile, |
| 211 const GURL& frontend_url, | 201 const GURL& frontend_url, |
| 212 content::RenderViewHost* inspected_rvh, | 202 content::RenderViewHost* inspected_rvh, |
| 213 bool can_dock); | 203 bool can_dock); |
| 214 | 204 |
| 215 static DevToolsWindow* Create(Profile* profile, | 205 static DevToolsWindow* Create(Profile* profile, |
| 216 const GURL& frontend_url, | 206 const GURL& frontend_url, |
| 217 content::RenderViewHost* inspected_rvh, | 207 content::RenderViewHost* inspected_rvh, |
| 218 bool shared_worker_frontend, | 208 bool shared_worker_frontend, |
| 219 bool external_frontend, | 209 bool external_frontend, |
| 220 bool can_dock); | 210 bool can_dock, |
| 211 const std::string& settings); |
| 221 static GURL GetDevToolsURL(Profile* profile, | 212 static GURL GetDevToolsURL(Profile* profile, |
| 222 const GURL& base_url, | 213 const GURL& base_url, |
| 223 bool shared_worker_frontend, | 214 bool shared_worker_frontend, |
| 224 bool external_frontend, | 215 bool external_frontend, |
| 225 bool can_dock); | 216 bool can_dock, |
| 217 const std::string& settings); |
| 226 static DevToolsWindow* FindDevToolsWindow(content::DevToolsAgentHost*); | 218 static DevToolsWindow* FindDevToolsWindow(content::DevToolsAgentHost*); |
| 227 static DevToolsWindow* AsDevToolsWindow(content::WebContents*); | 219 static DevToolsWindow* AsDevToolsWindow(content::WebContents*); |
| 228 static DevToolsWindow* CreateDevToolsWindowForWorker(Profile* profile); | 220 static DevToolsWindow* CreateDevToolsWindowForWorker(Profile* profile); |
| 229 static DevToolsWindow* ToggleDevToolsWindow( | 221 static DevToolsWindow* ToggleDevToolsWindow( |
| 230 content::RenderViewHost* inspected_rvh, | 222 content::RenderViewHost* inspected_rvh, |
| 231 bool force_open, | 223 bool force_open, |
| 232 const DevToolsToggleAction& action); | 224 const DevToolsToggleAction& action, |
| 225 const std::string& settings); |
| 233 | 226 |
| 234 static std::string GetDevToolsWindowPlacementPrefKey(); | 227 static std::string GetDevToolsWindowPlacementPrefKey(); |
| 235 | 228 |
| 236 // content::WebContentsDelegate: | 229 // content::WebContentsDelegate: |
| 237 virtual content::WebContents* OpenURLFromTab( | 230 virtual content::WebContents* OpenURLFromTab( |
| 238 content::WebContents* source, | 231 content::WebContents* source, |
| 239 const content::OpenURLParams& params) OVERRIDE; | 232 const content::OpenURLParams& params) OVERRIDE; |
| 240 virtual void ActivateContents(content::WebContents* contents) OVERRIDE; | 233 virtual void ActivateContents(content::WebContents* contents) OVERRIDE; |
| 241 virtual void AddNewContents(content::WebContents* source, | 234 virtual void AddNewContents(content::WebContents* source, |
| 242 content::WebContents* new_contents, | 235 content::WebContents* new_contents, |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 virtual void OnLoadCompleted() OVERRIDE; | 283 virtual void OnLoadCompleted() OVERRIDE; |
| 291 virtual InfoBarService* GetInfoBarService() OVERRIDE; | 284 virtual InfoBarService* GetInfoBarService() OVERRIDE; |
| 292 virtual void RenderProcessGone() OVERRIDE; | 285 virtual void RenderProcessGone() OVERRIDE; |
| 293 | 286 |
| 294 void CreateDevToolsBrowser(); | 287 void CreateDevToolsBrowser(); |
| 295 BrowserWindow* GetInspectedBrowserWindow(); | 288 BrowserWindow* GetInspectedBrowserWindow(); |
| 296 void ScheduleShow(const DevToolsToggleAction& action); | 289 void ScheduleShow(const DevToolsToggleAction& action); |
| 297 void Show(const DevToolsToggleAction& action); | 290 void Show(const DevToolsToggleAction& action); |
| 298 void DoAction(const DevToolsToggleAction& action); | 291 void DoAction(const DevToolsToggleAction& action); |
| 299 void LoadCompleted(); | 292 void LoadCompleted(); |
| 300 void SetIsDockedAndShowImmediatelyForTest(bool is_docked); | |
| 301 void UpdateBrowserToolbar(); | 293 void UpdateBrowserToolbar(); |
| 302 void UpdateBrowserWindow(); | 294 void UpdateBrowserWindow(); |
| 303 content::WebContents* GetInspectedWebContents(); | 295 content::WebContents* GetInspectedWebContents(); |
| 304 | 296 |
| 305 scoped_ptr<ObserverWithAccessor> inspected_contents_observer_; | 297 scoped_ptr<ObserverWithAccessor> inspected_contents_observer_; |
| 306 | 298 |
| 307 Profile* profile_; | 299 Profile* profile_; |
| 308 content::WebContents* main_web_contents_; | 300 content::WebContents* main_web_contents_; |
| 309 content::WebContents* toolbox_web_contents_; | 301 content::WebContents* toolbox_web_contents_; |
| 310 DevToolsUIBindings* bindings_; | 302 DevToolsUIBindings* bindings_; |
| 311 Browser* browser_; | 303 Browser* browser_; |
| 312 bool is_docked_; | 304 bool is_docked_; |
| 313 const bool can_dock_; | 305 const bool can_dock_; |
| 314 LifeStage life_stage_; | 306 LifeStage life_stage_; |
| 315 DevToolsToggleAction action_on_load_; | 307 DevToolsToggleAction action_on_load_; |
| 316 bool ignore_set_is_docked_; | |
| 317 DevToolsContentsResizingStrategy contents_resizing_strategy_; | 308 DevToolsContentsResizingStrategy contents_resizing_strategy_; |
| 318 // True if we're in the process of handling a beforeunload event originating | 309 // True if we're in the process of handling a beforeunload event originating |
| 319 // from the inspected webcontents, see InterceptPageBeforeUnload for details. | 310 // from the inspected webcontents, see InterceptPageBeforeUnload for details. |
| 320 bool intercepted_page_beforeunload_; | 311 bool intercepted_page_beforeunload_; |
| 321 base::Closure load_completed_callback_; | 312 base::Closure load_completed_callback_; |
| 313 base::Closure close_callback_; |
| 322 | 314 |
| 323 base::TimeTicks inspect_element_start_time_; | 315 base::TimeTicks inspect_element_start_time_; |
| 324 scoped_ptr<DevToolsEventForwarder> event_forwarder_; | 316 scoped_ptr<DevToolsEventForwarder> event_forwarder_; |
| 325 | 317 |
| 326 friend class DevToolsEventForwarder; | 318 friend class DevToolsEventForwarder; |
| 327 DISALLOW_COPY_AND_ASSIGN(DevToolsWindow); | 319 DISALLOW_COPY_AND_ASSIGN(DevToolsWindow); |
| 328 }; | 320 }; |
| 329 | 321 |
| 330 #endif // CHROME_BROWSER_DEVTOOLS_DEVTOOLS_WINDOW_H_ | 322 #endif // CHROME_BROWSER_DEVTOOLS_DEVTOOLS_WINDOW_H_ |
| OLD | NEW |