2 * Copyright (C) 2008 Benjamin Otte <otte@gnome.org>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301 USA
24 #include <swfdec/swfdec_access.h>
25 #include <swfdec/swfdec_debug.h>
28 swfdec_player_allow_by_matrix (SwfdecPlayer
*player
, SwfdecSandbox
*sandbox
,
29 const char *url_string
, const SwfdecAccessMatrix matrix
,
30 SwfdecPolicyFunc func
, gpointer data
)
32 SwfdecAccessPermission perm
;
33 SwfdecAccessType type
;
36 g_return_if_fail (SWFDEC_IS_PLAYER (player
));
37 g_return_if_fail (SWFDEC_IS_SANDBOX (sandbox
));
38 g_return_if_fail (url_string
!= NULL
);
39 g_return_if_fail (func
);
41 url
= swfdec_player_create_url (player
, url_string
);
43 func (player
, FALSE
, data
);
47 if (swfdec_url_is_local (url
)) {
48 type
= SWFDEC_ACCESS_LOCAL
;
49 } else if (swfdec_url_host_equal (url
, sandbox
->url
)) {
50 type
= SWFDEC_ACCESS_SAME_HOST
;
52 type
= SWFDEC_ACCESS_NET
;
55 perm
= matrix
[sandbox
->type
][type
];
57 if (perm
== SWFDEC_ACCESS_YES
) {
58 func (player
, TRUE
, data
);
59 } else if (perm
== SWFDEC_ACCESS_NO
) {
60 func (player
, FALSE
, data
);
62 SwfdecURL
*load_url
= swfdec_url_new_components (
63 swfdec_url_get_protocol (url
), swfdec_url_get_host (url
),
64 swfdec_url_get_port (url
), "crossdomain.xml", NULL
);
65 swfdec_player_allow_or_load (player
, sandbox
->url
, url
, load_url
, func
, data
);
66 swfdec_url_free (load_url
);
69 swfdec_url_free (url
);