summaryrefslogtreecommitdiffstats
path: root/chrome/renderer/external_js_object.h
blob: 738aa7c2c187db6c5f764077ed953c2b48a3661f (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
// Copyright (c) 2006-2008 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.

/*
  ExternalJSObject class:
  Bound to a JavaScript window.external object using
  CppBoundClass::BindToJavascript(), this adds methods accessible from JS for
  compatibility with other browsers.
*/

#ifndef CHROME_RENDERER_EXTERNAL_JS_OBJECT_H__
#define CHROME_RENDERER_EXTERNAL_JS_OBJECT_H__

#include "base/basictypes.h"
#include "webkit/glue/cpp_bound_class.h"

class RenderView;

class ExternalJSObject : public CppBoundClass {
 public:
  // Builds the property and method lists needed to bind this class to a JS
  // object.
  ExternalJSObject();

  // A RenderView must be set before AddSearchProvider is called, or the call
  // will do nothing.
  void set_render_view(RenderView* rv) { render_view_ = rv; }

  // Given a URL to an OpenSearch document in the first argument, adds the
  // corresponding search provider as a keyword search.  The nonstandard
  // capitalization is for compatibility with Firefox and IE.
  void AddSearchProvider(const CppArgumentList& args, CppVariant* result);

 private:
  RenderView* render_view_;

  DISALLOW_EVIL_CONSTRUCTORS(ExternalJSObject);
};

#endif  // CHROME_RENDERER_EXTERNAL_JS_OBJECT_H__