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

« back to all changes in this revision

Viewing changes to platform/windows-xul/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
105
 
    nsresult getCurrentTitle(wchar_t ** aTitle);
106
 
    // Call when the parent window changes size
107
 
    nsresult resize(int x, int y, int width, int height);
108
 
    // Give the browser keyboard focus
109
 
    nsresult focus();
110
 
    // Browser Navigation buttons.  Their functionality corresponds to the
111
 
    // nsIWebNavigation interface
112
 
    int canGoBack();
113
 
    int canGoForward();
114
 
    void goBack();
115
 
    void goForward();
116
 
    void stop();
117
 
    void reload();
118
 
    // Set the focus callback.  This will be called when the user tabs through
119
 
    // all the elements in the browser and the next Widget should be given
120
 
    // focus.
121
 
    void SetFocusCallback(focusCallback callback, void* data);
122
 
    // Set the URI callback.  This well be called when we are about to load a
123
 
    // new URI.  It should return 0 if the URI shouldn't be loaded.
124
 
    void SetURICallback(uriCallback callback, void* data);
125
 
    // Set the Network callback.  This is called when we start loading a
126
 
    // document and when all network activity for a document is finished
127
 
    // new URI.  It should return 0 if the URI shouldn't be loaded.
128
 
    void SetNetworkCallback(networkCallback callback, void* data);
129
 
    // Destroy the broswer
130
 
    void destroy();
131
 
 
132
 
protected:
133
 
    nativeWindow mWindow;
134
 
    PRUint32     mChromeFlags;
135
 
    PRBool       mContinueModalLoop;
136
 
    focusCallback mFocusCallback;
137
 
    uriCallback mURICallback;
138
 
    networkCallback mNetworkCallback;
139
 
    void* mFocusCallbackData;
140
 
    void* mURICallbackData;
141
 
    void* mNetworkCallbackData;
142
 
 
143
 
    nsCOMPtr<nsIWebBrowser> mWebBrowser;
144
 
    nsCOMPtr<nsIWebNavigation> mWebNavigation;
145
 
    nsCOMPtr<nsIURIContentListener> mParentContentListener;
146
 
    PRBool is_enabled();
147
 
};
148
 
 
149
 
/* Couple of utility functions, since the XPCOM Macros don't seem to work from
150
 
 * Cython.
151
 
 */
152
 
void addref(MiroBrowserEmbed* browser);
153
 
void release(MiroBrowserEmbed* browser);
154
 
 
155
 
#endif /* __PCF_MIRO_BROWSER_EMBED_H__ */