summaryrefslogtreecommitdiffstats
path: root/content/browser/devtools/devtools_agent_host_impl.cc
blob: 8b348d6d13486616f3ae0cc8cd9361f2c55988b1 (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
// Copyright (c) 2012 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.

#include "content/browser/devtools/devtools_agent_host_impl.h"

#include "base/basictypes.h"
#include "content/common/devtools_messages.h"

namespace content {

namespace {
static int g_next_agent_host_id = 0;
}  // namespace

DevToolsAgentHostImpl::DevToolsAgentHostImpl()
    : close_listener_(NULL),
      id_(++g_next_agent_host_id) {
}

void DevToolsAgentHostImpl::Attach() {
  SendMessageToAgent(new DevToolsAgentMsg_Attach(MSG_ROUTING_NONE));
  NotifyClientAttaching();
}

void DevToolsAgentHostImpl::Reattach(const std::string& saved_agent_state) {
  SendMessageToAgent(new DevToolsAgentMsg_Reattach(
      MSG_ROUTING_NONE,
      saved_agent_state));
  NotifyClientAttaching();
}

void DevToolsAgentHostImpl::Detach() {
  SendMessageToAgent(new DevToolsAgentMsg_Detach(MSG_ROUTING_NONE));
  NotifyClientDetaching();
}

void DevToolsAgentHostImpl::DipatchOnInspectorBackend(
    const std::string& message) {
  SendMessageToAgent(new DevToolsAgentMsg_DispatchOnInspectorBackend(
      MSG_ROUTING_NONE, message));
}

void DevToolsAgentHostImpl::InspectElement(int x, int y) {
  SendMessageToAgent(new DevToolsAgentMsg_InspectElement(MSG_ROUTING_NONE,
                                                         x, y));
}

void DevToolsAgentHostImpl::AddMessageToConsole(ConsoleMessageLevel level,
                                                const std::string& message) {
  SendMessageToAgent(new DevToolsAgentMsg_AddMessageToConsole(
      MSG_ROUTING_NONE,
      level,
      message));
}

RenderViewHost* DevToolsAgentHostImpl::GetRenderViewHost() {
  return NULL;
}

void DevToolsAgentHostImpl::NotifyCloseListener() {
  if (close_listener_) {
    scoped_refptr<DevToolsAgentHostImpl> protect(this);
    close_listener_->AgentHostClosing(this);
    close_listener_ = NULL;
  }
}

}  // namespace content