| 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" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 // Return the DevToolsWindow for the given RenderViewHost if one exists, | 38 // Return the DevToolsWindow for the given RenderViewHost if one exists, |
| 39 // otherwise NULL. | 39 // otherwise NULL. |
| 40 static DevToolsWindow* GetInstanceForInspectedRenderViewHost( | 40 static DevToolsWindow* GetInstanceForInspectedRenderViewHost( |
| 41 content::RenderViewHost* inspected_rvh); | 41 content::RenderViewHost* inspected_rvh); |
| 42 | 42 |
| 43 // Return the DevToolsWindow for the given WebContents if one exists, | 43 // Return the DevToolsWindow for the given WebContents if one exists, |
| 44 // otherwise NULL. | 44 // otherwise NULL. |
| 45 static DevToolsWindow* GetInstanceForInspectedWebContents( | 45 static DevToolsWindow* GetInstanceForInspectedWebContents( |
| 46 content::WebContents* inspected_web_contents); | 46 content::WebContents* inspected_web_contents); |
| 47 | 47 |
| 48 // Return the DevToolsWindow for the given WebContents if one exists and is | 48 // Return the docked DevTools WebContents for the given inspected WebContents |
| 49 // docked, otherwise NULL. This method will return only fully initialized | 49 // if one exists and should be shown in browser window, otherwise NULL. |
| 50 // window ready to be presented in UI. | 50 // This method will return only fully initialized window ready to be |
| 51 // presented in UI. |
| 52 // If |out_strategy| is not NULL, it will contain resizing strategy. |
| 51 // For immediately-ready-to-use but maybe not yet fully initialized DevTools | 53 // For immediately-ready-to-use but maybe not yet fully initialized DevTools |
| 52 // use |GetInstanceForInspectedRenderViewHost| instead. | 54 // use |GetInstanceForInspectedRenderViewHost| instead. |
| 53 static DevToolsWindow* GetDockedInstanceForInspectedTab( | 55 static content::WebContents* GetInTabWebContents( |
| 54 content::WebContents* inspected_tab); | 56 content::WebContents* inspected_tab, |
| 57 DevToolsContentsResizingStrategy* out_strategy); |
| 55 | 58 |
| 56 static bool IsDevToolsWindow(content::RenderViewHost* window_rvh); | 59 static bool IsDevToolsWindow(content::RenderViewHost* window_rvh); |
| 57 | 60 |
| 58 // Open or reveal DevTools window, and perform the specified action. | 61 // Open or reveal DevTools window, and perform the specified action. |
| 59 static DevToolsWindow* OpenDevToolsWindow( | 62 static DevToolsWindow* OpenDevToolsWindow( |
| 60 content::RenderViewHost* inspected_rvh, | 63 content::RenderViewHost* inspected_rvh, |
| 61 const DevToolsToggleAction& action); | 64 const DevToolsToggleAction& action); |
| 62 | 65 |
| 63 // Open or reveal DevTools window, with no special action. | 66 // Open or reveal DevTools window, with no special action. |
| 64 static DevToolsWindow* OpenDevToolsWindow( | 67 static DevToolsWindow* OpenDevToolsWindow( |
| (...skipping 17 matching lines...) Expand all Loading... |
| 82 content::DevToolsAgentHost* agent_host); | 85 content::DevToolsAgentHost* agent_host); |
| 83 | 86 |
| 84 // Worker frontend is always undocked. | 87 // Worker frontend is always undocked. |
| 85 static DevToolsWindow* OpenDevToolsWindowForWorker( | 88 static DevToolsWindow* OpenDevToolsWindowForWorker( |
| 86 Profile* profile, | 89 Profile* profile, |
| 87 content::DevToolsAgentHost* worker_agent); | 90 content::DevToolsAgentHost* worker_agent); |
| 88 | 91 |
| 89 static void InspectElement( | 92 static void InspectElement( |
| 90 content::RenderViewHost* inspected_rvh, int x, int y); | 93 content::RenderViewHost* inspected_rvh, int x, int y); |
| 91 | 94 |
| 92 content::WebContents* web_contents() { return web_contents_; } | 95 Browser* browser_for_test() { return browser_; } |
| 93 | 96 content::WebContents* web_contents_for_test() { return main_web_contents_; } |
| 94 Browser* browser() { return browser_; } // For tests. | |
| 95 | |
| 96 // Inspected WebContents is placed over DevTools WebContents in docked mode. | |
| 97 // The following method returns the resizing strategy of inspected | |
| 98 // WebContents relative to DevTools WebContents. | |
| 99 const DevToolsContentsResizingStrategy& GetContentsResizingStrategy() const; | |
| 100 | |
| 101 // Minimum size of the docked DevTools WebContents. This includes | |
| 102 // the overlaying inspected WebContents size. | |
| 103 gfx::Size GetMinimumSize() const; | |
| 104 | 97 |
| 105 // Sets closure to be called after load is done. If already loaded, calls | 98 // Sets closure to be called after load is done. If already loaded, calls |
| 106 // closure immediately. | 99 // closure immediately. |
| 107 void SetLoadCompletedCallback(const base::Closure& closure); | 100 void SetLoadCompletedCallback(const base::Closure& closure); |
| 108 | 101 |
| 109 // Forwards an unhandled keyboard event to the DevTools frontend. | 102 // Forwards an unhandled keyboard event to the DevTools frontend. |
| 110 bool ForwardKeyboardEvent(const content::NativeWebKeyboardEvent& event); | 103 bool ForwardKeyboardEvent(const content::NativeWebKeyboardEvent& event); |
| 111 | 104 |
| 112 // BeforeUnload interception //////////////////////////////////////////////// | 105 // BeforeUnload interception //////////////////////////////////////////////// |
| 113 | 106 |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 virtual content::WebContents* OpenURLFromTab( | 227 virtual content::WebContents* OpenURLFromTab( |
| 235 content::WebContents* source, | 228 content::WebContents* source, |
| 236 const content::OpenURLParams& params) OVERRIDE; | 229 const content::OpenURLParams& params) OVERRIDE; |
| 237 virtual void ActivateContents(content::WebContents* contents) OVERRIDE; | 230 virtual void ActivateContents(content::WebContents* contents) OVERRIDE; |
| 238 virtual void AddNewContents(content::WebContents* source, | 231 virtual void AddNewContents(content::WebContents* source, |
| 239 content::WebContents* new_contents, | 232 content::WebContents* new_contents, |
| 240 WindowOpenDisposition disposition, | 233 WindowOpenDisposition disposition, |
| 241 const gfx::Rect& initial_pos, | 234 const gfx::Rect& initial_pos, |
| 242 bool user_gesture, | 235 bool user_gesture, |
| 243 bool* was_blocked) OVERRIDE; | 236 bool* was_blocked) OVERRIDE; |
| 237 virtual void WebContentsCreated(content::WebContents* source_contents, |
| 238 int opener_render_frame_id, |
| 239 const base::string16& frame_name, |
| 240 const GURL& target_url, |
| 241 content::WebContents* new_contents) OVERRIDE; |
| 244 virtual void CloseContents(content::WebContents* source) OVERRIDE; | 242 virtual void CloseContents(content::WebContents* source) OVERRIDE; |
| 245 virtual void ContentsZoomChange(bool zoom_in) OVERRIDE; | 243 virtual void ContentsZoomChange(bool zoom_in) OVERRIDE; |
| 246 virtual void BeforeUnloadFired(content::WebContents* tab, | 244 virtual void BeforeUnloadFired(content::WebContents* tab, |
| 247 bool proceed, | 245 bool proceed, |
| 248 bool* proceed_to_fire_unload) OVERRIDE; | 246 bool* proceed_to_fire_unload) OVERRIDE; |
| 249 virtual bool PreHandleKeyboardEvent( | 247 virtual bool PreHandleKeyboardEvent( |
| 250 content::WebContents* source, | 248 content::WebContents* source, |
| 251 const content::NativeWebKeyboardEvent& event, | 249 const content::NativeWebKeyboardEvent& event, |
| 252 bool* is_keyboard_shortcut) OVERRIDE; | 250 bool* is_keyboard_shortcut) OVERRIDE; |
| 253 virtual void HandleKeyboardEvent( | 251 virtual void HandleKeyboardEvent( |
| (...skipping 30 matching lines...) Expand all Loading... |
| 284 virtual void RenderProcessGone() OVERRIDE; | 282 virtual void RenderProcessGone() OVERRIDE; |
| 285 | 283 |
| 286 void CreateDevToolsBrowser(); | 284 void CreateDevToolsBrowser(); |
| 287 BrowserWindow* GetInspectedBrowserWindow(); | 285 BrowserWindow* GetInspectedBrowserWindow(); |
| 288 void ScheduleShow(const DevToolsToggleAction& action); | 286 void ScheduleShow(const DevToolsToggleAction& action); |
| 289 void Show(const DevToolsToggleAction& action); | 287 void Show(const DevToolsToggleAction& action); |
| 290 void DoAction(const DevToolsToggleAction& action); | 288 void DoAction(const DevToolsToggleAction& action); |
| 291 void LoadCompleted(); | 289 void LoadCompleted(); |
| 292 void SetIsDockedAndShowImmediatelyForTest(bool is_docked); | 290 void SetIsDockedAndShowImmediatelyForTest(bool is_docked); |
| 293 void UpdateBrowserToolbar(); | 291 void UpdateBrowserToolbar(); |
| 292 void UpdateBrowserWindow(); |
| 294 content::WebContents* GetInspectedWebContents(); | 293 content::WebContents* GetInspectedWebContents(); |
| 295 | 294 |
| 296 class InspectedWebContentsObserver; | 295 class InspectedWebContentsObserver; |
| 297 scoped_ptr<InspectedWebContentsObserver> inspected_contents_observer_; | 296 scoped_ptr<InspectedWebContentsObserver> inspected_contents_observer_; |
| 298 | 297 |
| 299 Profile* profile_; | 298 Profile* profile_; |
| 300 content::WebContents* web_contents_; | 299 content::WebContents* main_web_contents_; |
| 300 content::WebContents* toolbox_web_contents_; |
| 301 DevToolsUIBindings* bindings_; | 301 DevToolsUIBindings* bindings_; |
| 302 Browser* browser_; | 302 Browser* browser_; |
| 303 bool is_docked_; | 303 bool is_docked_; |
| 304 const bool can_dock_; | 304 const bool can_dock_; |
| 305 LoadState load_state_; | 305 LoadState load_state_; |
| 306 DevToolsToggleAction action_on_load_; | 306 DevToolsToggleAction action_on_load_; |
| 307 bool ignore_set_is_docked_; | 307 bool ignore_set_is_docked_; |
| 308 DevToolsContentsResizingStrategy contents_resizing_strategy_; | 308 DevToolsContentsResizingStrategy contents_resizing_strategy_; |
| 309 // 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 |
| 310 // from the inspected webcontents, see InterceptPageBeforeUnload for details. | 310 // from the inspected webcontents, see InterceptPageBeforeUnload for details. |
| 311 bool intercepted_page_beforeunload_; | 311 bool intercepted_page_beforeunload_; |
| 312 base::Closure load_completed_callback_; | 312 base::Closure load_completed_callback_; |
| 313 | 313 |
| 314 base::TimeTicks inspect_element_start_time_; | 314 base::TimeTicks inspect_element_start_time_; |
| 315 scoped_ptr<DevToolsEventForwarder> event_forwarder_; | 315 scoped_ptr<DevToolsEventForwarder> event_forwarder_; |
| 316 | 316 |
| 317 friend class DevToolsEventForwarder; | 317 friend class DevToolsEventForwarder; |
| 318 DISALLOW_COPY_AND_ASSIGN(DevToolsWindow); | 318 DISALLOW_COPY_AND_ASSIGN(DevToolsWindow); |
| 319 }; | 319 }; |
| 320 | 320 |
| 321 #endif // CHROME_BROWSER_DEVTOOLS_DEVTOOLS_WINDOW_H_ | 321 #endif // CHROME_BROWSER_DEVTOOLS_DEVTOOLS_WINDOW_H_ |
| OLD | NEW |