| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_DEBUGGER_DEVTOOLS_MANAGER_H_ |
| 6 #define CHROME_BROWSER_DEBUGGER_DEVTOOLS_MANAGER_H_ | 6 #define CHROME_BROWSER_DEBUGGER_DEVTOOLS_MANAGER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 void ForwardToDevToolsClient(const RenderViewHost& from, | 46 void ForwardToDevToolsClient(const RenderViewHost& from, |
| 47 const IPC::Message& message); | 47 const IPC::Message& message); |
| 48 | 48 |
| 49 void OpenDevToolsWindow(WebContents* wc); | 49 void OpenDevToolsWindow(WebContents* wc); |
| 50 | 50 |
| 51 // Starts element inspection in the devtools client. | 51 // Starts element inspection in the devtools client. |
| 52 // Creates one by means of OpenDevToolsWindow if no client | 52 // Creates one by means of OpenDevToolsWindow if no client |
| 53 // exists. | 53 // exists. |
| 54 void InspectElement(WebContents* web_contents, int x, int y); | 54 void InspectElement(WebContents* web_contents, int x, int y); |
| 55 | 55 |
| 56 private: | 56 // Sends 'Attach' message to the agent using |target_host| in case |
| 57 // there is a DevToolsClientHost registered for the |web_contents|. |
| 58 void SendAttachToAgent( |
| 59 const WebContents& web_contents, |
| 60 RenderViewHost* target_host); |
| 61 |
| 62 private: |
| 57 // NotificationObserver override. | 63 // NotificationObserver override. |
| 58 virtual void Observe(NotificationType type, | 64 virtual void Observe(NotificationType type, |
| 59 const NotificationSource& source, | 65 const NotificationSource& source, |
| 60 const NotificationDetails& details); | 66 const NotificationDetails& details); |
| 61 | 67 |
| 62 // DevToolsClientHost::CloseListener override. | 68 // DevToolsClientHost::CloseListener override. |
| 63 // This method will remove all references from the manager to the | 69 // This method will remove all references from the manager to the |
| 64 // DevToolsClientHost and unregister all listeners related to the | 70 // DevToolsClientHost and unregister all listeners related to the |
| 65 // DevToolsClientHost. | 71 // DevToolsClientHost. |
| 66 virtual void ClientHostClosing(DevToolsClientHost* host); | 72 virtual void ClientHostClosing(DevToolsClientHost* host); |
| 67 | 73 |
| 68 // Returns NavigationController for the tab that is inspected by devtools | 74 // Returns NavigationController for the tab that is inspected by devtools |
| 69 // client hosted by DevToolsClientHost. | 75 // client hosted by DevToolsClientHost. |
| 70 NavigationController* GetDevToolsAgentNavigationController( | 76 NavigationController* GetDevToolsAgentNavigationController( |
| 71 const DevToolsClientHost& client_host); | 77 const DevToolsClientHost& client_host); |
| 72 | 78 |
| 73 void UnregisterDevToolsClientHost( | 79 void UnregisterDevToolsClientHost( |
| 74 DevToolsClientHost* client_host, | 80 DevToolsClientHost* client_host, |
| 75 NavigationController* navigation_controller); | 81 NavigationController* navigation_controller); |
| 76 void StartListening(NavigationController* navigation_controller); | 82 void StartListening(NavigationController* navigation_controller); |
| 77 void StopListening(NavigationController* navigation_controller); | 83 void StopListening(NavigationController* navigation_controller); |
| 78 void SendAttachToAgent(const WebContents& web_contents); | |
| 79 void SendDetachToAgent(const WebContents& web_contents); | 84 void SendDetachToAgent(const WebContents& web_contents); |
| 80 | 85 |
| 81 // This object is not NULL iff there is at least one registered | 86 // This object is not NULL iff there is at least one registered |
| 82 // DevToolsClientHost. | 87 // DevToolsClientHost. |
| 83 scoped_ptr<NotificationRegistrar> web_contents_listeners_; | 88 scoped_ptr<NotificationRegistrar> web_contents_listeners_; |
| 84 | 89 |
| 85 // These two maps are for tracking dependencies between inspected tabs and | 90 // These two maps are for tracking dependencies between inspected tabs and |
| 86 // their DevToolsClientHosts. They are usful for routing devtools messages | 91 // their DevToolsClientHosts. They are usful for routing devtools messages |
| 87 // and allow us to have at most one devtools client host per tab. We use | 92 // and allow us to have at most one devtools client host per tab. We use |
| 88 // NavigationController* as key because it survives crosee-site navigation in | 93 // NavigationController* as key because it survives crosee-site navigation in |
| 89 // cases when tab contents may change. | 94 // cases when tab contents may change. |
| 90 // | 95 // |
| 91 // DevToolsManager start listening to DevToolsClientHosts when they are put | 96 // DevToolsManager start listening to DevToolsClientHosts when they are put |
| 92 // into these maps and removes them when they are closing. | 97 // into these maps and removes them when they are closing. |
| 93 typedef std::map<const NavigationController*, | 98 typedef std::map<const NavigationController*, |
| 94 DevToolsClientHost*> ClientHostMap; | 99 DevToolsClientHost*> ClientHostMap; |
| 95 ClientHostMap navcontroller_to_client_host_; | 100 ClientHostMap navcontroller_to_client_host_; |
| 96 | 101 |
| 97 typedef std::map<const DevToolsClientHost*, | 102 typedef std::map<const DevToolsClientHost*, |
| 98 NavigationController*> NavControllerMap; | 103 NavigationController*> NavControllerMap; |
| 99 NavControllerMap client_host_to_navcontroller_; | 104 NavControllerMap client_host_to_navcontroller_; |
| 100 | 105 |
| 101 DISALLOW_COPY_AND_ASSIGN(DevToolsManager); | 106 DISALLOW_COPY_AND_ASSIGN(DevToolsManager); |
| 102 }; | 107 }; |
| 103 | 108 |
| 104 #endif // CHROME_BROWSER_DEBUGGER_DEVTOOLS_MANAGER_H_ | 109 #endif // CHROME_BROWSER_DEBUGGER_DEVTOOLS_MANAGER_H_ |
| OLD | NEW |