mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-03 12:35:58 +00:00
Bug 676293 - Add ability to make 'home screen shortcut' for Bookmarks [r=fabrice, r=blassey]
--HG-- rename : mobile/components/build/nsIPhoneSupport.idl => mobile/components/build/nsIShellService.idl rename : mobile/components/build/nsPhoneSupport.cpp => mobile/components/build/nsShellService.cpp rename : mobile/components/build/nsPhoneSupport.h => mobile/components/build/nsShellService.h
This commit is contained in:
parent
d52214f7a6
commit
b448cb7549
@ -70,6 +70,7 @@ abstract public class GeckoApp
|
||||
public static final String ACTION_ALERT_CLEAR = "org.mozilla.gecko.ACTION_ALERT_CLEAR";
|
||||
public static final String ACTION_WEBAPP = "org.mozilla.gecko.WEBAPP";
|
||||
public static final String ACTION_DEBUG = "org.mozilla.gecko.DEBUG";
|
||||
public static final String ACTION_BOOKMARK = "org.mozilla.gecko.BOOKMARK";
|
||||
|
||||
public static FrameLayout mainLayout;
|
||||
public static GeckoSurfaceView surfaceView;
|
||||
@ -317,20 +318,25 @@ abstract public class GeckoApp
|
||||
if (checkLaunchState(LaunchState.WaitButton) || launch(intent))
|
||||
return;
|
||||
|
||||
if (Intent.ACTION_VIEW.equals(action)) {
|
||||
if (Intent.ACTION_MAIN.equals(action)) {
|
||||
Log.i("GeckoApp", "Intent : ACTION_MAIN");
|
||||
GeckoAppShell.sendEventToGecko(new GeckoEvent(""));
|
||||
}
|
||||
else if (Intent.ACTION_VIEW.equals(action)) {
|
||||
String uri = intent.getDataString();
|
||||
GeckoAppShell.sendEventToGecko(new GeckoEvent(uri));
|
||||
Log.i("GeckoApp","onNewIntent: "+uri);
|
||||
}
|
||||
else if (Intent.ACTION_MAIN.equals(action)) {
|
||||
Log.i("GeckoApp", "Intent : ACTION_MAIN");
|
||||
GeckoAppShell.sendEventToGecko(new GeckoEvent(""));
|
||||
}
|
||||
else if (ACTION_WEBAPP.equals(action)) {
|
||||
String uri = intent.getStringExtra("args");
|
||||
GeckoAppShell.sendEventToGecko(new GeckoEvent(uri));
|
||||
Log.i("GeckoApp","Intent : WEBAPP - " + uri);
|
||||
}
|
||||
else if (ACTION_BOOKMARK.equals(action)) {
|
||||
String args = intent.getStringExtra("args");
|
||||
GeckoAppShell.sendEventToGecko(new GeckoEvent(args));
|
||||
Log.i("GeckoApp","Intent : BOOKMARK - " + args);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -682,14 +682,20 @@ public class GeckoAppShell
|
||||
}
|
||||
|
||||
// "Installs" an application by creating a shortcut
|
||||
static void installWebApplication(String aURI, String aTitle, String aIconData) {
|
||||
Log.w("GeckoAppJava", "installWebApplication for " + aURI + " [" + aTitle + "]");
|
||||
static void createShortcut(String aTitle, String aURI, String aIconData, String aType) {
|
||||
Log.w("GeckoAppJava", "createShortcut for " + aURI + " [" + aTitle + "]");
|
||||
|
||||
// the intent to be launched by the shortcut
|
||||
Intent shortcutIntent = new Intent("org.mozilla.gecko.WEBAPP");
|
||||
Intent shortcutIntent = new Intent();
|
||||
if (aType == "webapp") {
|
||||
shortcutIntent.setAction("org.mozilla.gecko.WEBAPP");
|
||||
shortcutIntent.putExtra("args", "--webapp=" + aURI);
|
||||
} else {
|
||||
shortcutIntent.setAction("org.mozilla.gecko.BOOKMARK");
|
||||
shortcutIntent.putExtra("args", "--url=" + aURI);
|
||||
}
|
||||
shortcutIntent.setClassName(GeckoApp.mAppContext,
|
||||
GeckoApp.mAppContext.getPackageName() + ".App");
|
||||
shortcutIntent.putExtra("args", "--webapp=" + aURI);
|
||||
|
||||
Intent intent = new Intent();
|
||||
intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
|
||||
|
@ -108,5 +108,31 @@ var ContextCommands = {
|
||||
removeBookmark: function cc_removeBookmark() {
|
||||
let target = ContextHelper.popupState.target;
|
||||
target.remove();
|
||||
},
|
||||
|
||||
shortcutBookmark: function cc_shortcutBookmark() {
|
||||
const kIconSize = 64;
|
||||
|
||||
let target = ContextHelper.popupState.target;
|
||||
let canvas = document.createElementNS("http://www.w3.org/1999/xhtml", "canvas");
|
||||
canvas.setAttribute("style", "display: none");
|
||||
|
||||
let self = this;
|
||||
let image = new Image();
|
||||
image.onload = function() {
|
||||
canvas.width = canvas.height = kIconSize; // clears the canvas
|
||||
let ctx = canvas.getContext("2d");
|
||||
ctx.drawImage(image, 0, 0, kIconSize, kIconSize);
|
||||
let icon = canvas.toDataURL("image/png", "");
|
||||
canvas = null;
|
||||
try {
|
||||
let shell = Cc["@mozilla.org/browser/shell-service;1"].createInstance(Ci.nsIShellService);
|
||||
shell.createShortcut(target.getAttribute("title"), target.getAttribute("uri"), icon, "bookmark");
|
||||
} catch(e) {
|
||||
Cu.reportError(e);
|
||||
}
|
||||
}
|
||||
|
||||
image.src = target.getAttribute("src");
|
||||
}
|
||||
};
|
||||
|
@ -874,8 +874,8 @@ var BrowserUI = {
|
||||
|
||||
switchTask: function switchTask() {
|
||||
try {
|
||||
let phone = Cc["@mozilla.org/phone/support;1"].createInstance(Ci.nsIPhoneSupport);
|
||||
phone.switchTask();
|
||||
let shell = Cc["@mozilla.org/browser/shell-service;1"].createInstance(Ci.nsIShellService);
|
||||
shell.switchTask();
|
||||
} catch(e) { }
|
||||
},
|
||||
|
||||
|
@ -663,6 +663,9 @@
|
||||
<label value="&contextRemoveBookmark.label;"/>
|
||||
</richlistitem>
|
||||
#ifdef ANDROID
|
||||
<richlistitem class="context-command" id="context-shortcutbookmark" type="edit-bookmark" onclick="ContextCommands.shortcutBookmark();">
|
||||
<label value="&contextShortcutBookmark.label;"/>
|
||||
</richlistitem>
|
||||
<richlistitem class="context-command" id="context-select-input" type="input-text" onclick="ContextCommands.selectInput();">
|
||||
<label value="&inputMethod.label;"/>
|
||||
</richlistitem>
|
||||
|
@ -49,6 +49,7 @@ XPIDL_MODULE = MobileComponents
|
||||
XPIDLSRCS = \
|
||||
SessionStore.idl \
|
||||
LoginManagerPrompter.idl \
|
||||
WebappsSupport.idl \
|
||||
$(NULL)
|
||||
|
||||
EXTRA_PP_COMPONENTS = \
|
||||
|
@ -59,16 +59,16 @@ REQUIRES = \
|
||||
pref \
|
||||
$(NULL)
|
||||
|
||||
XPIDL_MODULE = browsercomps
|
||||
|
||||
XPIDLSRCS = nsIShellService.idl
|
||||
|
||||
CPPSRCS = \
|
||||
nsSSLCertErrorDialog.cpp \
|
||||
nsBrowserModule.cpp \
|
||||
nsShellService.cpp \
|
||||
$(NULL)
|
||||
|
||||
ifndef ANDROID
|
||||
CPPSRCS += nsPhoneSupport.cpp
|
||||
XPIDLSRCS = nsIPhoneSupport.idl
|
||||
endif
|
||||
|
||||
ifeq ($(MOZ_PLATFORM_MAEMO),5)
|
||||
LOCAL_INCLUDES += $(MOZ_DBUS_GLIB_CFLAGS)
|
||||
endif
|
||||
|
@ -39,32 +39,23 @@
|
||||
|
||||
#include "mozilla/ModuleUtils.h"
|
||||
|
||||
#ifndef ANDROID
|
||||
#include "nsPhoneSupport.h"
|
||||
#endif
|
||||
|
||||
#include "nsShellService.h"
|
||||
#include "nsSSLCertErrorDialog.h"
|
||||
|
||||
#ifndef ANDROID
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsPhoneSupport)
|
||||
NS_DEFINE_NAMED_CID(nsPhoneSupport_CID);
|
||||
#endif
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsShellService)
|
||||
NS_DEFINE_NAMED_CID(nsShellService_CID);
|
||||
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSSLCertErrorDialog)
|
||||
NS_DEFINE_NAMED_CID(nsSSLCertErrorDialog_CID);
|
||||
|
||||
static const mozilla::Module::CIDEntry kBrowserCIDs[] = {
|
||||
#ifndef ANDROID
|
||||
{ &knsPhoneSupport_CID, false, NULL, nsPhoneSupportConstructor },
|
||||
#endif
|
||||
{ &knsShellService_CID, false, NULL, nsShellServiceConstructor },
|
||||
{ &knsSSLCertErrorDialog_CID, false, NULL, nsSSLCertErrorDialogConstructor },
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
static const mozilla::Module::ContractIDEntry kBrowserContracts[] = {
|
||||
#ifndef ANDROID
|
||||
{ nsPhoneSupport_ContractID, &knsPhoneSupport_CID },
|
||||
#endif
|
||||
{ nsShellService_ContractID, &knsShellService_CID },
|
||||
{ nsSSLCertErrorDialog_ContractID, &knsSSLCertErrorDialog_CID },
|
||||
{ NULL }
|
||||
};
|
||||
|
@ -40,11 +40,22 @@
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
[scriptable, uuid(c893eb89-8650-49d2-aed7-0ef809a2b940)]
|
||||
interface nsIPhoneSupport : nsISupports
|
||||
[scriptable, uuid(fd2450a3-966b-44a9-a8eb-316256bb80b4)]
|
||||
interface nsIShellService : nsISupports
|
||||
{
|
||||
/**
|
||||
* This method displays a UI to switch to (or launch) a different task
|
||||
*/
|
||||
void switchTask();
|
||||
|
||||
/**
|
||||
* This method creates a shortcut on a desktop or homescreen that opens in
|
||||
* the our application.
|
||||
*
|
||||
* @param aTitle the user-friendly name of the shortcut.
|
||||
* @param aURI the URI to open.
|
||||
* @param aIconData a base64 encoded representation of the shortcut's icon.
|
||||
* @param aIntent how the URI should be opened. Examples: "default", "bookmark" and "webapp"
|
||||
*/
|
||||
void createShortcut(in AString aTitle, in AString aURI, in AString aIconData, in AString aIntent);
|
||||
};
|
@ -48,13 +48,17 @@
|
||||
#include <QtGui/QWidget>
|
||||
#endif
|
||||
|
||||
#include "nsPhoneSupport.h"
|
||||
#ifdef ANDROID
|
||||
#include "AndroidBridge.h"
|
||||
#endif
|
||||
|
||||
#include "nsShellService.h"
|
||||
#include "nsString.h"
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsPhoneSupport, nsIPhoneSupport)
|
||||
NS_IMPL_ISUPPORTS1(nsShellService, nsIShellService)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPhoneSupport::SwitchTask()
|
||||
nsShellService::SwitchTask()
|
||||
{
|
||||
#if (MOZ_PLATFORM_MAEMO == 5)
|
||||
DBusError error;
|
||||
@ -81,3 +85,17 @@ nsPhoneSupport::SwitchTask()
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
#endif
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsShellService::CreateShortcut(const nsAString& aTitle, const nsAString& aURI, const nsAString& aIconData, const nsAString& aIntent)
|
||||
{
|
||||
if (!aTitle.Length() || !aURI.Length() || !aIconData.Length())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
#if ANDROID
|
||||
mozilla::AndroidBridge::Bridge()->CreateShortcut(aTitle, aURI, aIconData, aIntent);
|
||||
return NS_OK;
|
||||
#else
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
#endif
|
||||
}
|
@ -39,27 +39,26 @@
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef __NS_PHONESUPPORT_H__
|
||||
#define __NS_PHONESUPPORT_H__
|
||||
#ifndef __NS_SHELLSERVICE_H__
|
||||
#define __NS_SHELLSERVICE_H__
|
||||
|
||||
#include "nsIPhoneSupport.h"
|
||||
#include "nsIShellService.h"
|
||||
|
||||
class nsPhoneSupport : public nsIPhoneSupport
|
||||
class nsShellService : public nsIShellService
|
||||
{
|
||||
public:
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIPHONESUPPORT
|
||||
NS_DECL_NSISHELLSERVICE
|
||||
|
||||
nsPhoneSupport() {};
|
||||
~nsPhoneSupport() {};
|
||||
nsShellService() {};
|
||||
~nsShellService() {};
|
||||
|
||||
};
|
||||
|
||||
#define nsPhoneSupport_CID \
|
||||
{ 0x2a08c9e4, 0xf853, 0x4f02, \
|
||||
{0x88, 0xd8, 0xd6, 0x2f, 0x27, 0xca, 0x06, 0x85} }
|
||||
#define nsShellService_CID \
|
||||
{0xae9ebe1c, 0x61e9, 0x45fa, {0x8f, 0x34, 0xc1, 0x07, 0x80, 0x3a, 0x5b, 0x44}}
|
||||
|
||||
#define nsPhoneSupport_ContractID "@mozilla.org/phone/support;1"
|
||||
#define nsShellService_ContractID "@mozilla.org/browser/shell-service;1"
|
||||
|
||||
#endif
|
@ -104,6 +104,7 @@
|
||||
<!ENTITY contextFullScreen.label "Full Screen">
|
||||
<!ENTITY contextEditBookmark.label "Edit">
|
||||
<!ENTITY contextRemoveBookmark.label "Remove">
|
||||
<!ENTITY contextShortcutBookmark.label "Add Shortcut to Home">
|
||||
|
||||
<!ENTITY pageactions.saveas.pdf "Save As PDF">
|
||||
<!ENTITY pageactions.share.page "Share Page">
|
||||
|
@ -47,7 +47,7 @@ $MOZ_BRANDING_DIRECTORY/locales/Makefile
|
||||
mobile/chrome/Makefile
|
||||
mobile/chrome/tests/Makefile
|
||||
mobile/components/Makefile
|
||||
mobile/components/phone/Makefile
|
||||
mobile/components/build/Makefile
|
||||
mobile/modules/Makefile
|
||||
mobile/installer/Makefile
|
||||
mobile/locales/Makefile
|
||||
|
@ -72,7 +72,6 @@ PARALLEL_DIRS += \
|
||||
urlformatter \
|
||||
viewconfig \
|
||||
viewsource \
|
||||
webapps \
|
||||
telemetry \
|
||||
$(NULL)
|
||||
|
||||
|
@ -78,12 +78,6 @@ LOCAL_INCLUDES += \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
ifeq (Android,$(OS_TARGET))
|
||||
LOCAL_INCLUDES += \
|
||||
-I$(srcdir)/../webapps \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
SHARED_LIBRARY_LIBS = \
|
||||
../find/$(LIB_PREFIX)mozfind_s.$(LIB_SUFFIX) \
|
||||
../typeaheadfind/$(LIB_PREFIX)fastfind_s.$(LIB_SUFFIX) \
|
||||
@ -123,8 +117,4 @@ ifdef MOZ_FEEDS
|
||||
SHARED_LIBRARY_LIBS += ../feeds/$(LIB_PREFIX)feed_s.$(LIB_SUFFIX)
|
||||
endif
|
||||
|
||||
ifeq (Android,$(OS_TARGET))
|
||||
SHARED_LIBRARY_LIBS += ../webapps/$(LIB_PREFIX)webapps_s.$(LIB_SUFFIX)
|
||||
endif
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
@ -116,9 +116,6 @@
|
||||
#define NS_APPSTARTUP_CONTRACTID \
|
||||
"@mozilla.org/toolkit/app-startup;1"
|
||||
|
||||
#define NS_WEBAPPSSUPPORT_CONTRACTID \
|
||||
"@mozilla.org/webapps/installer;1"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// {A0CCAAF8-09DA-44D8-B250-9AC3E93C8117}
|
||||
@ -194,7 +191,3 @@
|
||||
// {6fb0c970-e1b1-11db-8314-0800200c9a66}
|
||||
#define NS_PLACESIMPORTEXPORTSERVICE_CID \
|
||||
{ 0x6fb0c970, 0xe1b1, 0x11db, { 0x83, 0x14, 0x08, 0x00, 0x20, 0x0c, 0x9a, 0x66 } }
|
||||
|
||||
#define NS_WEBAPPSSUPPORT_CID \
|
||||
{ 0xd0b62752, 0x88be, 0x4c88, {0x94, 0xe5, 0xc6, 0x9e, 0x15, 0xa1, 0x0c, 0x4e} }
|
||||
|
||||
|
@ -71,10 +71,6 @@
|
||||
|
||||
#include "nsBrowserStatusFilter.h"
|
||||
|
||||
#ifdef ANDROID
|
||||
#include "nsWebappsSupport.h"
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsAppStartup, Init)
|
||||
@ -127,10 +123,6 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsScriptableUnescapeHTML)
|
||||
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsBrowserStatusFilter)
|
||||
|
||||
#ifdef ANDROID
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsWebappsSupport)
|
||||
#endif
|
||||
|
||||
NS_DEFINE_NAMED_CID(NS_TOOLKIT_APPSTARTUP_CID);
|
||||
NS_DEFINE_NAMED_CID(NS_USERINFO_CID);
|
||||
#ifdef ALERTS_SERVICE
|
||||
@ -156,10 +148,6 @@ NS_DEFINE_NAMED_CID(NS_SCRIPTABLEUNESCAPEHTML_CID);
|
||||
NS_DEFINE_NAMED_CID(NS_BROWSERSTATUSFILTER_CID);
|
||||
NS_DEFINE_NAMED_CID(NS_CHARSETMENU_CID);
|
||||
|
||||
#ifdef ANDROID
|
||||
NS_DEFINE_NAMED_CID(NS_WEBAPPSSUPPORT_CID);
|
||||
#endif
|
||||
|
||||
static const mozilla::Module::CIDEntry kToolkitCIDs[] = {
|
||||
{ &kNS_TOOLKIT_APPSTARTUP_CID, false, NULL, nsAppStartupConstructor },
|
||||
{ &kNS_USERINFO_CID, false, NULL, nsUserInfoConstructor },
|
||||
@ -185,9 +173,6 @@ static const mozilla::Module::CIDEntry kToolkitCIDs[] = {
|
||||
#endif
|
||||
{ &kNS_BROWSERSTATUSFILTER_CID, false, NULL, nsBrowserStatusFilterConstructor },
|
||||
{ &kNS_CHARSETMENU_CID, false, NULL, NS_NewCharsetMenu },
|
||||
#ifdef ANDROID
|
||||
{ &kNS_WEBAPPSSUPPORT_CID, false, NULL, nsWebappsSupportConstructor },
|
||||
#endif
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
@ -217,9 +202,6 @@ static const mozilla::Module::ContractIDEntry kToolkitContracts[] = {
|
||||
#endif
|
||||
{ NS_BROWSERSTATUSFILTER_CONTRACTID, &kNS_BROWSERSTATUSFILTER_CID },
|
||||
{ NS_RDF_DATASOURCE_CONTRACTID_PREFIX NS_CHARSETMENU_PID, &kNS_CHARSETMENU_CID },
|
||||
#ifdef ANDROID
|
||||
{ NS_WEBAPPSSUPPORT_CONTRACTID, &kNS_WEBAPPSSUPPORT_CID },
|
||||
#endif
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
|
@ -1,61 +0,0 @@
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is Mozilla Webapp code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# the Mozilla Foundation.
|
||||
# Portions created by the Initial Developer are Copyright (C) 2010
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Fabrice Desré <fabrice@mozilla.com>
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
DEPTH = ../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE_NAME = webapps
|
||||
MODULE = webapps
|
||||
|
||||
ifeq (Android,$(OS_TARGET))
|
||||
LIBRARY_NAME = webapps_s
|
||||
LIBXUL_LIBRARY = 1
|
||||
IS_COMPONENT = 1
|
||||
EXPORT_LIBRARY = 1
|
||||
|
||||
CPPSRCS = \
|
||||
nsWebappsSupport.cpp \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
XPIDLSRCS = nsIWebappsSupport.idl
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
@ -1,78 +0,0 @@
|
||||
/* -*- Mode: c++; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Webapp code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Mozilla Foundation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Fabrice Desré <fabrice@mozilla.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "AndroidBridge.h"
|
||||
#include "nsCRTGlue.h"
|
||||
#include "nsWebappsSupport.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsWebappsSupport, nsIWebappsSupport)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWebappsSupport::InstallApplication(const PRUnichar *aTitle, const PRUnichar *aURI, const PRUnichar *aIconURI, const PRUnichar *aIconData)
|
||||
{
|
||||
ALOG("in nsWebappsSupport::InstallApplication()\n");
|
||||
AndroidBridge::AutoLocalJNIFrame jniFrame;
|
||||
JNIEnv *jEnv = GetJNIForThread();
|
||||
jclass jGeckoAppShellClass = GetGeckoAppShellClass();
|
||||
|
||||
if (!jEnv || !jGeckoAppShellClass)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
jmethodID jInstallWebApplication = jEnv->GetStaticMethodID(jGeckoAppShellClass, "installWebApplication", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V");
|
||||
jstring jstrURI = jEnv->NewString(aURI, NS_strlen(aURI));
|
||||
jstring jstrTitle = jEnv->NewString(aTitle, NS_strlen(aTitle));
|
||||
jstring jstrIconData = jEnv->NewString(aIconData, NS_strlen(aIconData));
|
||||
|
||||
if (!jstrURI || !jstrTitle || !jstrIconData)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
jEnv->CallStaticVoidMethod(jGeckoAppShellClass, jInstallWebApplication, jstrURI, jstrTitle, jstrIconData);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* we have no way to know if an application is installed, so pretend it's not installed
|
||||
*/
|
||||
NS_IMETHODIMP
|
||||
nsWebappsSupport::IsApplicationInstalled(const PRUnichar *aURI, PRBool *_retval)
|
||||
{
|
||||
*_retval = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -1,56 +0,0 @@
|
||||
/* -*- Mode: c++; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Webapp code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Mozilla Foundation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Fabrice Desré <fabrice@mozilla.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nsWebappsSupport_h__
|
||||
#define nsWebappsSupport_h__
|
||||
|
||||
#include "nsIWebappsSupport.h"
|
||||
|
||||
class nsWebappsSupport : public nsIWebappsSupport
|
||||
{
|
||||
public:
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIWEBAPPSSUPPORT
|
||||
|
||||
nsWebappsSupport() {};
|
||||
~nsWebappsSupport() {};
|
||||
|
||||
};
|
||||
|
||||
#endif // nsWebappsSupport_h__
|
||||
|
@ -147,6 +147,7 @@ AndroidBridge::Init(JNIEnv *jEnv,
|
||||
jScanMedia = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "scanMedia", "(Ljava/lang/String;Ljava/lang/String;)V");
|
||||
jGetSystemColors = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "getSystemColors", "()[I");
|
||||
jGetIconForExtension = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "getIconForExtension", "(Ljava/lang/String;I)[B");
|
||||
jCreateShortcut = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "createShortcut", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V");
|
||||
|
||||
jEGLContextClass = (jclass) jEnv->NewGlobalRef(jEnv->FindClass("javax/microedition/khronos/egl/EGLContext"));
|
||||
jEGL10Class = (jclass) jEnv->NewGlobalRef(jEnv->FindClass("javax/microedition/khronos/egl/EGL10"));
|
||||
@ -902,6 +903,21 @@ AndroidBridge::ScanMedia(const nsAString& aFile, const nsACString& aMimeType)
|
||||
mJNIEnv->CallStaticVoidMethod(mGeckoAppShellClass, jScanMedia, jstrFile, jstrMimeTypes);
|
||||
}
|
||||
|
||||
void
|
||||
AndroidBridge::CreateShortcut(const nsAString& aTitle, const nsAString& aURI, const nsAString& aIconData, const nsAString& aIntent)
|
||||
{
|
||||
AutoLocalJNIFrame jniFrame;
|
||||
jstring jstrTitle = mJNIEnv->NewString(nsPromiseFlatString(aTitle).get(), aTitle.Length());
|
||||
jstring jstrURI = mJNIEnv->NewString(nsPromiseFlatString(aURI).get(), aURI.Length());
|
||||
jstring jstrIconData = mJNIEnv->NewString(nsPromiseFlatString(aIconData).get(), aIconData.Length());
|
||||
jstring jstrIntent = mJNIEnv->NewString(nsPromiseFlatString(aIntent).get(), aIntent.Length());
|
||||
|
||||
if (!jstrURI || !jstrTitle || !jstrIconData)
|
||||
return;
|
||||
|
||||
mJNIEnv->CallStaticVoidMethod(mGeckoAppShellClass, jCreateShortcut, jstrTitle, jstrURI, jstrIconData, jstrIntent);
|
||||
}
|
||||
|
||||
bool
|
||||
AndroidBridge::HasNativeBitmapAccess()
|
||||
{
|
||||
|
@ -249,6 +249,8 @@ public:
|
||||
|
||||
void ScanMedia(const nsAString& aFile, const nsACString& aMimeType);
|
||||
|
||||
void CreateShortcut(const nsAString& aTitle, const nsAString& aURI, const nsAString& aIconData, const nsAString& aIntent);
|
||||
|
||||
// These next four functions are for native Bitmap access in Android 2.2+
|
||||
bool HasNativeBitmapAccess();
|
||||
|
||||
@ -319,6 +321,7 @@ protected:
|
||||
jmethodID jScanMedia;
|
||||
jmethodID jGetSystemColors;
|
||||
jmethodID jGetIconForExtension;
|
||||
jmethodID jCreateShortcut;
|
||||
|
||||
// stuff we need for CallEglCreateWindowSurface
|
||||
jclass jEGLSurfaceImplClass;
|
||||
|
Loading…
x
Reference in New Issue
Block a user