summaryrefslogtreecommitdiffstats
path: root/chrome/renderer/extensions/chrome_v8_extension_handler.h
blob: 301b9f623fbe915aef62f9372fe557b625d4d3ff (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
// 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.

#ifndef CHROME_RENDERER_EXTENSIONS_CHROME_V8_EXTENSION_HANDLER_H_
#define CHROME_RENDERER_EXTENSIONS_CHROME_V8_EXTENSION_HANDLER_H_
#pragma once

#include <string>

#include "base/basictypes.h"
#include "ipc/ipc_channel.h"
#include "v8/include/v8.h"

class ChromeV8Context;

// Base class for context-scoped handlers used with ChromeV8Extension.
// TODO(koz): Rename/refactor this somehow. Maybe just pull it into
// ChromeV8Extension.
class ChromeV8ExtensionHandler : public IPC::Channel::Listener {
 public:
  virtual ~ChromeV8ExtensionHandler();

  // IPC::Channel::Listener
  virtual bool OnMessageReceived(const IPC::Message& message) = 0;

 protected:
  explicit ChromeV8ExtensionHandler(ChromeV8Context* context);
  int GetRoutingID();
  void Send(IPC::Message* message);
  ChromeV8Context* context_;

 private:
  int routing_id_;
  DISALLOW_COPY_AND_ASSIGN(ChromeV8ExtensionHandler);
};

#endif  // CHROME_RENDERER_EXTENSIONS_CHROME_V8_EXTENSION_HANDLER_H_