2
* Miro - an RSS based video player application
3
* Copyright (C) 2005-2010 Participatory Culture Foundation
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2 of the License, or
8
* (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19
* In addition, as a special exception, the copyright holders give
20
* permission to link the code of portions of this program with the OpenSSL
23
* You must obey the GNU General Public License in all respects for all of
24
* the code used other than OpenSSL. If you modify file(s) with this
25
* exception, you may extend this exception to your version of the file(s),
26
* but you are not obligated to do so. If you do not wish to do so, delete
27
* this exception statement from your version. If you delete this exception
28
* statement from all source files in the program, then also delete it here.
34
* Public interface for our embedded xulrunner browser. MiroBrowserEmbed
35
* serves 2 functions. It provides an XPCOM interface for XULRunner to hook
36
* up to. It also provides a C++ interface that the .pyx file uses to
37
* controll the browser and to hook up callbacks to it.
40
#ifndef __PCF_MIRO_BROWSER_EMBED_H__
41
#define __PCF_MIRO_BROWSER_EMBED_H__
44
#include "nsIWebBrowserChrome.h"
45
#include "nsIEmbeddingSiteWindow.h"
46
#include "nsIWebBrowser.h"
47
#include "nsIInterfaceRequestor.h"
48
#include "nsIWebBrowserChromeFocus.h"
49
#include "docshell/nsIWebNavigation.h"
50
#include "widget/nsIBaseWindow.h"
51
#include "uriloader/nsIURIContentListener.h"
52
#include "uriloader/nsIWebProgressListener.h"
53
#include "xpcom/nsWeakReference.h"
54
#include "shistory/nsIHistoryEntry.h"
55
#include "shistory/nsISHistory.h"
57
typedef void(*focusCallback)(PRBool forward, void* data);
58
typedef int(*uriCallback)(char* uri, void* data);
59
typedef void(*networkCallback)(PRBool is_start, void* data);
61
class MiroBrowserEmbed : public nsIWebBrowserChrome,
62
public nsIWebBrowserChromeFocus,
63
public nsIEmbeddingSiteWindow,
64
public nsIInterfaceRequestor,
65
public nsIURIContentListener,
66
public nsIWebProgressListener,
67
public nsSupportsWeakReference
72
virtual ~MiroBrowserEmbed();
75
* Methods from the XPCOM interfaces we implement. These are proiveded
80
NS_DECL_NSIWEBBROWSERCHROME
81
NS_DECL_NSIEMBEDDINGSITEWINDOW
82
NS_DECL_NSIINTERFACEREQUESTOR
83
NS_DECL_NSIWEBBROWSERCHROMEFOCUS
84
NS_DECL_NSIURICONTENTLISTENER
85
NS_DECL_NSIWEBPROGRESSLISTENER
88
* Methods to interact with the MiroBrowserEmbed from Cython. These are
92
// Create a WebBrowser object and place it inside parentWindow. This must
93
// be called before any other methods.
94
nsresult init(unsigned long parentWindow, int x, int y, int width,
96
// Stop the browser from painting to the screen or handling input
98
// Startup the browser again after a call to disable()
100
// Load a URI into the browser
101
nsresult loadURI(const char* uri);
102
// Gets the current uri from mWebNavigator
103
nsresult getCurrentURI(char ** uri);
104
// Gets the current title from a long chain of things. aTitle is a utf-16
105
// encoding string. length inputs the length of the string (in
107
nsresult getCurrentTitle(char ** aTitle, int* length);
108
// Call when the parent window changes size
109
nsresult resize(int x, int y, int width, int height);
110
// Give the browser keyboard focus
112
// Browser Navigation buttons. Their functionality corresponds to the
113
// nsIWebNavigation interface
120
// Set the focus callback. This will be called when the user tabs through
121
// all the elements in the browser and the next Widget should be given
123
void SetFocusCallback(focusCallback callback, void* data);
124
// Set the URI callback. This well be called when we are about to load a
125
// new URI. It should return 0 if the URI shouldn't be loaded.
126
void SetURICallback(uriCallback callback, void* data);
127
// Set the Network callback. This is called when we start loading a
128
// document and when all network activity for a document is finished
129
// new URI. It should return 0 if the URI shouldn't be loaded.
130
void SetNetworkCallback(networkCallback callback, void* data);
131
// Destroy the broswer
135
nativeWindow mWindow;
136
PRUint32 mChromeFlags;
137
PRBool mContinueModalLoop;
138
focusCallback mFocusCallback;
139
uriCallback mURICallback;
140
networkCallback mNetworkCallback;
141
void* mFocusCallbackData;
142
void* mURICallbackData;
143
void* mNetworkCallbackData;
145
nsCOMPtr<nsIWebBrowser> mWebBrowser;
146
nsCOMPtr<nsIWebNavigation> mWebNavigation;
147
nsCOMPtr<nsIURIContentListener> mParentContentListener;
151
/* Couple of utility functions, since the XPCOM Macros don't seem to work from
154
void addref(MiroBrowserEmbed* browser);
155
void release(MiroBrowserEmbed* browser);
157
#endif /* __PCF_MIRO_BROWSER_EMBED_H__ */