| 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..6a8e85fd5134f77bc11819873399d257a4ea9494 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,52 @@ 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. This method will return only fully initialized
|
| + // window ready to be presented in UI.
|
| + // For immediately-ready-to-use but maybe not yet fully initialized DevTools
|
| + // use |GetInstanceForInspectedRenderViewHost| instead.
|
| 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 reveal DevTools window, and perform the specified action.
|
| + static DevToolsWindow* OpenDevToolsWindow(
|
| + content::RenderViewHost* inspected_rvh,
|
| + const DevToolsToggleAction& action);
|
| +
|
| + // Open or reveal DevTools window, with no special action.
|
| static DevToolsWindow* OpenDevToolsWindow(
|
| content::RenderViewHost* inspected_rvh);
|
| +
|
| + static DevToolsWindow* OpenDevToolsWindowForTest(
|
| + content::RenderViewHost* inspected_rvh, bool is_docked);
|
| + static DevToolsWindow* OpenDevToolsWindowForTest(
|
| + Browser* browser, bool is_docked);
|
| +
|
| + // 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);
|
| + // External frontend is always undocked.
|
| + static void OpenExternalFrontend(
|
| + Profile* profile,
|
| + const std::string& frontend_uri,
|
| + content::DevToolsAgentHost* agent_host);
|
| +
|
| + // Worker frontend is always undocked.
|
| + static DevToolsWindow* OpenDevToolsWindowForWorker(
|
| + Profile* profile,
|
| + content::DevToolsAgentHost* worker_agent);
|
|
|
| static void InspectElement(
|
| content::RenderViewHost* inspected_rvh, int x, int y);
|
| @@ -105,10 +119,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 +131,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 +205,53 @@ class DevToolsWindow : private content::NotificationObserver,
|
| // by user.
|
| static void OnPageCloseCanceled(content::WebContents* contents);
|
|
|
| - void SetDockSideForTest(DevToolsDockSide dock_side);
|
| -
|
| private:
|
| friend class DevToolsControllerTest;
|
| + friend class DevToolsSanityTest;
|
| friend class BrowserWindowControllerTest;
|
|
|
| + // DevTools initialization typically follows this way:
|
| + // - Toggle/Open: client call;
|
| + // - Create;
|
| + // - ScheduleShow: setup window to be functional, but not yet show;
|
| + // - DocumentOnLoadCompletedInMainFrame: frontend loaded;
|
| + // - SetIsDocked: frontend decided on docking state;
|
| + // - OnLoadCompleted: ready to present frontend;
|
| + // - Show: actually placing frontend WebContents to a Browser or docked place;
|
| + // - DoAction: perform action passed in Toggle/Open.
|
| + enum LoadState {
|
| + kNotLoaded,
|
| + kOnLoadFired, // Implies SetIsDocked was not yet called.
|
| + kIsDockedSet, // Implies DocumentOnLoadCompleted was not yet called.
|
| + kLoadCompleted
|
| + };
|
| +
|
| 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 +301,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 +342,11 @@ 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 SetIsDockedAndShowImmediatelyForTest(bool is_docked);
|
| void UpdateTheme();
|
| void AddDevToolsExtensionsToClient();
|
| void CallClientFunction(const std::string& function_name,
|
| @@ -326,8 +354,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 +366,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_;
|
| + LoadState load_state_;
|
| DevToolsToggleAction action_on_load_;
|
| + bool ignore_set_is_docked_for_test_;
|
| content::NotificationRegistrar registrar_;
|
| scoped_ptr<content::DevToolsClientHost> frontend_host_;
|
| scoped_ptr<DevToolsFileHelper> file_helper_;
|
| @@ -354,7 +381,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_;
|
|
|