| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_DEBUGGER_DEVTOOLS_WINDOW_H_ | 5 #ifndef CHROME_BROWSER_DEBUGGER_DEVTOOLS_WINDOW_H_ |
| 6 #define CHROME_BROWSER_DEBUGGER_DEVTOOLS_WINDOW_H_ | 6 #define CHROME_BROWSER_DEBUGGER_DEVTOOLS_WINDOW_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "chrome/browser/debugger/devtools_toggle_action.h" | 13 #include "chrome/browser/debugger/devtools_toggle_action.h" |
| 14 #include "content/public/browser/devtools_client_host.h" | 14 #include "content/public/browser/devtools_client_host.h" |
| 15 #include "content/public/browser/devtools_frontend_host_delegate.h" | 15 #include "content/public/browser/devtools_frontend_host_delegate.h" |
| 16 #include "content/public/browser/notification_observer.h" | 16 #include "content/public/browser/notification_observer.h" |
| 17 #include "content/public/browser/notification_registrar.h" | 17 #include "content/public/browser/notification_registrar.h" |
| 18 #include "content/public/browser/web_contents_delegate.h" | 18 #include "content/public/browser/web_contents_delegate.h" |
| 19 | 19 |
| 20 namespace IPC { | 20 namespace IPC { |
| 21 class Message; | 21 class Message; |
| 22 } | 22 } |
| 23 | 23 |
| 24 class Browser; | 24 class Browser; |
| 25 class BrowserWindow; | 25 class BrowserWindow; |
| 26 class PrefService; | 26 class PrefService; |
| 27 class Profile; | 27 class Profile; |
| 28 class RenderViewHost; | |
| 29 class TabContentsWrapper; | 28 class TabContentsWrapper; |
| 30 | 29 |
| 31 namespace base { | 30 namespace base { |
| 32 class Value; | 31 class Value; |
| 33 } | 32 } |
| 34 | 33 |
| 35 namespace content { | 34 namespace content { |
| 36 class DevToolsAgentHost; | 35 class DevToolsAgentHost; |
| 37 class DevToolsClientHost; | 36 class DevToolsClientHost; |
| 37 class RenderViewHost; |
| 38 class WebContents; | 38 class WebContents; |
| 39 } | 39 } |
| 40 | 40 |
| 41 class DevToolsWindow : private content::NotificationObserver, | 41 class DevToolsWindow : private content::NotificationObserver, |
| 42 private content::WebContentsDelegate, | 42 private content::WebContentsDelegate, |
| 43 private content::DevToolsFrontendHostDelegate { | 43 private content::DevToolsFrontendHostDelegate { |
| 44 public: | 44 public: |
| 45 static const char kDevToolsApp[]; | 45 static const char kDevToolsApp[]; |
| 46 static void RegisterUserPrefs(PrefService* prefs); | 46 static void RegisterUserPrefs(PrefService* prefs); |
| 47 static TabContentsWrapper* GetDevToolsContents( | 47 static TabContentsWrapper* GetDevToolsContents( |
| 48 content::WebContents* inspected_tab); | 48 content::WebContents* inspected_tab); |
| 49 static bool IsDevToolsWindow(RenderViewHost* window_rvh); | 49 static bool IsDevToolsWindow(content::RenderViewHost* window_rvh); |
| 50 | 50 |
| 51 static DevToolsWindow* OpenDevToolsWindowForWorker( | 51 static DevToolsWindow* OpenDevToolsWindowForWorker( |
| 52 Profile* profile, | 52 Profile* profile, |
| 53 content::DevToolsAgentHost* worker_agent); | 53 content::DevToolsAgentHost* worker_agent); |
| 54 static DevToolsWindow* CreateDevToolsWindowForWorker(Profile* profile); | 54 static DevToolsWindow* CreateDevToolsWindowForWorker(Profile* profile); |
| 55 static DevToolsWindow* OpenDevToolsWindow(RenderViewHost* inspected_rvh); | 55 static DevToolsWindow* OpenDevToolsWindow( |
| 56 static DevToolsWindow* ToggleDevToolsWindow(RenderViewHost* inspected_rvh, | 56 content::RenderViewHost* inspected_rvh); |
| 57 DevToolsToggleAction action); | 57 static DevToolsWindow* ToggleDevToolsWindow( |
| 58 static void InspectElement(RenderViewHost* inspected_rvh, int x, int y); | 58 content::RenderViewHost* inspected_rvh, |
| 59 DevToolsToggleAction action); |
| 60 static void InspectElement( |
| 61 content::RenderViewHost* inspected_rvh, int x, int y); |
| 59 | 62 |
| 60 virtual ~DevToolsWindow(); | 63 virtual ~DevToolsWindow(); |
| 61 | 64 |
| 62 // Overridden from DevToolsClientHost. | 65 // Overridden from DevToolsClientHost. |
| 63 virtual void InspectedTabClosing() OVERRIDE; | 66 virtual void InspectedTabClosing() OVERRIDE; |
| 64 virtual void TabReplaced(content::WebContents* new_tab) OVERRIDE; | 67 virtual void TabReplaced(content::WebContents* new_tab) OVERRIDE; |
| 65 RenderViewHost* GetRenderViewHost(); | 68 content::RenderViewHost* GetRenderViewHost(); |
| 66 | 69 |
| 67 void Show(DevToolsToggleAction action); | 70 void Show(DevToolsToggleAction action); |
| 68 | 71 |
| 69 TabContentsWrapper* tab_contents() { return tab_contents_; } | 72 TabContentsWrapper* tab_contents() { return tab_contents_; } |
| 70 Browser* browser() { return browser_; } // For tests. | 73 Browser* browser() { return browser_; } // For tests. |
| 71 bool is_docked() { return docked_; } | 74 bool is_docked() { return docked_; } |
| 72 content::DevToolsClientHost* devtools_client_host() { | 75 content::DevToolsClientHost* devtools_client_host() { |
| 73 return frontend_host_; | 76 return frontend_host_; |
| 74 } | 77 } |
| 75 | 78 |
| 76 private: | 79 private: |
| 77 static DevToolsWindow* Create(Profile* profile, | 80 static DevToolsWindow* Create(Profile* profile, |
| 78 RenderViewHost* inspected_rvh, | 81 content::RenderViewHost* inspected_rvh, |
| 79 bool docked, bool shared_worker_frontend); | 82 bool docked, bool shared_worker_frontend); |
| 80 DevToolsWindow(TabContentsWrapper* tab_contents, Profile* profile, | 83 DevToolsWindow(TabContentsWrapper* tab_contents, Profile* profile, |
| 81 RenderViewHost* inspected_rvh, bool docked); | 84 content::RenderViewHost* inspected_rvh, bool docked); |
| 82 | 85 |
| 83 void CreateDevToolsBrowser(); | 86 void CreateDevToolsBrowser(); |
| 84 bool FindInspectedBrowserAndTabIndex(Browser**, int* tab); | 87 bool FindInspectedBrowserAndTabIndex(Browser**, int* tab); |
| 85 BrowserWindow* GetInspectedBrowserWindow(); | 88 BrowserWindow* GetInspectedBrowserWindow(); |
| 86 bool IsInspectedBrowserPopupOrPanel(); | 89 bool IsInspectedBrowserPopupOrPanel(); |
| 87 void UpdateFrontendAttachedState(); | 90 void UpdateFrontendAttachedState(); |
| 88 | 91 |
| 89 // Overridden from content::NotificationObserver. | 92 // Overridden from content::NotificationObserver. |
| 90 virtual void Observe(int type, | 93 virtual void Observe(int type, |
| 91 const content::NotificationSource& source, | 94 const content::NotificationSource& source, |
| (...skipping 20 matching lines...) Expand all Loading... |
| 112 virtual bool CanReloadContents(content::WebContents* source) const OVERRIDE; | 115 virtual bool CanReloadContents(content::WebContents* source) const OVERRIDE; |
| 113 virtual bool PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event, | 116 virtual bool PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event, |
| 114 bool* is_keyboard_shortcut) OVERRIDE; | 117 bool* is_keyboard_shortcut) OVERRIDE; |
| 115 virtual void HandleKeyboardEvent( | 118 virtual void HandleKeyboardEvent( |
| 116 const NativeWebKeyboardEvent& event) OVERRIDE; | 119 const NativeWebKeyboardEvent& event) OVERRIDE; |
| 117 virtual content::JavaScriptDialogCreator* | 120 virtual content::JavaScriptDialogCreator* |
| 118 GetJavaScriptDialogCreator() OVERRIDE; | 121 GetJavaScriptDialogCreator() OVERRIDE; |
| 119 | 122 |
| 120 virtual void FrameNavigating(const std::string& url) OVERRIDE {} | 123 virtual void FrameNavigating(const std::string& url) OVERRIDE {} |
| 121 | 124 |
| 122 static DevToolsWindow* ToggleDevToolsWindow(RenderViewHost* inspected_rvh, | 125 static DevToolsWindow* ToggleDevToolsWindow( |
| 123 bool force_open, | 126 content::RenderViewHost* inspected_rvh, |
| 124 DevToolsToggleAction action); | 127 bool force_open, |
| 128 DevToolsToggleAction action); |
| 125 static DevToolsWindow* AsDevToolsWindow(content::DevToolsClientHost*); | 129 static DevToolsWindow* AsDevToolsWindow(content::DevToolsClientHost*); |
| 126 | 130 |
| 127 // content::DevToolsClientHandlerDelegate overrides. | 131 // content::DevToolsClientHandlerDelegate overrides. |
| 128 virtual void ActivateWindow() OVERRIDE; | 132 virtual void ActivateWindow() OVERRIDE; |
| 129 virtual void CloseWindow() OVERRIDE; | 133 virtual void CloseWindow() OVERRIDE; |
| 130 virtual void MoveWindow(int x, int y) OVERRIDE; | 134 virtual void MoveWindow(int x, int y) OVERRIDE; |
| 131 virtual void DockWindow() OVERRIDE; | 135 virtual void DockWindow() OVERRIDE; |
| 132 virtual void UndockWindow() OVERRIDE; | 136 virtual void UndockWindow() OVERRIDE; |
| 133 virtual void SetDockSide(const std::string& side) OVERRIDE; | 137 virtual void SetDockSide(const std::string& side) OVERRIDE; |
| 134 virtual void OpenInNewTab(const std::string& url) OVERRIDE; | 138 virtual void OpenInNewTab(const std::string& url) OVERRIDE; |
| 135 virtual void SaveToFile(const std::string& suggested_file_name, | 139 virtual void SaveToFile(const std::string& suggested_file_name, |
| 136 const std::string& content) OVERRIDE; | 140 const std::string& content) OVERRIDE; |
| 137 | 141 |
| 138 void RequestSetDocked(bool docked); | 142 void RequestSetDocked(bool docked); |
| 139 | 143 |
| 140 Profile* profile_; | 144 Profile* profile_; |
| 141 TabContentsWrapper* inspected_tab_; | 145 TabContentsWrapper* inspected_tab_; |
| 142 TabContentsWrapper* tab_contents_; | 146 TabContentsWrapper* tab_contents_; |
| 143 Browser* browser_; | 147 Browser* browser_; |
| 144 bool docked_; | 148 bool docked_; |
| 145 bool is_loaded_; | 149 bool is_loaded_; |
| 146 DevToolsToggleAction action_on_load_; | 150 DevToolsToggleAction action_on_load_; |
| 147 content::NotificationRegistrar registrar_; | 151 content::NotificationRegistrar registrar_; |
| 148 content::DevToolsClientHost* frontend_host_; | 152 content::DevToolsClientHost* frontend_host_; |
| 149 DISALLOW_COPY_AND_ASSIGN(DevToolsWindow); | 153 DISALLOW_COPY_AND_ASSIGN(DevToolsWindow); |
| 150 }; | 154 }; |
| 151 | 155 |
| 152 #endif // CHROME_BROWSER_DEBUGGER_DEVTOOLS_WINDOW_H_ | 156 #endif // CHROME_BROWSER_DEBUGGER_DEVTOOLS_WINDOW_H_ |
| OLD | NEW |