svnno****@sourc*****
svnno****@sourc*****
Sun Aug 3 20:35:25 JST 2008
Revision: 3508 http://svn.sourceforge.jp/cgi-bin/viewcvs.cgi?root=kazehakase&view=rev&rev=3508 Author: kous Date: 2008-08-03 20:35:25 +0900 (Sun, 03 Aug 2008) Log Message: ----------- * module/embed/gecko/kz-mozcookiepromptservice.{cpp,h}: show cookie accept/reject dialog by kazehakase itself not Gecko's XUL implementation. derived from Epiphany's embed/mozilla/GeckoCookiePromptService.{cpp,h}. * module/embed/gecko/mozilla.cpp: register KzMozCookiePromptService. * module/embed/gecko/Makefile.am: add kz-mozcookiepromptservice.{cpp,h}. Modified Paths: -------------- kazehakase/trunk/ChangeLog kazehakase/trunk/module/embed/gecko/Makefile.am kazehakase/trunk/module/embed/gecko/mozilla.cpp Added Paths: ----------- kazehakase/trunk/module/embed/gecko/kz-mozcookiepromptservice.cpp kazehakase/trunk/module/embed/gecko/kz-mozcookiepromptservice.h Modified: kazehakase/trunk/ChangeLog =================================================================== --- kazehakase/trunk/ChangeLog 2008-07-29 14:15:15 UTC (rev 3507) +++ kazehakase/trunk/ChangeLog 2008-08-03 11:35:25 UTC (rev 3508) @@ -1,3 +1,14 @@ +2008-08-03 Kouhei Sutou <kou****@cozmi*****> + + * module/embed/gecko/kz-mozcookiepromptservice.{cpp,h}: + show cookie accept/reject dialog by kazehakase itself not Gecko's + XUL implementation. derived from Epiphany's + embed/mozilla/GeckoCookiePromptService.{cpp,h}. + + * module/embed/gecko/mozilla.cpp: register KzMozCookiePromptService. + + * module/embed/gecko/Makefile.am: add kz-mozcookiepromptservice.{cpp,h}. + 2008-07-29 Ryo SHIMIZU <furyo****@on-ai*****> * configure.ac: version 0.5.5. Modified: kazehakase/trunk/module/embed/gecko/Makefile.am =================================================================== --- kazehakase/trunk/module/embed/gecko/Makefile.am 2008-07-29 14:15:15 UTC (rev 3507) +++ kazehakase/trunk/module/embed/gecko/Makefile.am 2008-08-03 11:35:25 UTC (rev 3508) @@ -88,7 +88,8 @@ kz-mozutils.cpp kz-mozutils.h \ kz-mozwrapper.cpp kz-mozwrapper.h \ kz-mozthumbnailer.cpp kz-mozthumbnailer.h \ - kz-mozhistorysearch.cpp kz-mozhistorysearch.h + kz-mozhistorysearch.cpp kz-mozhistorysearch.h \ + kz-mozcookiepromptservice.cpp kz-mozcookiepromptservice.h if HAVE_NSIBADCERTLISTENER_H gecko_la_SOURCES += \ Added: kazehakase/trunk/module/embed/gecko/kz-mozcookiepromptservice.cpp =================================================================== --- kazehakase/trunk/module/embed/gecko/kz-mozcookiepromptservice.cpp (rev 0) +++ kazehakase/trunk/module/embed/gecko/kz-mozcookiepromptservice.cpp 2008-08-03 11:35:25 UTC (rev 3508) @@ -0,0 +1,148 @@ +// -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- + +// derived from epiphany's embed/mozilla/GeckoCookiePromptService.cpp. +// original header: +/* + * Copyright © 2003 Tommi Komulainen <tommi****@iki*****> + * Copyright © 2004, 2007 Christian Persch + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * $Id$ + */ + +#include "mozilla-config.h" +#include "config.h" + +#include <glib/gi18n.h> + +#include <gtk/gtkbox.h> +#include <gtk/gtkcheckbutton.h> +#include <gtk/gtkdialog.h> +#include <gtk/gtkmessagedialog.h> +#include <gtk/gtkstock.h> +#include <gtk/gtkwindow.h> + +#include <nsStringAPI.h> + +#include "kz-mozcookiepromptservice.h" + +#include "kz-mozutils.h" + +NS_IMPL_ISUPPORTS1 (KzMozCookiePromptService, nsICookiePromptService) + +KzMozCookiePromptService::KzMozCookiePromptService() +{ +} + +KzMozCookiePromptService::~KzMozCookiePromptService() +{ +} + +/* boolean cookieDialog (in nsIDOMWindow parent, in nsICookie cookie, in ACString hostname, in long cookiesFromHost, in boolean changingCookie, inout boolean checkValue); */ +NS_IMETHODIMP +KzMozCookiePromptService::CookieDialog (nsIDOMWindow *aParent, + nsICookie *aCookie, + const nsACString &aHostname, + PRInt32 aCookiesFromHost, + PRBool aChangingCookie, + PRBool *_checkValue, + PRBool *_retval) +{ + NS_ENSURE_ARG(aParent); + NS_ENSURE_ARG(aCookie); + NS_ENSURE_ARG_POINTER(_checkValue); + NS_ENSURE_ARG_POINTER(_retval); + + nsCString host(aHostname); + + GtkWidget *kz; + GtkWidget *dialog; + + kz = GetGtkWindowForDOMWindow(aParent); + dialog = gtk_message_dialog_new(GTK_WINDOW(kz), + GTK_DIALOG_MODAL /* FIXME mozilla sucks! */, + GTK_MESSAGE_QUESTION, + GTK_BUTTONS_NONE, + _("Accept cookie from %s?"), + host.get()); + gtk_window_set_title(GTK_WINDOW(dialog), _("Accept Cookie?")); + + if (aChangingCookie) { + gtk_message_dialog_format_secondary_text + (GTK_MESSAGE_DIALOG(dialog), + _("The site wants to modify an existing cookie.")); + } else if (aCookiesFromHost == 0) { + gtk_message_dialog_format_secondary_text + (GTK_MESSAGE_DIALOG(dialog), + _("The site wants to set a cookie.")); + } else if (aCookiesFromHost == 1) { + gtk_message_dialog_format_secondary_text + (GTK_MESSAGE_DIALOG(dialog), + _("The site wants to set a second cookie.")); + } else { + char *num_text = g_strdup_printf + (ngettext("You already have %d cookie from this site.", + "You already have %d cookies from this site.", + aCookiesFromHost), + aCookiesFromHost); + + gtk_message_dialog_format_secondary_text + (GTK_MESSAGE_DIALOG(dialog), + "The site %s wants to set another cookie. %s", + host.get(), num_text); + g_free(num_text); + } + + GtkWidget *check_button; + check_button = gtk_check_button_new_with_mnemonic + (_("Apply this _decision to all cookies from this site")); + gtk_widget_show(check_button); + + GtkWidget *content_box; + GList *children; + + content_box = GTK_DIALOG(dialog)->vbox; + children = gtk_container_get_children(GTK_CONTAINER(content_box)); + content_box = GTK_WIDGET(children->data); + g_list_free(children); + + children = gtk_container_get_children(GTK_CONTAINER(content_box)); + content_box = GTK_WIDGET(children->next->data); + g_list_free(children); + + gtk_box_pack_start(GTK_BOX(content_box), check_button, FALSE, FALSE, 0); + + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_button), + *_checkValue); + + gtk_dialog_add_button(GTK_DIALOG(dialog), + _("_Reject"), GTK_RESPONSE_REJECT); + gtk_dialog_add_button(GTK_DIALOG(dialog), + _("_Accept"), GTK_RESPONSE_ACCEPT); + gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT); + + int response = gtk_dialog_run(GTK_DIALOG(dialog)); + + if (response == GTK_RESPONSE_ACCEPT || response == GTK_RESPONSE_REJECT) { + *_retval = (response == GTK_RESPONSE_ACCEPT); + *_checkValue = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(check_button)); + } else { + *_retval = PR_FALSE; + *_checkValue = PR_FALSE; + } + gtk_widget_destroy(dialog); + + return NS_OK; +} Property changes on: kazehakase/trunk/module/embed/gecko/kz-mozcookiepromptservice.cpp ___________________________________________________________________ Name: svn:keywords + Id Added: kazehakase/trunk/module/embed/gecko/kz-mozcookiepromptservice.h =================================================================== --- kazehakase/trunk/module/embed/gecko/kz-mozcookiepromptservice.h (rev 0) +++ kazehakase/trunk/module/embed/gecko/kz-mozcookiepromptservice.h 2008-08-03 11:35:25 UTC (rev 3508) @@ -0,0 +1,47 @@ +// -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- + +// derived from epiphany's embed/mozilla/GeckoCookiePromptService.h. +// original header: +/* + * Copyright (C) 2003 Tommi Komulainen <tommi****@iki*****> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * $Id$ + */ + +#ifndef KzMozCookieServiceService_h___ +#define KzMozCookieServiceService_h___ + +#include <nsICookiePromptService.h> + +/* 7a5b8bea-fa1f-445c-8947-84f09756e312 */ +#define KZ_COOKIEPROMPTSERVICE_CID \ + { 0x7a5b8bea, 0xfa1f, 0x445c, { 0x89, 0x47, 0x84, 0xf0, 0x97, 0x56, 0xe3, 0x12 } } + +#define KZ_COOKIEPROMPTSERVICE_CLASSNAME "Kazehakase Cookie Prompt Service" +#define KZ_COOKIEPROMPTSERVICE_CONTRACTID "@mozilla.org/embedcomp/cookieprompt-service;1" + +class KzMozCookiePromptService : public nsICookiePromptService { + public: + NS_DECL_ISUPPORTS + NS_DECL_NSICOOKIEPROMPTSERVICE + + KzMozCookiePromptService(); + + private: + ~KzMozCookiePromptService(); +}; + +#endif /* KzMozCookieServiceService_h___ */ Property changes on: kazehakase/trunk/module/embed/gecko/kz-mozcookiepromptservice.h ___________________________________________________________________ Name: svn:keywords + Id Modified: kazehakase/trunk/module/embed/gecko/mozilla.cpp =================================================================== --- kazehakase/trunk/module/embed/gecko/mozilla.cpp 2008-07-29 14:15:15 UTC (rev 3507) +++ kazehakase/trunk/module/embed/gecko/mozilla.cpp 2008-08-03 11:35:25 UTC (rev 3508) @@ -43,6 +43,7 @@ #include "kazehakase.h" #include "kz-mozhistorysearch.h" #include "kz-mozselectionlistener.h" +#include "kz-mozcookiepromptservice.h" #ifdef HAVE_NSIBADCERTLISTENER_H # include "GtkNSSDialogs.h" #endif @@ -64,6 +65,7 @@ #ifdef HAVE_NSIBADCERTLISTENER_H NS_GENERIC_FACTORY_CONSTRUCTOR(GtkNSSDialogs) #endif +NS_GENERIC_FACTORY_CONSTRUCTOR(KzMozCookiePromptService) static const nsModuleComponentInfo sAppComps[] = { { @@ -116,6 +118,12 @@ "@mozilla.org/embedcomp/prompt-service;1", GtkPromptServiceConstructor }, + { + KZ_COOKIEPROMPTSERVICE_CLASSNAME, + KZ_COOKIEPROMPTSERVICE_CID, + KZ_COOKIEPROMPTSERVICE_CONTRACTID, + KzMozCookiePromptServiceConstructor + }, }; static const int sNumAppComps = G_N_ELEMENTS(sAppComps);