Chromium Code Reviews| Index: chrome/browser/devtools/devtools_window.h |
| diff --git a/chrome/browser/devtools/devtools_window.h b/chrome/browser/devtools/devtools_window.h |
| index 53a0ccf43ca612b5bf14389d367d3c5ee6bd9605..9d9182cf0ad203ea5bcf16a7bffdf4f826e5f557 100644 |
| --- a/chrome/browser/devtools/devtools_window.h |
| +++ b/chrome/browser/devtools/devtools_window.h |
| @@ -49,13 +49,6 @@ namespace user_prefs { |
| class PrefRegistrySyncable; |
| } |
| -enum DevToolsDockSide { |
| - DEVTOOLS_DOCK_SIDE_UNDOCKED = 0, |
| - DEVTOOLS_DOCK_SIDE_BOTTOM, |
| - DEVTOOLS_DOCK_SIDE_RIGHT, |
| - DEVTOOLS_DOCK_SIDE_MINIMIZED |
| -}; |
| - |
| class DevToolsWindow : private content::NotificationObserver, |
| private content::WebContentsDelegate, |
| private content::DevToolsFrontendHostDelegate, |
| @@ -69,31 +62,42 @@ class DevToolsWindow : private content::NotificationObserver, |
| static std::string GetDevToolsWindowPlacementPrefKey(); |
| static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); |
| + |
| // Return the DevToolsWindow for the given RenderViewHost if one exists, |
| // otherwise NULL. |
| static DevToolsWindow* GetInstanceForInspectedRenderViewHost( |
| content::RenderViewHost* inspected_rvh); |
| + |
| + // Return the DevToolsWindow for the given WebContents if one exists and is |
| + // docked, otherwise NULL. |
| static DevToolsWindow* GetDockedInstanceForInspectedTab( |
| content::WebContents* inspected_tab); |
| + |
| static bool IsDevToolsWindow(content::RenderViewHost* window_rvh); |
| + |
| static DevToolsWindow* OpenDevToolsWindowForWorker( |
| Profile* profile, |
| content::DevToolsAgentHost* worker_agent); |
| - static DevToolsWindow* CreateDevToolsWindowForWorker(Profile* profile); |
| + |
| + // Open or focus existing DevTools window, and perform the specified action. |
|
pfeldman
2014/01/09 12:52:01
Open or reveal DevTools window
dgozman
2014/01/14 15:26:17
Done.
|
| + static DevToolsWindow* OpenDevToolsWindow( |
| + content::RenderViewHost* inspected_rvh, |
| + const DevToolsToggleAction& action); |
| + |
| + // Open or focus existing DevTools window, with no special action. |
| static DevToolsWindow* OpenDevToolsWindow( |
| content::RenderViewHost* inspected_rvh); |
| + |
| + // Perform specified action for current WebContents inside a |browser|. |
| + // This may close currently open DevTools window. |
| static DevToolsWindow* ToggleDevToolsWindow( |
| Browser* browser, |
| const DevToolsToggleAction& action); |
| - static void OpenExternalFrontend(Profile* profile, |
| - const std::string& frontend_uri, |
| - content::DevToolsAgentHost* agent_host); |
| - // Exposed for testing, normal clients should not use this method. |
| - static DevToolsWindow* ToggleDevToolsWindow( |
| - content::RenderViewHost* inspected_rvh, |
| - bool force_open, |
| - const DevToolsToggleAction& action); |
| + static void OpenExternalFrontend( |
| + Profile* profile, |
| + const std::string& frontend_uri, |
| + content::DevToolsAgentHost* agent_host); |
| static void InspectElement( |
| content::RenderViewHost* inspected_rvh, int x, int y); |
| @@ -105,10 +109,8 @@ class DevToolsWindow : private content::NotificationObserver, |
| content::WebContents* web_contents() { return web_contents_; } |
| Browser* browser() { return browser_; } // For tests. |
| - DevToolsDockSide dock_side() const { return dock_side_; } |
| content::RenderViewHost* GetRenderViewHost(); |
| - content::DevToolsClientHost* GetDevToolsClientHostForTest(); |
| // Inspected WebContents is placed over DevTools WebContents in docked mode. |
| // The following methods return the insets of inspected WebContents |
| @@ -119,8 +121,6 @@ class DevToolsWindow : private content::NotificationObserver, |
| // the overlaying inspected WebContents size. |
| gfx::Size GetMinimumSize() const; |
| - void Show(const DevToolsToggleAction& action); |
| - |
| // BeforeUnload interception //////////////////////////////////////////////// |
| // In order to preserve any edits the user may have made in devtools, the |
| @@ -195,37 +195,47 @@ class DevToolsWindow : private content::NotificationObserver, |
| // by user. |
| static void OnPageCloseCanceled(content::WebContents* contents); |
| - void SetDockSideForTest(DevToolsDockSide dock_side); |
| + void SetIsDockedAndShowImmediatelyForTest(bool is_docked); |
| private: |
| friend class DevToolsControllerTest; |
| + friend class DevToolsSanityTest; |
| friend class BrowserWindowControllerTest; |
| + enum LoadState { |
| + kNotLoaded = 0, |
| + kOnLoadFired = 1 << 0, |
| + kIsDockedSet = 1 << 1, |
| + kLoadCompleted = kOnLoadFired | kIsDockedSet |
| + }; |
| + typedef int LoadStateMask; |
|
pfeldman
2014/01/09 12:52:01
nuke
dgozman
2014/01/14 15:26:17
Done.
|
| + |
| DevToolsWindow(Profile* profile, |
| const GURL& frontend_url, |
| content::RenderViewHost* inspected_rvh, |
| - DevToolsDockSide dock_side); |
| + bool can_dock); |
| static DevToolsWindow* Create(Profile* profile, |
| const GURL& frontend_url, |
| content::RenderViewHost* inspected_rvh, |
| - DevToolsDockSide dock_side, |
| bool shared_worker_frontend, |
| bool external_frontend, |
| bool can_dock); |
| static GURL GetDevToolsURL(Profile* profile, |
| const GURL& base_url, |
| - DevToolsDockSide dock_side, |
| bool shared_worker_frontend, |
| bool external_frontend, |
| bool can_dock); |
| static DevToolsWindow* FindDevToolsWindow(content::DevToolsAgentHost*); |
| static DevToolsWindow* AsDevToolsWindow(content::RenderViewHost*); |
| - static DevToolsDockSide GetDockSideFromPrefs(Profile* profile); |
| - static std::string SideToString(DevToolsDockSide dock_side); |
| - static DevToolsDockSide SideFromString(const std::string& dock_side); |
| + static DevToolsWindow* CreateDevToolsWindowForWorker(Profile* profile); |
| + static bool IsDockedFromString(const std::string& dock_side); |
| static bool FindInspectedBrowserAndTabIndex( |
| content::WebContents* inspected_web_contents, Browser**, int* tab); |
| + static DevToolsWindow* ToggleDevToolsWindow( |
| + content::RenderViewHost* inspected_rvh, |
| + bool force_open, |
| + const DevToolsToggleAction& action); |
| // content::NotificationObserver: |
| virtual void Observe(int type, |
| @@ -275,6 +285,7 @@ class DevToolsWindow : private content::NotificationObserver, |
| int left, int top, int right, int bottom) OVERRIDE; |
| virtual void MoveWindow(int x, int y) OVERRIDE; |
| virtual void SetDockSide(const std::string& side) OVERRIDE; |
| + virtual void SetIsDocked(bool is_docked) OVERRIDE; |
| virtual void OpenInNewTab(const std::string& url) OVERRIDE; |
| virtual void SaveToFile(const std::string& url, |
| const std::string& content, |
| @@ -315,10 +326,10 @@ class DevToolsWindow : private content::NotificationObserver, |
| void CreateDevToolsBrowser(); |
| BrowserWindow* GetInspectedBrowserWindow(); |
| - bool IsInspectedBrowserPopup(); |
| - void UpdateFrontendDockSide(); |
| - void ScheduleAction(const DevToolsToggleAction& action); |
| - void DoAction(); |
| + void ScheduleShow(const DevToolsToggleAction& action); |
| + void Show(const DevToolsToggleAction& action); |
| + void DoAction(const DevToolsToggleAction& action); |
| + void LoadCompleted(); |
| void UpdateTheme(); |
| void AddDevToolsExtensionsToClient(); |
| void CallClientFunction(const std::string& function_name, |
| @@ -326,8 +337,6 @@ class DevToolsWindow : private content::NotificationObserver, |
| const base::Value* arg2, |
| const base::Value* arg3); |
| void UpdateBrowserToolbar(); |
| - bool IsDocked(); |
| - void Restore(); |
| content::WebContents* GetInspectedWebContents(); |
| void DocumentOnLoadCompletedInMainFrame(); |
| @@ -340,10 +349,11 @@ class DevToolsWindow : private content::NotificationObserver, |
| Profile* profile_; |
| content::WebContents* web_contents_; |
| Browser* browser_; |
| - // TODO(dgozman): move dock side knowledge entirely to frontend. |
| - DevToolsDockSide dock_side_; |
| - bool is_loaded_; |
| + bool is_docked_; |
| + bool can_dock_; |
| + LoadStateMask load_state_mask_; |
|
pfeldman
2014/01/09 12:52:01
LoadState
dgozman
2014/01/14 15:26:17
Done.
|
| DevToolsToggleAction action_on_load_; |
| + bool set_is_docked_for_test_on_load_; |
| content::NotificationRegistrar registrar_; |
| scoped_ptr<content::DevToolsClientHost> frontend_host_; |
| scoped_ptr<DevToolsFileHelper> file_helper_; |
| @@ -354,7 +364,6 @@ class DevToolsWindow : private content::NotificationObserver, |
| IndexingJobsMap; |
| IndexingJobsMap indexing_jobs_; |
| gfx::Insets contents_insets_; |
| - DevToolsDockSide dock_side_before_minimized_; |
| // True if we're in the process of handling a beforeunload event originating |
| // from the inspected webcontents, see InterceptPageBeforeUnload for details. |
| bool intercepted_page_beforeunload_; |