diff options
Diffstat (limited to 'WebCore/page')
-rw-r--r-- | WebCore/page/Navigator.cpp | 23 | ||||
-rw-r--r-- | WebCore/page/Navigator.h | 10 | ||||
-rw-r--r-- | WebCore/page/Page.cpp | 18 |
3 files changed, 46 insertions, 5 deletions
diff --git a/WebCore/page/Navigator.cpp b/WebCore/page/Navigator.cpp index 3c0424f..bb07911 100644 --- a/WebCore/page/Navigator.cpp +++ b/WebCore/page/Navigator.cpp @@ -45,6 +45,7 @@ #if PLATFORM(ANDROID) #include "ApplicationInstalledCallback.h" #include "Connection.h" +#include "PackageNotifier.h" #endif namespace WebCore { @@ -171,10 +172,26 @@ Connection* Navigator::connection() const #endif #if PLATFORM(ANDROID) && ENABLE(APPLICATION_INSTALLED) -void Navigator::isApplicationInstalled(const String& name, PassRefPtr<ApplicationInstalledCallback> callback) + +bool Navigator::isApplicationInstalled(const String& name, PassRefPtr<ApplicationInstalledCallback> callback) +{ + if (m_applicationInstalledCallback) + return false; + + m_applicationInstalledCallback = callback; + m_applicationNameQuery = name; + + packageNotifier().requestPackageResult(); + + return true; +} + +void Navigator::onPackageResult() { - //TODO(implement); - callback->handleEvent(false); + if (m_applicationInstalledCallback) { + m_applicationInstalledCallback->handleEvent(packageNotifier().isPackageInstalled(m_applicationNameQuery)); + m_applicationInstalledCallback = 0; + } } #endif diff --git a/WebCore/page/Navigator.h b/WebCore/page/Navigator.h index 83ed83f..c6acfd5 100644 --- a/WebCore/page/Navigator.h +++ b/WebCore/page/Navigator.h @@ -21,6 +21,7 @@ #define Navigator_h #include "NavigatorBase.h" +#include "PlatformString.h" #include <wtf/PassRefPtr.h> #include <wtf/RefCounted.h> #include <wtf/RefPtr.h> @@ -32,7 +33,6 @@ namespace WebCore { class MimeTypeArray; class PluginData; class PluginArray; - class String; #if PLATFORM(ANDROID) class ApplicationInstalledCallback; class Connection; @@ -67,7 +67,8 @@ namespace WebCore { #endif #if PLATFORM(ANDROID) && ENABLE(APPLICATION_INSTALLED) - void isApplicationInstalled(const String& name, PassRefPtr<ApplicationInstalledCallback> callback); + bool isApplicationInstalled(const String& name, PassRefPtr<ApplicationInstalledCallback> callback); + void onPackageResult(); #endif #if ENABLE(DOM_STORAGE) @@ -87,6 +88,11 @@ namespace WebCore { #if PLATFORM(ANDROID) mutable RefPtr<Connection> m_connection; #endif + +#if PLATFORM(ANDROID) && ENABLE(APPLICATION_INSTALLED) + RefPtr<ApplicationInstalledCallback> m_applicationInstalledCallback; + String m_applicationNameQuery; +#endif }; } diff --git a/WebCore/page/Page.cpp b/WebCore/page/Page.cpp index 1704bfb..b685e59 100644 --- a/WebCore/page/Page.cpp +++ b/WebCore/page/Page.cpp @@ -81,6 +81,10 @@ #include "GeolocationController.h" #endif +#if PLATFORM(ANDROID) && ENABLE(APPLICATION_INSTALLED) +#include "PackageNotifier.h" +#endif + namespace WebCore { static HashSet<Page*>* allPages; @@ -105,6 +109,17 @@ static void networkStateChanged() frames[i]->document()->dispatchWindowEvent(Event::create(eventName, false, false)); } +#if PLATFORM(ANDROID) && ENABLE(APPLICATION_INSTALLED) +static void onPackageResultAvailable() +{ + HashSet<Page*>::iterator end = allPages->end(); + for (HashSet<Page*>::iterator it = allPages->begin(); it != end; ++it) { + for (Frame* frame = (*it)->mainFrame(); frame; frame = frame->tree()->traverseNext()) + frame->domWindow()->navigator()->onPackageResult(); + } +} +#endif + Page::Page(ChromeClient* chromeClient, ContextMenuClient* contextMenuClient, EditorClient* editorClient, DragClient* dragClient, InspectorClient* inspectorClient, PluginHalterClient* pluginHalterClient, GeolocationControllerClient* geolocationControllerClient) : m_chrome(new Chrome(this, chromeClient)) , m_dragCaretController(new SelectionController(0, true)) @@ -163,6 +178,9 @@ Page::Page(ChromeClient* chromeClient, ContextMenuClient* contextMenuClient, Edi allPages = new HashSet<Page*>; networkStateNotifier().setNetworkStateChangedFunction(networkStateChanged); +#if PLATFORM(ANDROID) && ENABLE(APPLICATION_INSTALLED) + packageNotifier().setOnResultAvailable(onPackageResultAvailable); +#endif } ASSERT(!allPages->contains(this)); |