1// Copyright (c) 2011 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_SYNC_JS_FRONTEND_H_ 6#define CHROME_BROWSER_SYNC_JS_FRONTEND_H_ 7#pragma once 8 9// See README.js for design comments. 10 11#include <string> 12 13namespace browser_sync { 14 15class JsArgList; 16class JsEventHandler; 17 18// An interface for objects that interact directly with 19// JsEventHandlers. 20class JsFrontend { 21 public: 22 // Adds a handler which will start receiving JS events (not 23 // immediately, so this can be called in the handler's constructor). 24 // A handler must be added at most once. 25 virtual void AddHandler(JsEventHandler* handler) = 0; 26 27 // Removes the given handler if it has been added. It will 28 // immediately stop receiving any JS events. 29 virtual void RemoveHandler(JsEventHandler* handler) = 0; 30 31 // Sends a JS message. The reply (if any) will be sent to |sender| 32 // if it has been added. 33 virtual void ProcessMessage( 34 const std::string& name, const JsArgList& args, 35 const JsEventHandler* sender) = 0; 36 37 protected: 38 virtual ~JsFrontend() {} 39}; 40 41} // namespace browser_sync 42 43#endif // CHROME_BROWSER_SYNC_JS_FRONTEND_H_ 44