FireBreath  1.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Pages
ScriptingCore/DOM/Window.h
1 /**********************************************************\
2 Original Author: Richard Bateman (taxilian)
3 
4 Created: Dec 9, 2009
5 License: Dual license model; choose one of two:
6  New BSD License
7  http://www.opensource.org/licenses/bsd-license.php
8  - or -
9  GNU Lesser General Public License, version 2.1
10  http://www.gnu.org/licenses/lgpl-2.1.html
11 
12 Copyright 2010 Facebook, Inc and the Firebreath development team
13 \**********************************************************/
14 
15 #pragma once
16 #ifndef H_FB_DOM_WINDOW
17 #define H_FB_DOM_WINDOW
18 
19 #include <string>
20 #include <boost/shared_ptr.hpp>
21 #include "Node.h"
22 #include "Document.h"
23 
24 namespace FB {
25  namespace DOM {
26 
27  class JSObject;
33  class Window;
34 
40  typedef boost::shared_ptr<Window> WindowPtr;
41 
51  class Window : public virtual Node
52  {
53  public:
54 
66  Window(const JSObjectPtr& element);
67 
73  virtual ~Window();
74 
82  WindowPtr window() { return boost::dynamic_pointer_cast<Window>(node()); }
83 
95  static WindowPtr create(const FB::JSObjectPtr &api) {
96  if (!api) { return WindowPtr(); }
97  return api->getHost()->_createWindow(api);
98  }
99 
100  public:
101 
109  virtual DocumentPtr getDocument() const;
110 
118  virtual void alert(const std::string& str) const;
122  virtual void alert(const std::wstring& str) const;
123 
131  virtual FB::JSObjectPtr createArray() const;
132 
140  virtual FB::JSObjectPtr createMap() const;
141 
149 // virtual FB::JSObjectPtr createDate(const std::string& datestring) const;
150 
159  virtual std::string getLocation() const;
160  };
161 
162 } };
163 
164 #endif // H_FB_DOM_WINDOW
165 
DOM Node wrapper.
boost::shared_ptr< FB::JSObject > JSObjectPtr
Defines an alias representing a JSObject shared_ptr (you should never use a JSObject* directly) ...
Definition: APITypes.h:109
Window(const JSObjectPtr &element)
Constructor. DO NOT USE.
WindowPtr window()
Gets the shared_ptr for the window (FB::DOM::WindowPtr)
virtual FB::JSObjectPtr createMap() const
Creates a javascript object and returns it.
boost::shared_ptr< Window > WindowPtr
shared_ptr for a FB::DOM::Window
boost::shared_ptr< Document > DocumentPtr
shared_ptr for a FB::DOM::Document
virtual DocumentPtr getDocument() const
Gets the DOM Document contained in this window.
DOM Window abstraction for manipulating and accessing the javascript window object that the plugin is...
static WindowPtr create(const FB::JSObjectPtr &api)
Creates a FB::DOM::Window object from a JSObjectPtr representing a DOM object. This will probably thr...
virtual std::string getLocation() const
Returns window.location for the containing page.
virtual void alert(const std::string &str) const
Pop up a JS alert box.
virtual FB::JSObjectPtr createArray() const
Creates a javascript array object and returns it.
NodePtr node()
Gets the NodePtr for the current node.
virtual ~Window()
Finaliser.