aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXan Lopez <xan@src.gnome.org>2007-10-21 23:43:19 +0800
committerXan Lopez <xan@src.gnome.org>2007-10-21 23:43:19 +0800
commita78af5ef50e7ee33d0e5c3e8652280fe9081eb99 (patch)
tree169a47eb52956327af0b5a0ade61badfa66ecdd0
parentb9edf3436f43a8df14192aae61b33bdaf459fe45 (diff)
downloadgsoc2013-epiphany-a78af5ef50e7ee33d0e5c3e8652280fe9081eb99.tar.gz
gsoc2013-epiphany-a78af5ef50e7ee33d0e5c3e8652280fe9081eb99.tar.zst
gsoc2013-epiphany-a78af5ef50e7ee33d0e5c3e8652280fe9081eb99.zip
Add security-level property to embed and fix EphyWindow.
svn path=/trunk/; revision=7539
-rw-r--r--embed/mozilla/mozilla-embed.cpp69
-rw-r--r--src/ephy-window.c21
2 files changed, 78 insertions, 12 deletions
diff --git a/embed/mozilla/mozilla-embed.cpp b/embed/mozilla/mozilla-embed.cpp
index 3fadccc38..21828ae37 100644
--- a/embed/mozilla/mozilla-embed.cpp
+++ b/embed/mozilla/mozilla-embed.cpp
@@ -92,10 +92,19 @@ struct MozillaEmbedPrivate
{
EphyBrowser *browser;
MozillaEmbedLoadState load_state;
+
+ EphyEmbedSecurityLevel security_level;
+ /* guint security_level : 3; ? */
};
#define WINDOWWATCHER_CONTRACTID "@mozilla.org/embedcomp/window-watcher;1"
+enum
+{
+ PROP_0,
+ PROP_SECURITY
+};
+
static GObjectClass *parent_class = NULL;
static void
@@ -232,6 +241,44 @@ mozilla_embed_constructor (GType type, guint n_construct_properties,
}
static void
+mozilla_embed_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ MozillaEmbed *embed = MOZILLA_EMBED (object);
+ MozillaEmbedPrivate *priv = embed->priv;
+
+ switch (prop_id)
+ {
+ case PROP_SECURITY:
+ g_value_set_enum (value, priv->security_level);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+
+}
+
+static void
+mozilla_embed_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ switch (prop_id)
+ {
+ case PROP_SECURITY:
+ /* read only */
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
mozilla_embed_class_init (MozillaEmbedClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
@@ -242,12 +289,16 @@ mozilla_embed_class_init (MozillaEmbedClass *klass)
object_class->constructor = mozilla_embed_constructor;
object_class->finalize = mozilla_embed_finalize;
+ object_class->get_property = mozilla_embed_get_property;
+ object_class->set_property = mozilla_embed_set_property;
gtk_object_class->destroy = mozilla_embed_destroy;
widget_class->grab_focus = mozilla_embed_grab_focus;
widget_class->realize = mozilla_embed_realize;
+ g_object_class_override_property (object_class, PROP_SECURITY, "security-level");
+
g_type_class_add_private (object_class, sizeof(MozillaEmbedPrivate));
}
@@ -278,6 +329,8 @@ mozilla_embed_init (MozillaEmbed *embed)
g_signal_connect_object (embed, "security_change",
G_CALLBACK (mozilla_embed_security_change_cb),
embed, (GConnectFlags) 0);
+
+ embed->priv->security_level = EPHY_EMBED_STATE_IS_UNKNOWN;
}
gpointer
@@ -1106,13 +1159,25 @@ mozilla_embed_new_window_cb (GtkMozEmbed *embed,
}
static void
+mozilla_embed_set_security_level (MozillaEmbed *embed, EphyEmbedSecurityLevel level)
+{
+ MozillaEmbedPrivate *priv = embed->priv;
+
+ if (priv->security_level != level)
+ {
+ priv->security_level = level;
+
+ g_object_notify (G_OBJECT (embed), "security-level");
+ }
+}
+
+static void
mozilla_embed_security_change_cb (GtkMozEmbed *embed,
gpointer requestptr,
PRUint32 state,
MozillaEmbed *membed)
{
- g_signal_emit_by_name (membed, "ge_security_change",
- mozilla_embed_security_level (state));
+ mozilla_embed_set_security_level (membed, mozilla_embed_security_level (state));
}
static EphyEmbedSecurityLevel
diff --git a/src/ephy-window.c b/src/ephy-window.c
index b16b2b743..e3147452f 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -100,7 +100,7 @@ static void ephy_window_view_popup_windows_cb (GtkAction *action,
static void sync_tab_load_status (EphyTab *tab,
GParamSpec *pspec,
EphyWindow *window);
-static void sync_tab_security (EphyTab *tab,
+static void sync_tab_security (EphyEmbed *embed,
GParamSpec *pspec,
EphyWindow *window);
static void sync_tab_zoom (EphyTab *tab,
@@ -707,7 +707,7 @@ ephy_window_fullscreen (EphyWindow *window)
/* sync status */
tab = ephy_window_get_active_tab (window);
sync_tab_load_status (tab, NULL, window);
- sync_tab_security (tab, NULL, window);
+ sync_tab_security (ephy_tab_get_embed (tab), NULL, window);
egg_editable_toolbar_set_model
(EGG_EDITABLE_TOOLBAR (priv->toolbar),
@@ -1527,12 +1527,11 @@ sync_tab_navigation (EphyTab *tab,
}
static void
-sync_tab_security (EphyTab *tab,
+sync_tab_security (EphyEmbed *embed,
GParamSpec *pspec,
EphyWindow *window)
{
EphyWindowPrivate *priv = window->priv;
- EphyEmbed *embed;
EphyEmbedSecurityLevel level;
char *description = NULL;
char *state = NULL;
@@ -1543,8 +1542,6 @@ sync_tab_security (EphyTab *tab,
if (priv->closing) return;
- embed = ephy_tab_get_embed (tab);
-
ephy_embed_get_security_level (embed, &level, &description);
switch (level)
@@ -2197,6 +2194,10 @@ ephy_window_set_active_tab (EphyWindow *window, EphyTab *new_tab)
if (new_tab != NULL)
{
+ embed = ephy_tab_get_embed (new_tab);
+
+ sync_tab_security (embed, NULL, window);
+
sync_tab_address (new_tab, NULL, window);
sync_tab_document_type (new_tab, NULL, window);
sync_tab_icon (new_tab, NULL, window);
@@ -2204,7 +2205,6 @@ ephy_window_set_active_tab (EphyWindow *window, EphyTab *new_tab)
sync_tab_load_status (new_tab, NULL, window);
sync_tab_message (new_tab, NULL, window);
sync_tab_navigation (new_tab, NULL, window);
- sync_tab_security (new_tab, NULL, window);
sync_tab_popup_windows (new_tab, NULL, window);
sync_tab_popups_allowed (new_tab, NULL, window);
sync_tab_title (new_tab, NULL, window);
@@ -2231,9 +2231,6 @@ ephy_window_set_active_tab (EphyWindow *window, EphyTab *new_tab)
g_signal_connect_object (new_tab, "notify::navigation",
G_CALLBACK (sync_tab_navigation),
window, 0);
- g_signal_connect_object (new_tab, "notify::security-level",
- G_CALLBACK (sync_tab_security),
- window, 0);
g_signal_connect_object (new_tab, "notify::hidden-popup-count",
G_CALLBACK (sync_tab_popup_windows),
window, 0);
@@ -2248,6 +2245,10 @@ ephy_window_set_active_tab (EphyWindow *window, EphyTab *new_tab)
window, 0);
embed = ephy_tab_get_embed (new_tab);
+
+ g_signal_connect_object (embed, "notify::security-level",
+ G_CALLBACK (sync_tab_security),
+ window, 0);
g_signal_connect_object (embed, "ge-context-menu",
G_CALLBACK (tab_context_menu_cb),
window, G_CONNECT_AFTER);