Browse Source

Added a method BrowserPluginComponent::getBrowserURL() so that plugins can find out what URL they are embedded in

tags/2021-05-28
jules 16 years ago
parent
commit
5df4ac7dec
3 changed files with 1332 additions and 1242 deletions
  1. +37
    -2
      extras/browser plugins/wrapper/juce_ActiveX_GlueCode.cpp
  2. +93
    -89
      extras/browser plugins/wrapper/juce_BrowserPluginComponent.h
  3. +1202
    -1151
      extras/browser plugins/wrapper/juce_NPAPI_GlueCode.cpp

+ 37
- 2
extras/browser plugins/wrapper/juce_ActiveX_GlueCode.cpp View File

@@ -43,6 +43,7 @@
#include <windowsx.h>
#include <olectl.h>
#include <objsafe.h>
#include <exdisp.h>
#pragma warning (disable:4584)
#include "../../../juce_amalgamated.h"
@@ -458,7 +459,8 @@ public:
//==============================================================================
AXBrowserPluginHolderComponent()
: child (0),
parentHWND (0)
parentHWND (0),
browser (0)
{
setOpaque (true);
setWantsKeyboardFocus (false);
@@ -490,12 +492,28 @@ public:
void setWindow (IOleInPlaceSite* site)
{
if (browser != 0)
{
browser->Release();
browser = 0;
}
HWND newHWND = 0;
if (site != 0)
{
site->GetWindow (&newHWND);
//log ("setWindow: " + String ((int) newHWND));
IServiceProvider* sp = 0;
site->QueryInterface (IID_IServiceProvider, (void**) &sp);
if (sp != 0)
{
sp->QueryService (IID_IWebBrowserApp, IID_IWebBrowser2, (void**) &browser);
sp->Release();
}
}
if (parentHWND != newHWND)
{
removeFromDesktop();
@@ -521,10 +539,21 @@ public:
site->OnInPlaceActivate();
}
const String getBrowserURL() const
{
if (browser == 0)
return String::empty;
BSTR url = 0;
browser->get_LocationURL (&url);
return URL::removeEscapeChars (url);
}
private:
//==============================================================================
BrowserPluginComponent* child;
HWND parentHWND;
IWebBrowser2* browser;
};
//==============================================================================
@@ -759,6 +788,12 @@ static const String getExeVersion (const String& exeFileName, const String& fiel
return resultString;
}
const String getActiveXBrowserURL (const BrowserPluginComponent* comp)
{
AXBrowserPluginHolderComponent* const ax = dynamic_cast <AXBrowserPluginHolderComponent*> (comp->getParentComponent());
return ax != 0 ? ax->getBrowserURL() : String::empty;
}
//==============================================================================
extern "C" BOOL WINAPI DllMain (HANDLE instance, DWORD reason, LPVOID)
{


+ 93
- 89
extras/browser plugins/wrapper/juce_BrowserPluginComponent.h View File

@@ -1,89 +1,93 @@
/*
==============================================================================

This file is part of the JUCE library - "Jules' Utility Class Extensions"
Copyright 2004-7 by Raw Material Software ltd.

------------------------------------------------------------------------------

JUCE can be redistributed and/or modified under the terms of the
GNU General Public License, as published by the Free Software Foundation;
either version 2 of the License, or (at your option) any later version.

JUCE is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with JUCE; if not, visit www.gnu.org/licenses or write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
Boston, MA 02111-1307 USA

------------------------------------------------------------------------------

If you'd like to release a closed-source product which uses JUCE, commercial
licenses are also available: visit www.rawmaterialsoftware.com/juce for
more information.

==============================================================================
*/

#ifndef __JUCE_BROWSERPLUGINCOMP_H__
#define __JUCE_BROWSERPLUGINCOMP_H__

#include "../../../../juce/juce_amalgamated.h"


//==============================================================================
/**
Base class for a browser plugin object.
You need to implement a createBrowserPlugin() function that the host will call
when it needs a new instance of your BrowserPluginComponent subclass. The host will
delete the BrowserPluginComponent later when the user navigates away from the
page.
*/
class BrowserPluginComponent : public Component
{
public:
//==============================================================================
/**
Creates a browser plugin object.
@see createBrowserPlugin
*/
BrowserPluginComponent();
/** Destructor. */
~BrowserPluginComponent();

//==============================================================================
/** Returns a string describing the host browser version.
*/
const String getBrowserVersion() const;

/** The plugin must implement this method to return a variant object whose
properties and methods can be accessed by javascript in the browser.
If your plugin doesn't need to represent itself, you can just return
a void var() object here.
*/
virtual const var getJavascriptObject() = 0;

//==============================================================================
juce_UseDebuggingNewOperator
};


//==============================================================================
/**
This function must be implemented somewhere in your code to create the actual
plugin object that you want to use.

Obviously multiple instances may be used simultaneously, so be VERY cautious
in your use of static variables!
*/
BrowserPluginComponent* JUCE_CALLTYPE createBrowserPlugin();


#endif
/*
==============================================================================
This file is part of the JUCE library - "Jules' Utility Class Extensions"
Copyright 2004-7 by Raw Material Software ltd.
------------------------------------------------------------------------------
JUCE can be redistributed and/or modified under the terms of the
GNU General Public License, as published by the Free Software Foundation;
either version 2 of the License, or (at your option) any later version.
JUCE is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with JUCE; if not, visit www.gnu.org/licenses or write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
Boston, MA 02111-1307 USA
------------------------------------------------------------------------------
If you'd like to release a closed-source product which uses JUCE, commercial
licenses are also available: visit www.rawmaterialsoftware.com/juce for
more information.
==============================================================================
*/
#ifndef __JUCE_BROWSERPLUGINCOMP_H__
#define __JUCE_BROWSERPLUGINCOMP_H__
#include "../../../../juce/juce_amalgamated.h"
//==============================================================================
/**
Base class for a browser plugin object.
You need to implement a createBrowserPlugin() function that the host will call
when it needs a new instance of your BrowserPluginComponent subclass. The host will
delete the BrowserPluginComponent later when the user navigates away from the
page.
*/
class BrowserPluginComponent : public Component
{
public:
//==============================================================================
/**
Creates a browser plugin object.
@see createBrowserPlugin
*/
BrowserPluginComponent();
/** Destructor. */
~BrowserPluginComponent();
//==============================================================================
/** Returns a string describing the host browser version.
*/
const String getBrowserVersion() const;
/** Returns the URL that the browser is currently showing.
*/
const String getBrowserURL() const;
/** The plugin must implement this method to return a variant object whose
properties and methods can be accessed by javascript in the browser.
If your plugin doesn't need to represent itself, you can just return
a void var() object here.
*/
virtual const var getJavascriptObject() = 0;
//==============================================================================
juce_UseDebuggingNewOperator
};
//==============================================================================
/**
This function must be implemented somewhere in your code to create the actual
plugin object that you want to use.
Obviously multiple instances may be used simultaneously, so be VERY cautious
in your use of static variables!
*/
BrowserPluginComponent* JUCE_CALLTYPE createBrowserPlugin();
#endif

+ 1202
- 1151
extras/browser plugins/wrapper/juce_NPAPI_GlueCode.cpp
File diff suppressed because it is too large
View File


Loading…
Cancel
Save