aboutsummaryrefslogtreecommitdiffstats
path: root/embed/mozilla
diff options
context:
space:
mode:
authorChristian Persch <chpe@cvs.gnome.org>2004-06-24 04:07:43 +0800
committerChristian Persch <chpe@src.gnome.org>2004-06-24 04:07:43 +0800
commitbf9a14796c23d31c781a6e09b92f523531285932 (patch)
tree2b176ececf168f5d06293a7397e5a8f16441b933 /embed/mozilla
parent38b74d1e516fd674940903dbf49a48894c0bbab7 (diff)
downloadgsoc2013-epiphany-bf9a14796c23d31c781a6e09b92f523531285932.tar
gsoc2013-epiphany-bf9a14796c23d31c781a6e09b92f523531285932.tar.gz
gsoc2013-epiphany-bf9a14796c23d31c781a6e09b92f523531285932.tar.bz2
gsoc2013-epiphany-bf9a14796c23d31c781a6e09b92f523531285932.tar.lz
gsoc2013-epiphany-bf9a14796c23d31c781a6e09b92f523531285932.tar.xz
gsoc2013-epiphany-bf9a14796c23d31c781a6e09b92f523531285932.tar.zst
gsoc2013-epiphany-bf9a14796c23d31c781a6e09b92f523531285932.zip
Make the permission type a string instead of an enum, that way we can
2004-06-23 Christian Persch <chpe@cvs.gnome.org> * doc/reference/tmpl/ephy-permission-manager.sgml: * embed/ephy-permission-manager.c: (ephy_permission_info_new), (ephy_permission_info_copy), (ephy_permission_manager_add), (ephy_permission_manager_remove), (ephy_permission_manager_test), (ephy_permission_manager_list): * embed/ephy-permission-manager.h: * embed/mozilla/EphySingle.cpp: * embed/mozilla/mozilla-embed-single.cpp: Make the permission type a string instead of an enum, that way we can support more than just the hardcoded 3 types.
Diffstat (limited to 'embed/mozilla')
-rw-r--r--embed/mozilla/EphySingle.cpp21
-rw-r--r--embed/mozilla/mozilla-embed-single.cpp30
2 files changed, 20 insertions, 31 deletions
diff --git a/embed/mozilla/EphySingle.cpp b/embed/mozilla/EphySingle.cpp
index 1a3791b43..b667c16d1 100644
--- a/embed/mozilla/EphySingle.cpp
+++ b/embed/mozilla/EphySingle.cpp
@@ -263,26 +263,11 @@ mozilla_cookie_to_ephy_cookie (nsICookie *cookie)
EphyPermissionInfo *
mozilla_permission_to_ephy_permission (nsIPermission *perm)
{
- EphyPermissionType type = (EphyPermissionType) 0;
-
nsresult result;
- nsEmbedCString str;
- result = perm->GetType(str);
+ nsEmbedCString type;
+ result = perm->GetType(type);
NS_ENSURE_SUCCESS (result, NULL);
- if (strcmp (str.get(), "cookie") == 0)
- {
- type = EPT_COOKIE;
- }
- else if (strcmp (str.get(), "image"))
- {
- type = EPT_IMAGE;
- }
- else if (strcmp (str.get(), "popup"))
- {
- type = EPT_POPUP;
- }
-
PRUint32 cap;
perm->GetCapability(&cap);
EphyPermission permission;
@@ -303,5 +288,5 @@ mozilla_permission_to_ephy_permission (nsIPermission *perm)
nsEmbedCString host;
perm->GetHost(host);
- return ephy_permission_info_new (host.get(), type, permission);
+ return ephy_permission_info_new (host.get(), type.get(), permission);
}
diff --git a/embed/mozilla/mozilla-embed-single.cpp b/embed/mozilla/mozilla-embed-single.cpp
index 6513c8095..7b48f03f6 100644
--- a/embed/mozilla/mozilla-embed-single.cpp
+++ b/embed/mozilla/mozilla-embed-single.cpp
@@ -718,11 +718,12 @@ static const char *permission_type_string [] =
void
impl_permission_manager_add (EphyPermissionManager *manager,
const char *host,
- EphyPermissionType type,
+ const char *type,
EphyPermission permission)
{
/* can only set allow or deny */
g_return_if_fail (permission != EPHY_PERMISSION_DEFAULT);
+ g_return_if_fail (type != NULL && type[0] != '\0');
nsCOMPtr<nsIPermissionManager> pm
(do_GetService (NS_PERMISSIONMANAGER_CONTRACTID));
@@ -734,8 +735,7 @@ impl_permission_manager_add (EphyPermissionManager *manager,
gboolean allow = (permission == EPHY_PERMISSION_ALLOWED);
- pm->Add (uri,
- permission_type_string [type],
+ pm->Add (uri, type,
allow ? (PRUint32) nsIPermissionManager::ALLOW_ACTION :
(PRUint32) nsIPermissionManager::DENY_ACTION);
}
@@ -743,13 +743,13 @@ impl_permission_manager_add (EphyPermissionManager *manager,
void
impl_permission_manager_remove (EphyPermissionManager *manager,
const char *host,
- EphyPermissionType type)
+ const char *type)
{
nsCOMPtr<nsIPermissionManager> pm
(do_GetService (NS_PERMISSIONMANAGER_CONTRACTID));
if (!pm) return;
- pm->Remove (nsEmbedCString (host), permission_type_string [type]);
+ pm->Remove (nsEmbedCString (host), type);
}
void
@@ -765,8 +765,10 @@ impl_permission_manager_clear (EphyPermissionManager *manager)
EphyPermission
impl_permission_manager_test (EphyPermissionManager *manager,
const char *host,
- EphyPermissionType type)
+ const char *type)
{
+ g_return_val_if_fail (type != NULL && type[0] != '\0', EPHY_PERMISSION_DEFAULT);
+
nsCOMPtr<nsIPermissionManager> pm
(do_GetService (NS_PERMISSIONMANAGER_CONTRACTID));
if (!pm) return EPHY_PERMISSION_DEFAULT;
@@ -777,7 +779,7 @@ impl_permission_manager_test (EphyPermissionManager *manager,
nsresult rv;
PRUint32 action;
- rv = pm->TestPermission (uri, permission_type_string [type], &action);
+ rv = pm->TestPermission (uri, type, &action);
NS_ENSURE_SUCCESS (rv, EPHY_PERMISSION_DEFAULT);
EphyPermission permission;
@@ -801,7 +803,7 @@ impl_permission_manager_test (EphyPermissionManager *manager,
GList *
impl_permission_manager_list (EphyPermissionManager *manager,
- EphyPermissionType type)
+ const char *type)
{
GList *list = NULL;
@@ -813,11 +815,13 @@ impl_permission_manager_list (EphyPermissionManager *manager,
pm->GetEnumerator(getter_AddRefs(pe));
NS_ENSURE_TRUE (pe, NULL);
- PRBool more;
- for (pe->HasMoreElements (&more); more == PR_TRUE; pe->HasMoreElements (&more))
+ PRBool hasMore;
+ while (NS_SUCCEEDED (pe->HasMoreElements (&hasMore)) && hasMore)
{
- nsCOMPtr<nsIPermission> perm;
- pe->GetNext(getter_AddRefs(perm));
+ nsCOMPtr<nsISupports> element;
+ pe->GetNext (getter_AddRefs (element));
+
+ nsCOMPtr<nsIPermission> perm (do_QueryInterface (element));
if (!perm) continue;
nsresult rv;
@@ -825,7 +829,7 @@ impl_permission_manager_list (EphyPermissionManager *manager,
rv = perm->GetType(str);
if (NS_FAILED (rv)) continue;
- if (strcmp (str.get(), permission_type_string[type]) == 0)
+ if (strcmp (str.get(), type) == 0)
{
EphyPermissionInfo *info =
mozilla_permission_to_ephy_permission (perm);