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 3 // found in the LICENSE file. 4 5 #ifndef CHROME_BROWSER_DEBUGGER_DEVTOOLS_CLIENT_HOST_H_ 6 #define CHROME_BROWSER_DEBUGGER_DEVTOOLS_CLIENT_HOST_H_ 7 #pragma once 8 9 #include <string> 10 11 #include "base/basictypes.h" 12 13 namespace IPC { 14 class Message; 15 } 16 17 class DevToolsWindow; 18 class TabContentsWrapper; 19 20 // Describes interface for managing devtools clients from browser process. There 21 // are currently two types of clients: devtools windows and TCP socket 22 // debuggers. 23 class DevToolsClientHost { 24 public: 25 class CloseListener { 26 public: 27 CloseListener() {} 28 virtual ~CloseListener() {} 29 virtual void ClientHostClosing(DevToolsClientHost* host) = 0; 30 private: 31 DISALLOW_COPY_AND_ASSIGN(CloseListener); 32 }; 33 34 virtual ~DevToolsClientHost() {} 35 36 // This method is called when tab inspected by this devtools client is 37 // closing. 38 virtual void InspectedTabClosing() = 0; 39 40 // This method is called when tab inspected by this devtools client is 41 // navigating to |url|. 42 virtual void FrameNavigating(const std::string& url) = 0; 43 44 // Sends the message to the devtools client hosted by this object. 45 virtual void SendMessageToClient(const IPC::Message& msg) = 0; 46 47 void set_close_listener(CloseListener* listener) { 48 close_listener_ = listener; 49 } 50 51 virtual DevToolsWindow* AsDevToolsWindow(); 52 53 // Invoked when a tab is replaced by another tab. This is triggered by 54 // TabStripModel::ReplaceTabContentsAt. 55 virtual void TabReplaced(TabContentsWrapper* new_tab) = 0; 56 57 protected: 58 DevToolsClientHost() : close_listener_(NULL) {} 59 60 // Should be called when the devtools client is going to die and this 61 // DevToolsClientHost should not be used anymore. 62 void NotifyCloseListener(); 63 64 private: 65 CloseListener* close_listener_; 66 DISALLOW_COPY_AND_ASSIGN(DevToolsClientHost); 67 }; 68 69 #endif // CHROME_BROWSER_DEBUGGER_DEVTOOLS_CLIENT_HOST_H_ 70