Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(331)

Side by Side Diff: chrome/browser/devtools/devtools_window.h

Issue 253823005: DevTools: extract DevToolsWindowBase, leave docking, unload and factory logic in DevToolsWindow. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebaselined Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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>
9 #include <vector>
10
11 #include "base/basictypes.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "base/memory/weak_ptr.h"
14 #include "base/strings/string16.h"
15 #include "chrome/browser/devtools/device/devtools_android_bridge.h"
16 #include "chrome/browser/devtools/devtools_contents_resizing_strategy.h" 8 #include "chrome/browser/devtools/devtools_contents_resizing_strategy.h"
17 #include "chrome/browser/devtools/devtools_embedder_message_dispatcher.h"
18 #include "chrome/browser/devtools/devtools_file_helper.h"
19 #include "chrome/browser/devtools/devtools_file_system_indexer.h"
20 #include "chrome/browser/devtools/devtools_targets_ui.h"
21 #include "chrome/browser/devtools/devtools_toggle_action.h" 9 #include "chrome/browser/devtools/devtools_toggle_action.h"
22 #include "content/public/browser/devtools_client_host.h" 10 #include "chrome/browser/devtools/devtools_window_base.h"
23 #include "content/public/browser/devtools_frontend_host_delegate.h"
24 #include "content/public/browser/notification_observer.h"
25 #include "content/public/browser/notification_registrar.h"
26 #include "content/public/browser/web_contents_delegate.h" 11 #include "content/public/browser/web_contents_delegate.h"
27 #include "ui/gfx/size.h"
28 12
29 class Browser; 13 class Browser;
30 class BrowserWindow; 14 class BrowserWindow;
31 class DevToolsControllerTest; 15 class DevToolsControllerTest;
32 class DevToolsEventForwarder; 16 class DevToolsEventForwarder;
33 class Profile;
34
35 namespace base {
36 class Value;
37 }
38 17
39 namespace content { 18 namespace content {
40 class DevToolsAgentHost; 19 class DevToolsAgentHost;
41 class DevToolsClientHost;
42 struct FileChooserParams;
43 struct NativeWebKeyboardEvent; 20 struct NativeWebKeyboardEvent;
44 class RenderViewHost; 21 class RenderViewHost;
45 class WebContents;
46 }
47
48 namespace IPC {
49 class Message;
50 } 22 }
51 23
52 namespace user_prefs { 24 namespace user_prefs {
53 class PrefRegistrySyncable; 25 class PrefRegistrySyncable;
54 } 26 }
55 27
56 class DevToolsWindow : private content::NotificationObserver, 28 class DevToolsWindow : public DevToolsWindowBase,
57 private content::WebContentsDelegate, 29 public content::WebContentsDelegate {
58 private content::DevToolsFrontendHostDelegate,
59 private DevToolsEmbedderMessageDispatcher::Delegate,
60 private DevToolsAndroidBridge::DeviceCountListener {
61 public: 30 public:
62 typedef base::Callback<void(bool)> InfoBarCallback;
63
64 static const char kDevToolsApp[]; 31 static const char kDevToolsApp[];
65 32
66 virtual ~DevToolsWindow(); 33 virtual ~DevToolsWindow();
67 34
68 static std::string GetDevToolsWindowPlacementPrefKey(); 35 static std::string GetDevToolsWindowPlacementPrefKey();
69 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); 36 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
70 37
71 // Return the DevToolsWindow for the given RenderViewHost if one exists, 38 // Return the DevToolsWindow for the given RenderViewHost if one exists,
72 // otherwise NULL. 39 // otherwise NULL.
73 static DevToolsWindow* GetInstanceForInspectedRenderViewHost( 40 static DevToolsWindow* GetInstanceForInspectedRenderViewHost(
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 content::DevToolsAgentHost* agent_host); 82 content::DevToolsAgentHost* agent_host);
116 83
117 // Worker frontend is always undocked. 84 // Worker frontend is always undocked.
118 static DevToolsWindow* OpenDevToolsWindowForWorker( 85 static DevToolsWindow* OpenDevToolsWindowForWorker(
119 Profile* profile, 86 Profile* profile,
120 content::DevToolsAgentHost* worker_agent); 87 content::DevToolsAgentHost* worker_agent);
121 88
122 static void InspectElement( 89 static void InspectElement(
123 content::RenderViewHost* inspected_rvh, int x, int y); 90 content::RenderViewHost* inspected_rvh, int x, int y);
124 91
125 // content::DevToolsFrontendHostDelegate:
126 virtual void InspectedContentsClosing() OVERRIDE;
127
128 content::WebContents* web_contents() { return web_contents_; }
129 Browser* browser() { return browser_; } // For tests. 92 Browser* browser() { return browser_; } // For tests.
130 93
131 content::RenderViewHost* GetRenderViewHost();
132
133 // Inspected WebContents is placed over DevTools WebContents in docked mode. 94 // Inspected WebContents is placed over DevTools WebContents in docked mode.
134 // The following method returns the resizing strategy of inspected 95 // The following method returns the resizing strategy of inspected
135 // WebContents relative to DevTools WebContents. 96 // WebContents relative to DevTools WebContents.
136 const DevToolsContentsResizingStrategy& GetContentsResizingStrategy() const; 97 const DevToolsContentsResizingStrategy& GetContentsResizingStrategy() const;
137 98
138 // Minimum size of the docked DevTools WebContents. This includes 99 // Minimum size of the docked DevTools WebContents. This includes
139 // the overlaying inspected WebContents size. 100 // the overlaying inspected WebContents size.
140 gfx::Size GetMinimumSize() const; 101 gfx::Size GetMinimumSize() const;
141 102
142 // Sets closure to be called after load is done. If already loaded, calls 103 // Sets closure to be called after load is done. If already loaded, calls
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 static DevToolsWindow* FindDevToolsWindow(content::DevToolsAgentHost*); 221 static DevToolsWindow* FindDevToolsWindow(content::DevToolsAgentHost*);
261 static DevToolsWindow* AsDevToolsWindow(content::RenderViewHost*); 222 static DevToolsWindow* AsDevToolsWindow(content::RenderViewHost*);
262 static DevToolsWindow* CreateDevToolsWindowForWorker(Profile* profile); 223 static DevToolsWindow* CreateDevToolsWindowForWorker(Profile* profile);
263 static bool FindInspectedBrowserAndTabIndex( 224 static bool FindInspectedBrowserAndTabIndex(
264 content::WebContents* inspected_web_contents, Browser**, int* tab); 225 content::WebContents* inspected_web_contents, Browser**, int* tab);
265 static DevToolsWindow* ToggleDevToolsWindow( 226 static DevToolsWindow* ToggleDevToolsWindow(
266 content::RenderViewHost* inspected_rvh, 227 content::RenderViewHost* inspected_rvh,
267 bool force_open, 228 bool force_open,
268 const DevToolsToggleAction& action); 229 const DevToolsToggleAction& action);
269 230
270 // content::NotificationObserver: 231 // content::DevToolsFrontendHostDelegate override:
271 virtual void Observe(int type, 232 virtual void InspectedContentsClosing() OVERRIDE;
272 const content::NotificationSource& source,
273 const content::NotificationDetails& details) OVERRIDE;
274 233
275 // content::WebContentsDelegate: 234 // content::WebContentsDelegate:
276 virtual content::WebContents* OpenURLFromTab( 235 virtual content::WebContents* OpenURLFromTab(
277 content::WebContents* source, 236 content::WebContents* source,
278 const content::OpenURLParams& params) OVERRIDE; 237 const content::OpenURLParams& params) OVERRIDE;
238 virtual void ActivateContents(content::WebContents* contents) OVERRIDE;
279 virtual void AddNewContents(content::WebContents* source, 239 virtual void AddNewContents(content::WebContents* source,
280 content::WebContents* new_contents, 240 content::WebContents* new_contents,
281 WindowOpenDisposition disposition, 241 WindowOpenDisposition disposition,
282 const gfx::Rect& initial_pos, 242 const gfx::Rect& initial_pos,
283 bool user_gesture, 243 bool user_gesture,
284 bool* was_blocked) OVERRIDE; 244 bool* was_blocked) OVERRIDE;
285 virtual void CloseContents(content::WebContents* source) OVERRIDE; 245 virtual void CloseContents(content::WebContents* source) OVERRIDE;
286 virtual void ContentsZoomChange(bool zoom_in) OVERRIDE; 246 virtual void ContentsZoomChange(bool zoom_in) OVERRIDE;
287 virtual void BeforeUnloadFired(content::WebContents* tab, 247 virtual void BeforeUnloadFired(content::WebContents* tab,
288 bool proceed, 248 bool proceed,
(...skipping 12 matching lines...) Expand all
301 SkColor color, 261 SkColor color,
302 const std::vector<content::ColorSuggestion>& suggestions) OVERRIDE; 262 const std::vector<content::ColorSuggestion>& suggestions) OVERRIDE;
303 virtual void RunFileChooser( 263 virtual void RunFileChooser(
304 content::WebContents* web_contents, 264 content::WebContents* web_contents,
305 const content::FileChooserParams& params) OVERRIDE; 265 const content::FileChooserParams& params) OVERRIDE;
306 virtual void WebContentsFocused(content::WebContents* contents) OVERRIDE; 266 virtual void WebContentsFocused(content::WebContents* contents) OVERRIDE;
307 virtual bool PreHandleGestureEvent( 267 virtual bool PreHandleGestureEvent(
308 content::WebContents* source, 268 content::WebContents* source,
309 const blink::WebGestureEvent& event) OVERRIDE; 269 const blink::WebGestureEvent& event) OVERRIDE;
310 270
311 // content::DevToolsFrontendHostDelegate override:
312 virtual void DispatchOnEmbedder(const std::string& message) OVERRIDE;
313
314 // DevToolsEmbedderMessageDispatcher::Delegate overrides: 271 // DevToolsEmbedderMessageDispatcher::Delegate overrides:
315 virtual void ActivateWindow() OVERRIDE; 272 virtual void ActivateWindow() OVERRIDE;
316 virtual void ActivateContents(content::WebContents* contents) OVERRIDE;
317 virtual void CloseWindow() OVERRIDE; 273 virtual void CloseWindow() OVERRIDE;
318 virtual void SetContentsInsets( 274 virtual void SetContentsInsets(
319 int left, int top, int right, int bottom) OVERRIDE; 275 int left, int top, int right, int bottom) OVERRIDE;
320 virtual void SetContentsResizingStrategy( 276 virtual void SetContentsResizingStrategy(
321 const gfx::Insets& insets, const gfx::Size& min_size) OVERRIDE; 277 const gfx::Insets& insets, const gfx::Size& min_size) OVERRIDE;
322 virtual void InspectElementCompleted() OVERRIDE; 278 virtual void InspectElementCompleted() OVERRIDE;
323 virtual void MoveWindow(int x, int y) OVERRIDE; 279 virtual void MoveWindow(int x, int y) OVERRIDE;
324 virtual void SetIsDocked(bool is_docked) OVERRIDE; 280 virtual void SetIsDocked(bool is_docked) OVERRIDE;
325 virtual void OpenInNewTab(const std::string& url) OVERRIDE; 281 virtual void OpenInNewTab(const std::string& url) OVERRIDE;
326 virtual void SaveToFile(const std::string& url,
327 const std::string& content,
328 bool save_as) OVERRIDE;
329 virtual void AppendToFile(const std::string& url,
330 const std::string& content) OVERRIDE;
331 virtual void RequestFileSystems() OVERRIDE;
332 virtual void AddFileSystem() OVERRIDE;
333 virtual void RemoveFileSystem(const std::string& file_system_path) OVERRIDE;
334 virtual void UpgradeDraggedFileSystemPermissions(
335 const std::string& file_system_url) OVERRIDE;
336 virtual void IndexPath(int request_id,
337 const std::string& file_system_path) OVERRIDE;
338 virtual void StopIndexing(int request_id) OVERRIDE;
339 virtual void SearchInPath(int request_id,
340 const std::string& file_system_path,
341 const std::string& query) OVERRIDE;
342 virtual void SetWhitelistedShortcuts(const std::string& message) OVERRIDE; 282 virtual void SetWhitelistedShortcuts(const std::string& message) OVERRIDE;
343 virtual void ZoomIn() OVERRIDE;
344 virtual void ZoomOut() OVERRIDE;
345 virtual void ResetZoom() OVERRIDE;
346 virtual void OpenUrlOnRemoteDeviceAndInspect(const std::string& browser_id,
347 const std::string& url) OVERRIDE;
348 virtual void StartRemoteDevicesListener() OVERRIDE;
349 virtual void StopRemoteDevicesListener() OVERRIDE;
350 virtual void EnableRemoteDeviceCounter(bool enable) OVERRIDE;
351 283
352 // DevToolsAndroidBridge::DeviceCountListener override: 284 // DevToolsWindowBase overrides
353 virtual void DeviceCountChanged(int count) OVERRIDE; 285 virtual void AddDevToolsExtensionsToClient() OVERRIDE;
354 286 virtual void DocumentOnLoadCompletedInMainFrame() OVERRIDE;
355 // Forwards discovered devices to frontend.
356 virtual void PopulateRemoteDevices(const std::string& source,
357 scoped_ptr<base::ListValue> targets);
358
359 // DevToolsFileHelper callbacks.
360 void FileSavedAs(const std::string& url);
361 void CanceledFileSaveAs(const std::string& url);
362 void AppendedTo(const std::string& url);
363 void FileSystemsLoaded(
364 const std::vector<DevToolsFileHelper::FileSystem>& file_systems);
365 void FileSystemAdded(const DevToolsFileHelper::FileSystem& file_system);
366 void IndexingTotalWorkCalculated(int request_id,
367 const std::string& file_system_path,
368 int total_work);
369 void IndexingWorked(int request_id,
370 const std::string& file_system_path,
371 int worked);
372 void IndexingDone(int request_id, const std::string& file_system_path);
373 void SearchCompleted(int request_id,
374 const std::string& file_system_path,
375 const std::vector<std::string>& file_paths);
376 void ShowDevToolsConfirmInfoBar(const base::string16& message,
377 const InfoBarCallback& callback);
378 287
379 void CreateDevToolsBrowser(); 288 void CreateDevToolsBrowser();
380 BrowserWindow* GetInspectedBrowserWindow(); 289 BrowserWindow* GetInspectedBrowserWindow();
381 void ScheduleShow(const DevToolsToggleAction& action); 290 void ScheduleShow(const DevToolsToggleAction& action);
382 void Show(const DevToolsToggleAction& action); 291 void Show(const DevToolsToggleAction& action);
383 void DoAction(const DevToolsToggleAction& action); 292 void DoAction(const DevToolsToggleAction& action);
384 void LoadCompleted(); 293 void LoadCompleted();
385 void SetIsDockedAndShowImmediatelyForTest(bool is_docked); 294 void SetIsDockedAndShowImmediatelyForTest(bool is_docked);
386 void UpdateTheme();
387 void AddDevToolsExtensionsToClient();
388 void CallClientFunction(const std::string& function_name,
389 const base::Value* arg1,
390 const base::Value* arg2,
391 const base::Value* arg3);
392 void UpdateBrowserToolbar(); 295 void UpdateBrowserToolbar();
393 content::WebContents* GetInspectedWebContents(); 296 content::WebContents* GetInspectedWebContents();
394 void DocumentOnLoadCompletedInMainFrame();
395 297
396 class InspectedWebContentsObserver; 298 class InspectedWebContentsObserver;
397 scoped_ptr<InspectedWebContentsObserver> inspected_contents_observer_; 299 scoped_ptr<InspectedWebContentsObserver> inspected_contents_observer_;
398 class FrontendWebContentsObserver;
399 friend class FrontendWebContentsObserver;
400 scoped_ptr<FrontendWebContentsObserver> frontend_contents_observer_;
401 300
402 Profile* profile_;
403 content::WebContents* web_contents_;
404 Browser* browser_; 301 Browser* browser_;
405 bool is_docked_; 302 bool is_docked_;
406 const bool can_dock_; 303 const bool can_dock_;
407 bool device_listener_enabled_;
408 LoadState load_state_; 304 LoadState load_state_;
409 DevToolsToggleAction action_on_load_; 305 DevToolsToggleAction action_on_load_;
410 bool ignore_set_is_docked_; 306 bool ignore_set_is_docked_;
411 content::NotificationRegistrar registrar_;
412 scoped_ptr<content::DevToolsClientHost> frontend_host_;
413 scoped_ptr<DevToolsFileHelper> file_helper_;
414 scoped_refptr<DevToolsFileSystemIndexer> file_system_indexer_;
415 typedef std::map<
416 int,
417 scoped_refptr<DevToolsFileSystemIndexer::FileSystemIndexingJob> >
418 IndexingJobsMap;
419 IndexingJobsMap indexing_jobs_;
420 DevToolsContentsResizingStrategy contents_resizing_strategy_; 307 DevToolsContentsResizingStrategy contents_resizing_strategy_;
421 // True if we're in the process of handling a beforeunload event originating 308 // True if we're in the process of handling a beforeunload event originating
422 // from the inspected webcontents, see InterceptPageBeforeUnload for details. 309 // from the inspected webcontents, see InterceptPageBeforeUnload for details.
423 bool intercepted_page_beforeunload_; 310 bool intercepted_page_beforeunload_;
424 base::Closure load_completed_callback_; 311 base::Closure load_completed_callback_;
425 312
426 scoped_ptr<DevToolsRemoteTargetsUIHandler> remote_targets_handler_;
427 scoped_ptr<DevToolsEmbedderMessageDispatcher> embedder_message_dispatcher_;
428 base::WeakPtrFactory<DevToolsWindow> weak_factory_;
429 base::TimeTicks inspect_element_start_time_; 313 base::TimeTicks inspect_element_start_time_;
430 scoped_ptr<DevToolsEventForwarder> event_forwarder_; 314 scoped_ptr<DevToolsEventForwarder> event_forwarder_;
431 315
432 friend class DevToolsEventForwarder; 316 friend class DevToolsEventForwarder;
433 DISALLOW_COPY_AND_ASSIGN(DevToolsWindow); 317 DISALLOW_COPY_AND_ASSIGN(DevToolsWindow);
434 }; 318 };
435 319
436 #endif // CHROME_BROWSER_DEVTOOLS_DEVTOOLS_WINDOW_H_ 320 #endif // CHROME_BROWSER_DEVTOOLS_DEVTOOLS_WINDOW_H_
OLDNEW
« no previous file with comments | « chrome/browser/devtools/devtools_sanity_browsertest.cc ('k') | chrome/browser/devtools/devtools_window.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698