Home | History | Annotate | Download | only in sync
      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_EVENT_ROUTER_H_
      6 #define CHROME_BROWSER_SYNC_JS_EVENT_ROUTER_H_
      7 #pragma once
      8 
      9 // See README.js for design comments.
     10 
     11 #include <string>
     12 
     13 namespace browser_sync {
     14 
     15 class JsArgList;
     16 class JsEventHandler;
     17 
     18 // An interface for objects that don't directly handle Javascript
     19 // events but can pass them to JsEventHandlers or route them to other
     20 // JsEventRouters.
     21 class JsEventRouter {
     22  public:
     23   // If |target| is NULL that means the event is intended for every
     24   // handler.  Otherwise the event is meant for the given target only.
     25   // |target| is const because it shouldn't be used except by the
     26   // router that directly knows about it (which can then safely cast
     27   // away the constness).
     28   virtual void RouteJsEvent(const std::string& name, const JsArgList& args,
     29                             const JsEventHandler* target) = 0;
     30 
     31  protected:
     32   virtual ~JsEventRouter() {}
     33 };
     34 
     35 }  // namespace browser_sync
     36 
     37 #endif  // CHROME_BROWSER_SYNC_JS_EVENT_ROUTER_H_
     38