| 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 <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 class PrefRegistrySyncable; | 47 class PrefRegistrySyncable; |
| 48 } | 48 } |
| 49 | 49 |
| 50 enum DevToolsDockSide { | 50 enum DevToolsDockSide { |
| 51 DEVTOOLS_DOCK_SIDE_UNDOCKED = 0, | 51 DEVTOOLS_DOCK_SIDE_UNDOCKED = 0, |
| 52 DEVTOOLS_DOCK_SIDE_BOTTOM, | 52 DEVTOOLS_DOCK_SIDE_BOTTOM, |
| 53 DEVTOOLS_DOCK_SIDE_RIGHT, | 53 DEVTOOLS_DOCK_SIDE_RIGHT, |
| 54 DEVTOOLS_DOCK_SIDE_MINIMIZED | 54 DEVTOOLS_DOCK_SIDE_MINIMIZED |
| 55 }; | 55 }; |
| 56 | 56 |
| 57 enum DevToolsClosingTarget { |
| 58 DEVTOOLS_CLOSING_TARGET_NONE = 0, |
| 59 DEVTOOLS_CLOSING_TARGET_DEVTOOLS, |
| 60 DEVTOOLS_CLOSING_TARGET_INSPECTED_PAGE |
| 61 }; |
| 62 |
| 57 class DevToolsWindow : private content::NotificationObserver, | 63 class DevToolsWindow : private content::NotificationObserver, |
| 58 private content::WebContentsDelegate, | 64 private content::WebContentsDelegate, |
| 59 private content::DevToolsFrontendHostDelegate, | 65 private content::DevToolsFrontendHostDelegate, |
| 60 private DevToolsEmbedderMessageDispatcher::Delegate { | 66 private DevToolsEmbedderMessageDispatcher::Delegate { |
| 61 public: | 67 public: |
| 62 typedef base::Callback<void(bool)> InfoBarCallback; | 68 typedef base::Callback<void(bool)> InfoBarCallback; |
| 63 | 69 |
| 64 static const char kDevToolsApp[]; | 70 static const char kDevToolsApp[]; |
| 65 | 71 |
| 66 virtual ~DevToolsWindow(); | 72 virtual ~DevToolsWindow(); |
| 67 | 73 |
| 68 static std::string GetDevToolsWindowPlacementPrefKey(); | 74 static std::string GetDevToolsWindowPlacementPrefKey(); |
| 69 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); | 75 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); |
| 76 static DevToolsWindow* GetInstanceForInspectedTab( |
| 77 content::WebContents* inspected_tab); |
| 70 static DevToolsWindow* GetDockedInstanceForInspectedTab( | 78 static DevToolsWindow* GetDockedInstanceForInspectedTab( |
| 71 content::WebContents* inspected_tab); | 79 content::WebContents* inspected_tab); |
| 72 static bool IsDevToolsWindow(content::RenderViewHost* window_rvh); | 80 static bool IsDevToolsWindow(content::RenderViewHost* window_rvh); |
| 73 static DevToolsWindow* OpenDevToolsWindowForWorker( | 81 static DevToolsWindow* OpenDevToolsWindowForWorker( |
| 74 Profile* profile, | 82 Profile* profile, |
| 75 content::DevToolsAgentHost* worker_agent); | 83 content::DevToolsAgentHost* worker_agent); |
| 76 static DevToolsWindow* CreateDevToolsWindowForWorker(Profile* profile); | 84 static DevToolsWindow* CreateDevToolsWindowForWorker(Profile* profile); |
| 77 static DevToolsWindow* OpenDevToolsWindow( | 85 static DevToolsWindow* OpenDevToolsWindow( |
| 78 content::RenderViewHost* inspected_rvh); | 86 content::RenderViewHost* inspected_rvh); |
| 79 static DevToolsWindow* ToggleDevToolsWindow( | 87 static DevToolsWindow* ToggleDevToolsWindow( |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 int GetHeight(int container_height); | 126 int GetHeight(int container_height); |
| 119 | 127 |
| 120 // Stores preferred devtools window width for this instance. | 128 // Stores preferred devtools window width for this instance. |
| 121 void SetWidth(int width); | 129 void SetWidth(int width); |
| 122 | 130 |
| 123 // Stores preferred devtools window height for this instance. | 131 // Stores preferred devtools window height for this instance. |
| 124 void SetHeight(int height); | 132 void SetHeight(int height); |
| 125 | 133 |
| 126 void Show(DevToolsToggleAction action); | 134 void Show(DevToolsToggleAction action); |
| 127 | 135 |
| 136 static void HandleBeforeUnload(content::WebContents*, bool, bool*); |
| 137 bool InspectedPageWillClose(); |
| 138 void InspectedPageCancelClose(); |
| 139 |
| 128 private: | 140 private: |
| 129 friend class DevToolsControllerTest; | 141 friend class DevToolsControllerTest; |
| 130 | 142 |
| 131 DevToolsWindow(Profile* profile, | 143 DevToolsWindow(Profile* profile, |
| 132 const GURL& frontend_url, | 144 const GURL& frontend_url, |
| 133 content::RenderViewHost* inspected_rvh, | 145 content::RenderViewHost* inspected_rvh, |
| 134 DevToolsDockSide dock_side); | 146 DevToolsDockSide dock_side); |
| 135 | 147 |
| 136 static DevToolsWindow* Create(Profile* profile, | 148 static DevToolsWindow* Create(Profile* profile, |
| 137 const GURL& frontend_url, | 149 const GURL& frontend_url, |
| (...skipping 21 matching lines...) Expand all Loading... |
| 159 virtual content::WebContents* OpenURLFromTab( | 171 virtual content::WebContents* OpenURLFromTab( |
| 160 content::WebContents* source, | 172 content::WebContents* source, |
| 161 const content::OpenURLParams& params) OVERRIDE; | 173 const content::OpenURLParams& params) OVERRIDE; |
| 162 virtual void AddNewContents(content::WebContents* source, | 174 virtual void AddNewContents(content::WebContents* source, |
| 163 content::WebContents* new_contents, | 175 content::WebContents* new_contents, |
| 164 WindowOpenDisposition disposition, | 176 WindowOpenDisposition disposition, |
| 165 const gfx::Rect& initial_pos, | 177 const gfx::Rect& initial_pos, |
| 166 bool user_gesture, | 178 bool user_gesture, |
| 167 bool* was_blocked) OVERRIDE; | 179 bool* was_blocked) OVERRIDE; |
| 168 virtual void CloseContents(content::WebContents* source) OVERRIDE; | 180 virtual void CloseContents(content::WebContents* source) OVERRIDE; |
| 181 virtual void BeforeUnloadFired(content::WebContents* tab, |
| 182 bool proceed, |
| 183 bool* proceed_to_fire_unload) OVERRIDE; |
| 169 virtual bool PreHandleKeyboardEvent( | 184 virtual bool PreHandleKeyboardEvent( |
| 170 content::WebContents* source, | 185 content::WebContents* source, |
| 171 const content::NativeWebKeyboardEvent& event, | 186 const content::NativeWebKeyboardEvent& event, |
| 172 bool* is_keyboard_shortcut) OVERRIDE; | 187 bool* is_keyboard_shortcut) OVERRIDE; |
| 173 virtual void HandleKeyboardEvent( | 188 virtual void HandleKeyboardEvent( |
| 174 content::WebContents* source, | 189 content::WebContents* source, |
| 175 const content::NativeWebKeyboardEvent& event) OVERRIDE; | 190 const content::NativeWebKeyboardEvent& event) OVERRIDE; |
| 176 virtual content::JavaScriptDialogManager* | 191 virtual content::JavaScriptDialogManager* |
| 177 GetJavaScriptDialogManager() OVERRIDE; | 192 GetJavaScriptDialogManager() OVERRIDE; |
| 178 virtual content::ColorChooser* OpenColorChooser( | 193 virtual content::ColorChooser* OpenColorChooser( |
| 179 content::WebContents* web_contents, | 194 content::WebContents* web_contents, |
| 180 SkColor color) OVERRIDE; | 195 SkColor color) OVERRIDE; |
| 181 virtual void RunFileChooser( | 196 virtual void RunFileChooser( |
| 182 content::WebContents* web_contents, | 197 content::WebContents* web_contents, |
| 183 const content::FileChooserParams& params) OVERRIDE; | 198 const content::FileChooserParams& params) OVERRIDE; |
| 184 virtual void WebContentsFocused(content::WebContents* contents) OVERRIDE; | 199 virtual void WebContentsFocused(content::WebContents* contents) OVERRIDE; |
| 185 | 200 |
| 186 // content::DevToolsFrontendHostDelegate override: | 201 // content::DevToolsFrontendHostDelegate override: |
| 187 virtual void DispatchOnEmbedder(const std::string& message) OVERRIDE; | 202 virtual void DispatchOnEmbedder(const std::string& message) OVERRIDE; |
| 188 | 203 |
| 189 // DevToolsEmbedderMessageDispatcher::Delegate overrides: | 204 // DevToolsEmbedderMessageDispatcher::Delegate overrides: |
| 190 virtual void ActivateWindow() OVERRIDE; | 205 virtual void ActivateWindow() OVERRIDE; |
| 206 virtual void ActivateContents(content::WebContents* contents) OVERRIDE; |
| 191 virtual void CloseWindow() OVERRIDE; | 207 virtual void CloseWindow() OVERRIDE; |
| 192 virtual void MoveWindow(int x, int y) OVERRIDE; | 208 virtual void MoveWindow(int x, int y) OVERRIDE; |
| 193 virtual void SetDockSide(const std::string& side) OVERRIDE; | 209 virtual void SetDockSide(const std::string& side) OVERRIDE; |
| 194 virtual void OpenInNewTab(const std::string& url) OVERRIDE; | 210 virtual void OpenInNewTab(const std::string& url) OVERRIDE; |
| 195 virtual void SaveToFile(const std::string& url, | 211 virtual void SaveToFile(const std::string& url, |
| 196 const std::string& content, | 212 const std::string& content, |
| 197 bool save_as) OVERRIDE; | 213 bool save_as) OVERRIDE; |
| 198 virtual void AppendToFile(const std::string& url, | 214 virtual void AppendToFile(const std::string& url, |
| 199 const std::string& content) OVERRIDE; | 215 const std::string& content) OVERRIDE; |
| 200 virtual void RequestFileSystems() OVERRIDE; | 216 virtual void RequestFileSystems() OVERRIDE; |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 scoped_ptr<DevToolsFileHelper> file_helper_; | 278 scoped_ptr<DevToolsFileHelper> file_helper_; |
| 263 scoped_refptr<DevToolsFileSystemIndexer> file_system_indexer_; | 279 scoped_refptr<DevToolsFileSystemIndexer> file_system_indexer_; |
| 264 typedef std::map< | 280 typedef std::map< |
| 265 int, | 281 int, |
| 266 scoped_refptr<DevToolsFileSystemIndexer::FileSystemIndexingJob> > | 282 scoped_refptr<DevToolsFileSystemIndexer::FileSystemIndexingJob> > |
| 267 IndexingJobsMap; | 283 IndexingJobsMap; |
| 268 IndexingJobsMap indexing_jobs_; | 284 IndexingJobsMap indexing_jobs_; |
| 269 int width_; | 285 int width_; |
| 270 int height_; | 286 int height_; |
| 271 DevToolsDockSide dock_side_before_minimized_; | 287 DevToolsDockSide dock_side_before_minimized_; |
| 288 DevToolsClosingTarget closing_target_; |
| 289 bool inspected_page_is_closing_; |
| 272 | 290 |
| 273 scoped_ptr<DevToolsEmbedderMessageDispatcher> embedder_message_dispatcher_; | 291 scoped_ptr<DevToolsEmbedderMessageDispatcher> embedder_message_dispatcher_; |
| 274 DISALLOW_COPY_AND_ASSIGN(DevToolsWindow); | 292 DISALLOW_COPY_AND_ASSIGN(DevToolsWindow); |
| 275 }; | 293 }; |
| 276 | 294 |
| 277 #endif // CHROME_BROWSER_DEVTOOLS_DEVTOOLS_WINDOW_H_ | 295 #endif // CHROME_BROWSER_DEVTOOLS_DEVTOOLS_WINDOW_H_ |
| OLD | NEW |