summaryrefslogtreecommitdiffstats
path: root/content/browser/debugger/devtools_client_host.h
blob: f62996717341a49b4c0e4c796dc97d33e7c3035d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CONTENT_BROWSER_DEBUGGER_DEVTOOLS_CLIENT_HOST_H_
#define CONTENT_BROWSER_DEBUGGER_DEVTOOLS_CLIENT_HOST_H_
#pragma once

#include <string>
#include <vector>

#include "base/basictypes.h"

namespace IPC {
class Message;
}

class RenderViewHost;
class TabContents;

// Describes interface for managing devtools clients from browser process. There
// are currently two types of clients: devtools windows and TCP socket
// debuggers.
class DevToolsClientHost {
 public:
  class CloseListener {
   public:
    CloseListener() {}
    virtual ~CloseListener() {}
    virtual void ClientHostClosing(DevToolsClientHost* host) = 0;
   private:
    DISALLOW_COPY_AND_ASSIGN(CloseListener);
  };

  static DevToolsClientHost* FindOwnerClientHost(RenderViewHost* client_rvh);

  virtual ~DevToolsClientHost();

  // This method is called when tab inspected by this devtools client is
  // closing.
  virtual void InspectedTabClosing() = 0;

  // This method is called when tab inspected by this devtools client is
  // navigating to |url|.
  virtual void FrameNavigating(const std::string& url) = 0;

  // Sends the message to the devtools client hosted by this object.
  virtual void SendMessageToClient(const IPC::Message& msg) = 0;

  void set_close_listener(CloseListener* listener) {
    close_listener_ = listener;
  }

  // Invoked when a tab is replaced by another tab. This is triggered by
  // TabStripModel::ReplaceTabContentsAt.
  virtual void TabReplaced(TabContents* new_tab) = 0;

  // Returns client (front-end) RenderViewHost implementation of this
  // client host if applicable. NULL otherwise.
  virtual RenderViewHost* GetClientRenderViewHost();

 protected:
  DevToolsClientHost();

  // Should be called when the devtools client is going to die and this
  // DevToolsClientHost should not be used anymore.
  void NotifyCloseListener();

 private:
  CloseListener* close_listener_;
  typedef std::vector<DevToolsClientHost*> DevToolsClientHostList;
  static DevToolsClientHostList instances_;
  DISALLOW_COPY_AND_ASSIGN(DevToolsClientHost);
};

#endif  // CONTENT_BROWSER_DEBUGGER_DEVTOOLS_CLIENT_HOST_H_