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 CONTENT_BROWSER_DEBUGGER_DEVTOOLS_WINDOW_H_ | 5 #ifndef CONTENT_BROWSER_DEBUGGER_DEVTOOLS_WINDOW_H_ |
6 #define CONTENT_BROWSER_DEBUGGER_DEVTOOLS_WINDOW_H_ | 6 #define CONTENT_BROWSER_DEBUGGER_DEVTOOLS_WINDOW_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
| 10 #include <vector> |
10 | 11 |
11 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
12 #include "content/browser/debugger/devtools_client_host.h" | 13 #include "content/browser/debugger/devtools_client_host.h" |
13 #include "content/browser/debugger/devtools_toggle_action.h" | 14 #include "content/browser/debugger/devtools_toggle_action.h" |
14 #include "content/browser/tab_contents/tab_contents_delegate.h" | 15 #include "content/browser/tab_contents/tab_contents_delegate.h" |
15 #include "content/common/notification_observer.h" | 16 #include "content/common/notification_observer.h" |
16 #include "content/common/notification_registrar.h" | 17 #include "content/common/notification_registrar.h" |
17 | 18 |
18 namespace IPC { | 19 namespace IPC { |
19 class Message; | 20 class Message; |
20 } | 21 } |
21 | 22 |
22 class Browser; | 23 class Browser; |
23 class BrowserWindow; | 24 class BrowserWindow; |
24 class Profile; | 25 class Profile; |
25 class RenderViewHost; | 26 class RenderViewHost; |
26 class Value; | 27 class Value; |
27 | 28 |
28 class DevToolsWindow | 29 class DevToolsWindow |
29 : public DevToolsClientHost, | 30 : public DevToolsClientHost, |
30 public NotificationObserver, | 31 public NotificationObserver, |
31 public TabContentsDelegate { | 32 public TabContentsDelegate { |
32 public: | 33 public: |
33 static const char kDevToolsApp[]; | 34 static const char kDevToolsApp[]; |
34 static TabContentsWrapper* GetDevToolsContents(TabContents* inspected_tab); | 35 static TabContentsWrapper* GetDevToolsContents(TabContents* inspected_tab); |
| 36 static DevToolsWindow* FindDevToolsWindow(RenderViewHost* window_rvh); |
35 | 37 |
36 DevToolsWindow(Profile* profile, RenderViewHost* inspected_rvh, bool docked); | 38 static void OpenDevToolsWindow(RenderViewHost* inspected_rvh); |
| 39 static void ToggleDevToolsWindow(RenderViewHost* inspected_rvh, |
| 40 DevToolsToggleAction action); |
| 41 static void InspectElement(RenderViewHost* inspected_rvh, int x, int y); |
| 42 |
37 virtual ~DevToolsWindow(); | 43 virtual ~DevToolsWindow(); |
38 | 44 |
39 // Overridden from DevToolsClientHost. | 45 // Overridden from DevToolsClientHost. |
40 virtual DevToolsWindow* AsDevToolsWindow(); | |
41 virtual void SendMessageToClient(const IPC::Message& message); | 46 virtual void SendMessageToClient(const IPC::Message& message); |
42 virtual void InspectedTabClosing(); | 47 virtual void InspectedTabClosing(); |
43 virtual void TabReplaced(TabContentsWrapper* new_tab); | 48 virtual void TabReplaced(TabContentsWrapper* new_tab); |
44 | 49 |
45 void Show(DevToolsToggleAction action); | 50 void Show(DevToolsToggleAction action); |
46 void Activate(); | 51 void Activate(); |
47 void SetDocked(bool docked); | 52 void SetDocked(bool docked); |
48 RenderViewHost* GetRenderViewHost(); | 53 RenderViewHost* GetRenderViewHost(); |
49 | 54 |
50 TabContentsWrapper* tab_contents() { return tab_contents_; } | 55 TabContentsWrapper* tab_contents() { return tab_contents_; } |
51 Browser* browser() { return browser_; } // For tests. | 56 Browser* browser() { return browser_; } // For tests. |
52 bool is_docked() { return docked_; } | 57 bool is_docked() { return docked_; } |
53 | 58 |
54 private: | 59 private: |
| 60 DevToolsWindow(Profile* profile, RenderViewHost* inspected_rvh, bool docked); |
| 61 |
55 void CreateDevToolsBrowser(); | 62 void CreateDevToolsBrowser(); |
56 bool FindInspectedBrowserAndTabIndex(Browser**, int* tab); | 63 bool FindInspectedBrowserAndTabIndex(Browser**, int* tab); |
57 BrowserWindow* GetInspectedBrowserWindow(); | 64 BrowserWindow* GetInspectedBrowserWindow(); |
58 bool IsInspectedBrowserPopupOrPanel(); | 65 bool IsInspectedBrowserPopupOrPanel(); |
59 void UpdateFrontendAttachedState(); | 66 void UpdateFrontendAttachedState(); |
60 | 67 |
61 // Overridden from NotificationObserver. | 68 // Overridden from NotificationObserver. |
62 virtual void Observe(NotificationType type, | 69 virtual void Observe(NotificationType type, |
63 const NotificationSource& source, | 70 const NotificationSource& source, |
64 const NotificationDetails& details); | 71 const NotificationDetails& details); |
(...skipping 17 matching lines...) Expand all Loading... |
82 const gfx::Rect& initial_pos, | 89 const gfx::Rect& initial_pos, |
83 bool user_gesture); | 90 bool user_gesture); |
84 virtual void CloseContents(TabContents* source) {} | 91 virtual void CloseContents(TabContents* source) {} |
85 virtual bool CanReloadContents(TabContents* source) const; | 92 virtual bool CanReloadContents(TabContents* source) const; |
86 virtual bool PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event, | 93 virtual bool PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event, |
87 bool* is_keyboard_shortcut); | 94 bool* is_keyboard_shortcut); |
88 virtual void HandleKeyboardEvent(const NativeWebKeyboardEvent& event); | 95 virtual void HandleKeyboardEvent(const NativeWebKeyboardEvent& event); |
89 | 96 |
90 virtual void FrameNavigating(const std::string& url) {} | 97 virtual void FrameNavigating(const std::string& url) {} |
91 | 98 |
| 99 static void ToggleDevToolsWindow(RenderViewHost* inspected_rvh, |
| 100 bool force_open, |
| 101 DevToolsToggleAction action); |
| 102 static DevToolsWindow* AsDevToolsWindow(DevToolsClientHost*); |
| 103 |
92 Profile* profile_; | 104 Profile* profile_; |
93 TabContentsWrapper* inspected_tab_; | 105 TabContentsWrapper* inspected_tab_; |
94 TabContentsWrapper* tab_contents_; | 106 TabContentsWrapper* tab_contents_; |
95 Browser* browser_; | 107 Browser* browser_; |
96 bool docked_; | 108 bool docked_; |
97 bool is_loaded_; | 109 bool is_loaded_; |
98 DevToolsToggleAction action_on_load_; | 110 DevToolsToggleAction action_on_load_; |
99 NotificationRegistrar registrar_; | 111 NotificationRegistrar registrar_; |
| 112 typedef std::vector<DevToolsWindow*> DevToolsWindowList; |
| 113 static DevToolsWindowList instances_; |
100 DISALLOW_COPY_AND_ASSIGN(DevToolsWindow); | 114 DISALLOW_COPY_AND_ASSIGN(DevToolsWindow); |
101 }; | 115 }; |
102 | 116 |
103 #endif // CONTENT_BROWSER_DEBUGGER_DEVTOOLS_WINDOW_H_ | 117 #endif // CONTENT_BROWSER_DEBUGGER_DEVTOOLS_WINDOW_H_ |
OLD | NEW |