~ubuntu-branches/ubuntu/natty/miro/natty

« back to all changes in this revision

Viewing changes to windows/plat/frontends/widgets/XULRunnerBrowser/MiroBrowserEmbed.h

  • Committer: Bazaar Package Importer
  • Author(s): Bryce Harrington
  • Date: 2011-01-22 02:46:33 UTC
  • mfrom: (1.4.10 upstream) (1.7.5 experimental)
  • Revision ID: james.westby@ubuntu.com-20110122024633-kjme8u93y2il5nmf
Tags: 3.5.1-1ubuntu1
* Merge from debian.  Remaining ubuntu changes:
  - Use python 2.7 instead of python 2.6
  - Relax dependency on python-dbus to >= 0.83.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Miro - an RSS based video player application
 
3
 * Copyright (C) 2005-2010 Participatory Culture Foundation
 
4
 *
 
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.
 
9
 *
 
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.
 
14
 *
 
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
 
18
 *
 
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
 
21
 * library.
 
22
 *
 
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.
 
29
**/
 
30
 
 
31
/*
 
32
 * MiroBrowserEmbed.h
 
33
 *
 
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.
 
38
 */
 
39
 
 
40
#ifndef __PCF_MIRO_BROWSER_EMBED_H__
 
41
#define __PCF_MIRO_BROWSER_EMBED_H__
 
42
 
 
43
#include "nsCOMPtr.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"
 
56
 
 
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);
 
60
 
 
61
class MiroBrowserEmbed   : public nsIWebBrowserChrome,
 
62
                           public nsIWebBrowserChromeFocus,
 
63
                           public nsIEmbeddingSiteWindow,
 
64
                           public nsIInterfaceRequestor,
 
65
                           public nsIURIContentListener,
 
66
                           public nsIWebProgressListener,
 
67
                           public nsSupportsWeakReference
 
68
 
 
69
{
 
70
public:
 
71
    MiroBrowserEmbed();
 
72
    virtual ~MiroBrowserEmbed();
 
73
 
 
74
    /*
 
75
     * Methods from the XPCOM interfaces we implement.  These are proiveded
 
76
     * for XULRunner.
 
77
     */
 
78
 
 
79
    NS_DECL_ISUPPORTS
 
80
    NS_DECL_NSIWEBBROWSERCHROME
 
81
    NS_DECL_NSIEMBEDDINGSITEWINDOW
 
82
    NS_DECL_NSIINTERFACEREQUESTOR
 
83
    NS_DECL_NSIWEBBROWSERCHROMEFOCUS
 
84
    NS_DECL_NSIURICONTENTLISTENER
 
85
    NS_DECL_NSIWEBPROGRESSLISTENER
 
86
 
 
87
    /*
 
88
     * Methods to interact with the MiroBrowserEmbed from Cython.  These are
 
89
     * called by Miro.
 
90
     */
 
91
 
 
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, 
 
95
            int height);
 
96
    // Stop the browser from painting to the screen or handling input
 
97
    nsresult disable();
 
98
    // Startup the browser again after a call to disable()
 
99
    nsresult enable();
 
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
 
106
    // bytes)
 
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
 
111
    nsresult focus();
 
112
    // Browser Navigation buttons.  Their functionality corresponds to the
 
113
    // nsIWebNavigation interface
 
114
    int canGoBack();
 
115
    int canGoForward();
 
116
    void goBack();
 
117
    void goForward();
 
118
    void stop();
 
119
    void reload();
 
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
 
122
    // focus.
 
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
 
132
    void destroy();
 
133
 
 
134
protected:
 
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;
 
144
 
 
145
    nsCOMPtr<nsIWebBrowser> mWebBrowser;
 
146
    nsCOMPtr<nsIWebNavigation> mWebNavigation;
 
147
    nsCOMPtr<nsIURIContentListener> mParentContentListener;
 
148
    PRBool is_enabled();
 
149
};
 
150
 
 
151
/* Couple of utility functions, since the XPCOM Macros don't seem to work from
 
152
 * Cython.
 
153
 */
 
154
void addref(MiroBrowserEmbed* browser);
 
155
void release(MiroBrowserEmbed* browser);
 
156
 
 
157
#endif /* __PCF_MIRO_BROWSER_EMBED_H__ */