Revision: 6035
Author: [email protected]
Date: Sat Aug 29 22:15:21 2009
Log: Add changes to prompt the user if we don't find the current web server  
in
the access list, cleanup old libraries, changes from review feedback.

http://code.google.com/p/google-web-toolkit/source/detail?r=6035

Added:
  /changes/jat/plugins/plugins/xpcom/UserAgents.txt
   
/changes/jat/plugins/plugins/xpcom/prebuilt/extension-ff3/platform/Linux_x86_64-gcc3/components/libgwt_dmp_ff3.so
   
/changes/jat/plugins/plugins/xpcom/prebuilt/extension-ff3+/platform/Linux_x86_64-gcc3/components/libgwt_dmp_ff3+.so
Deleted:
  /changes/jat/plugins/plugins/xpcom/prebuilt/extension-ff2/install.rdf
   
/changes/jat/plugins/plugins/xpcom/prebuilt/extension-ff2/platform/Linux_x86-gcc3/components/liboophm_ff2.so
   
/changes/jat/plugins/plugins/xpcom/prebuilt/extension-ff2/platform/Linux_x86_64-gcc3/components/liboophm_ff2.so
  /changes/jat/plugins/plugins/xpcom/prebuilt/extension-ff3/chrome.manifest
  /changes/jat/plugins/plugins/xpcom/prebuilt/extension-ff3/install.rdf
   
/changes/jat/plugins/plugins/xpcom/prebuilt/extension-ff3/platform/Darwin_x86-gcc3/components/liboophm.dylib
   
/changes/jat/plugins/plugins/xpcom/prebuilt/extension-ff3/platform/Linux_x86-gcc3/components/liboophm_ff3.so
   
/changes/jat/plugins/plugins/xpcom/prebuilt/extension-ff3/platform/Linux_x86_64-gcc3/components/liboophm_ff3.so
  /changes/jat/plugins/plugins/xpcom/prebuilt/extension-ff3+/chrome.manifest
  /changes/jat/plugins/plugins/xpcom/prebuilt/extension-ff3+/install.rdf
   
/changes/jat/plugins/plugins/xpcom/prebuilt/extension-ff3+/platform/Linux_x86_64-gcc3/components/liboophm_ff3+.so
   
/changes/jat/plugins/plugins/xpcom/prebuilt/extension-ff35/platform/Linux_x86_64-gcc3/components/liboophm_ff35.so
  /changes/jat/plugins/plugins/xpcom/prebuilt/oophm-xpcom-ff2.xpi
  /changes/jat/plugins/plugins/xpcom/prebuilt/oophm-xpcom-ff3+.xpi
  /changes/jat/plugins/plugins/xpcom/prebuilt/oophm-xpcom-ff3.xpi
  /changes/jat/plugins/plugins/xpcom/prebuilt/oophm-xpcom-ff35.xpi
Modified:
  /changes/jat/plugins/plugins/xpcom/ExternalWrapper.cpp
  /changes/jat/plugins/plugins/xpcom/ExternalWrapper.h
  /changes/jat/plugins/plugins/xpcom/FFSessionHandler.cpp
  /changes/jat/plugins/plugins/xpcom/FFSessionHandler.h
  /changes/jat/plugins/plugins/xpcom/Makefile
  /changes/jat/plugins/plugins/xpcom/ModuleOOPHM.cpp
  /changes/jat/plugins/plugins/xpcom/Preferences.cpp
  /changes/jat/plugins/plugins/xpcom/Preferences.h
  /changes/jat/plugins/plugins/xpcom/prebuilt/extension/content/options.xul
  /changes/jat/plugins/plugins/xpcom/prebuilt/extension/content/prefScript.js

=======================================
--- /dev/null
+++ /changes/jat/plugins/plugins/xpcom/UserAgents.txt   Sat Aug 29 22:15:21  
2009
@@ -0,0 +1,8 @@
+User agents that work with ff3 XPI:
+===================================
+Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.13) Gecko/2009080315  
Ubuntu/9.04 (jaunty) Firefox/3.08
+
+User agents that work with ff3+ XPI:
+====================================
+Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.0.12) Gecko/2009072110  
Fedora/3.0.12-1.fc10 Firefox/3.0.12
+
=======================================
--- /dev/null   
+++  
/changes/jat/plugins/plugins/xpcom/prebuilt/extension-ff3/platform/Linux_x86_64-gcc3/components/libgwt_dmp_ff3.so
        
Sat Aug 29 22:15:21 2009
File is too large to display a diff.
=======================================
--- /dev/null   
+++  
/changes/jat/plugins/plugins/xpcom/prebuilt/extension-ff3+/platform/Linux_x86_64-gcc3/components/libgwt_dmp_ff3+.so
      
Sat Aug 29 22:15:21 2009
File is too large to display a diff.
=======================================
--- /changes/jat/plugins/plugins/xpcom/prebuilt/extension-ff2/install.rdf       
 
Mon Aug  3 08:30:11 2009
+++ /dev/null
@@ -1,46 +0,0 @@
-<?xml version="1.0"?>
-<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#";
-     xmlns:em="http://www.mozilla.org/2004/em-rdf#";>
-
-  <Description about="urn:mozilla:install-manifest">
-    <em:id>[email protected]</em:id>
-    <em:name>GWT Hosted Mode Plugin (XPCOM) for FF v1.5-2.x</em:name>
-    <em:version>0.0.-1M.20090803104826</em:version>
-    <em:type>2</em:type>
-    <em:targetApplication>
-      <Description>
-        <em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
-        <em:minVersion>1.5</em:minVersion>
-        <em:maxVersion>2.*</em:maxVersion>
-      </Description>
-    </em:targetApplication>
-
-    <!-- Front End MetaData -->
-    <em:description>A plugin to support hosted-mode development of GWT  
applications</em:description>
-    <em:creator>Google, Inc.</em:creator>
-    <em:homepageURL>http://code.google.com/webtoolkit/</em:homepageURL>
-    <em:iconURL>chrome://gwt-oophm/skin/icon.png</em:iconURL>
-
-    <em:targetPlatform>Linux_x86-gcc3</em:targetPlatform>
-    <em:targetPlatform>Linux_x86_64-gcc3</em:targetPlatform>
-    <em:targetPlatform>Darwin_x86-gcc3</em:targetPlatform>
-
-    <!-- TODO
-    # prefs dialog
-
-    # replace default about dialog
-    <em:aboutURL>chrome://gwt-oophm/content/about.xul</em:aboutURL>
-
-    # updates, see  
http://developer.mozilla.org/en/docs/Extension_Versioning%2C_Update_and_Compatibility#Update_RDF_Format
-    <em:updateURL>https://xxx.google.com/.../update.rdf</em:updateURL>
-     
<em:updateURL>http://google-web-toolkit.googlecode.com/svn/trunk/plugins/xpcom/prebuilt/update.rdf</em:updateURL>
-
-    # platforms - any others?
-    <em:targetPlatform>WINNT_x86-msvc</em:targetPlatform>
-    <em:targetPlatform>Darwin_ppc-gcc3</em:targetPlatform>
-    <em:targetPlatform>SunOS_sparc-sunc</em:targetPlatform>
-    <em:targetPlatform>SunOS_x86-sunc</em:targetPlatform>
-    -->
-
-  </Description>
-</RDF>
=======================================
---  
/changes/jat/plugins/plugins/xpcom/prebuilt/extension-ff2/platform/Linux_x86-gcc3/components/liboophm_ff2.so
     
Sat Aug 22 16:59:24 2009
+++ /dev/null   
Binary file, no diff available.
=======================================
---  
/changes/jat/plugins/plugins/xpcom/prebuilt/extension-ff2/platform/Linux_x86_64-gcc3/components/liboophm_ff2.so
  
Sat Aug 22 16:59:24 2009
+++ /dev/null   
Binary file, no diff available.
=======================================
---  
/changes/jat/plugins/plugins/xpcom/prebuilt/extension-ff3/chrome.manifest       
 
Mon Aug  3 08:30:11 2009
+++ /dev/null
@@ -1,2 +0,0 @@
-content gwt-oophm content/
-skin gwt-oophm classic/1.0 skin/
=======================================
--- /changes/jat/plugins/plugins/xpcom/prebuilt/extension-ff3/install.rdf       
 
Mon Aug  3 08:30:11 2009
+++ /dev/null
@@ -1,46 +0,0 @@
-<?xml version="1.0"?>
-<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#";
-     xmlns:em="http://www.mozilla.org/2004/em-rdf#";>
-
-  <Description about="urn:mozilla:install-manifest">
-    <em:id>[email protected]</em:id>
-    <em:name>GWT Hosted Mode Plugin (XPCOM) for FF v3.x</em:name>
-    <em:version>0.0.-1M.20090803104821</em:version>
-    <em:type>2</em:type>
-    <em:targetApplication>
-      <Description>
-        <em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
-        <em:minVersion>3</em:minVersion>
-        <em:maxVersion>3.*</em:maxVersion>
-      </Description>
-    </em:targetApplication>
-
-    <!-- Front End MetaData -->
-    <em:description>A plugin to support hosted-mode development of GWT  
applications</em:description>
-    <em:creator>Google, Inc.</em:creator>
-    <em:homepageURL>http://code.google.com/webtoolkit/</em:homepageURL>
-    <em:iconURL>chrome://gwt-oophm/skin/icon.png</em:iconURL>
-
-    <em:targetPlatform>Linux_x86-gcc3</em:targetPlatform>
-    <em:targetPlatform>Linux_x86_64-gcc3</em:targetPlatform>
-    <em:targetPlatform>WINNT_x86-msvc</em:targetPlatform>
-    <em:targetPlatform>Darwin_x86-gcc3</em:targetPlatform>
-
-    <!-- TODO
-    # prefs dialog
-
-    # replace default about dialog
-    <em:aboutURL>chrome://gwt-oophm/content/about.xul</em:aboutURL>
-
-    # updates, see  
http://developer.mozilla.org/en/docs/Extension_Versioning%2C_Update_and_Compatibility#Update_RDF_Format
-    <em:updateURL>https://xxx.google.com/.../update.rdf</em:updateURL>
-     
<em:updateURL>http://google-web-toolkit.googlecode.com/svn/trunk/plugins/xpcom/prebuilt/update.rdf</em:updateURL>
-
-    # platforms - any others?
-    <em:targetPlatform>Darwin_ppc-gcc3</em:targetPlatform>
-    <em:targetPlatform>SunOS_sparc-sunc</em:targetPlatform>
-    <em:targetPlatform>SunOS_x86-sunc</em:targetPlatform>
-    -->
-
-  </Description>
-</RDF>
=======================================
---  
/changes/jat/plugins/plugins/xpcom/prebuilt/extension-ff3/platform/Darwin_x86-gcc3/components/liboophm.dylib
     
Mon Aug  3 08:30:11 2009
+++ /dev/null   
File is too large to display a diff.
=======================================
---  
/changes/jat/plugins/plugins/xpcom/prebuilt/extension-ff3/platform/Linux_x86-gcc3/components/liboophm_ff3.so
     
Sat Aug 22 16:59:24 2009
+++ /dev/null   
Binary file, no diff available.
=======================================
---  
/changes/jat/plugins/plugins/xpcom/prebuilt/extension-ff3/platform/Linux_x86_64-gcc3/components/liboophm_ff3.so
  
Sat Aug 22 16:59:24 2009
+++ /dev/null   
File is too large to display a diff.
=======================================
---  
/changes/jat/plugins/plugins/xpcom/prebuilt/extension-ff3+/chrome.manifest      
 
Mon Aug  3 08:30:11 2009
+++ /dev/null
@@ -1,2 +0,0 @@
-content gwt-oophm content/
-skin gwt-oophm classic/1.0 skin/
=======================================
--- /changes/jat/plugins/plugins/xpcom/prebuilt/extension-ff3+/install.rdf      
 
Mon Aug  3 08:30:11 2009
+++ /dev/null
@@ -1,46 +0,0 @@
-<?xml version="1.0"?>
-<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#";
-     xmlns:em="http://www.mozilla.org/2004/em-rdf#";>
-
-  <Description about="urn:mozilla:install-manifest">
-    <em:id>[email protected]</em:id>
-    <em:name>GWT Hosted Mode Plugin (XPCOM) for FF v3.x</em:name>
-    <em:version>0.0.-1M.20090803104811</em:version>
-    <em:type>2</em:type>
-    <em:targetApplication>
-      <Description>
-        <em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
-        <em:minVersion>3</em:minVersion>
-        <em:maxVersion>3.*</em:maxVersion>
-      </Description>
-    </em:targetApplication>
-
-    <!-- Front End MetaData -->
-    <em:description>A plugin to support hosted-mode development of GWT  
applications</em:description>
-    <em:creator>Google, Inc.</em:creator>
-    <em:homepageURL>http://code.google.com/webtoolkit/</em:homepageURL>
-    <em:iconURL>chrome://gwt-oophm/skin/icon.png</em:iconURL>
-
-    <em:targetPlatform>Linux_x86-gcc3</em:targetPlatform>
-    <em:targetPlatform>Linux_x86_64-gcc3</em:targetPlatform>
-    <em:targetPlatform>WINNT_x86-msvc</em:targetPlatform>
-    <em:targetPlatform>Darwin_x86-gcc3</em:targetPlatform>
-
-    <!-- TODO
-    # prefs dialog
-
-    # replace default about dialog
-    <em:aboutURL>chrome://gwt-oophm/content/about.xul</em:aboutURL>
-
-    # updates, see  
http://developer.mozilla.org/en/docs/Extension_Versioning%2C_Update_and_Compatibility#Update_RDF_Format
-    <em:updateURL>https://xxx.google.com/.../update.rdf</em:updateURL>
-     
<em:updateURL>http://google-web-toolkit.googlecode.com/svn/trunk/plugins/xpcom/prebuilt/update.rdf</em:updateURL>
-
-    # platforms - any others?
-    <em:targetPlatform>Darwin_ppc-gcc3</em:targetPlatform>
-    <em:targetPlatform>SunOS_sparc-sunc</em:targetPlatform>
-    <em:targetPlatform>SunOS_x86-sunc</em:targetPlatform>
-    -->
-
-  </Description>
-</RDF>
=======================================
---  
/changes/jat/plugins/plugins/xpcom/prebuilt/extension-ff3+/platform/Linux_x86_64-gcc3/components/liboophm_ff3+.so
        
Sat Aug 22 16:59:24 2009
+++ /dev/null   
File is too large to display a diff.
=======================================
---  
/changes/jat/plugins/plugins/xpcom/prebuilt/extension-ff35/platform/Linux_x86_64-gcc3/components/liboophm_ff35.so
        
Sat Aug 22 16:59:24 2009
+++ /dev/null   
Binary file, no diff available.
=======================================
--- /changes/jat/plugins/plugins/xpcom/prebuilt/oophm-xpcom-ff2.xpi     Mon  
Aug  3 08:30:11 2009
+++ /dev/null   
Binary file, no diff available.
=======================================
--- /changes/jat/plugins/plugins/xpcom/prebuilt/oophm-xpcom-ff3+.xpi    Mon  
Aug  3 08:30:11 2009
+++ /dev/null   
Binary file, no diff available.
=======================================
--- /changes/jat/plugins/plugins/xpcom/prebuilt/oophm-xpcom-ff3.xpi     Mon  
Aug  3 08:30:11 2009
+++ /dev/null   
File is too large to display a diff.
=======================================
--- /changes/jat/plugins/plugins/xpcom/prebuilt/oophm-xpcom-ff35.xpi    Mon  
Aug  3 08:30:11 2009
+++ /dev/null   
Binary file, no diff available.
=======================================
--- /changes/jat/plugins/plugins/xpcom/ExternalWrapper.cpp      Sat Aug 29  
13:11:38 2009
+++ /changes/jat/plugins/plugins/xpcom/ExternalWrapper.cpp      Sat Aug 29  
22:15:21 2009
@@ -22,6 +22,7 @@
  #include "nsCOMPtr.h"
  #include "nsMemory.h"
  #include "nsServiceManagerUtils.h"
+#include "nsIPromptService.h"

  #ifndef NS_IMPL_ISUPPORTS2_CI
  #include "nsIClassInfoImpl.h" // 1.9 only
@@ -35,7 +36,15 @@
  NS_IMPL_ISUPPORTS2_CI(ExternalWrapper, IOOPHM, nsISecurityCheckedComponent)

  ExternalWrapper::ExternalWrapper() {
-  Debug::log(Debug::Spam) << "ExternalWrapper::ExternalWrapper()" <<  
Debug::flush;
+  Debug::log(Debug::Spam) << "ExternalWrapper::ExternalWrapper()"
+      << Debug::flush;
+  preferences = new Preferences();
+  windowWatcher = do_GetService(NS_WINDOWWATCHER_CONTRACTID);
+  if (!windowWatcher) {
+    Debug::log(Debug::Warning) << "Can't get WindowWatcher service"
+        << Debug::flush;
+    return;
+  }
  }

  ExternalWrapper::~ExternalWrapper() {
@@ -60,12 +69,59 @@
    return NS_OK;
  }

-// TODO: handle context object passed in (currently nsIDOMWindow below)
-NS_IMETHODIMP ExternalWrapper::Init(nsIDOMWindow* domWindow, PRBool  
*_retval) {
+std::string ExternalWrapper::computeTabIdentity() {
+  std::string returnVal;
+  if (!windowWatcher) {
+    return returnVal;
+  }
+  nsCOMPtr<nsIDOMWindow> topWindow(domWindow);
+  if (topWindow->GetTop(getter_AddRefs(topWindow)) != NS_OK) {
+    Debug::log(Debug::Warning) << "Unable to get top window" <<  
Debug::flush;
+    return returnVal;
+  }
+  nsCOMPtr<nsIWebBrowserChrome> chrome;
+  if (windowWatcher->GetChromeForWindow(topWindow.get(),
+      getter_AddRefs(chrome)) != NS_OK) {
+    Debug::log(Debug::Warning) << "Unable to get browser chrome for window"
+        << Debug::flush;
+    return returnVal;
+  }
+  Debug::log(Debug::Debugging) << "computeTabIdentity: browserChrome = "
+      << (void*) chrome.get() << Debug::flush;
+  // TODO(jat): find a way to get the tab from the chrome window
+  return returnVal;
+}
+
+NS_IMETHODIMP ExternalWrapper::Init(nsIDOMWindow* domWindow,
+    PRBool *_retval) {
    Debug::log(Debug::Spam) << "Init" << Debug::flush;
+  this->domWindow = domWindow;
    *_retval = true;
    return NS_OK;
  }
+
+bool ExternalWrapper::askUserToAllow(const std::string& url) {
+  nsCOMPtr<nsIPromptService> promptService = do_GetService(
+      "@mozilla.org/embedcomp/prompt-service;1");
+  if (!promptService) {
+    return false;
+  }
+  NS_ConvertASCIItoUTF16 title("Allow GWT Development Mode Connection");
+  NS_ConvertASCIItoUTF16 text("This web server is requesting a GWT "
+      "development mode connection -- do you want to allow it?");
+  NS_ConvertASCIItoUTF16 checkMsg("Remember this decision for this server "
+      "(change in GWT plugin preferences)");
+  PRBool remember = false;
+  PRBool include = true;
+  if (promptService->ConfirmCheck(domWindow.get(), title.get(), text.get(),
+      checkMsg.get(), &remember, &include) != NS_OK) {
+    return false;
+  }
+  if (remember) {
+     
preferences->addNewRule(AllowedConnections::getHostFromUrl(url), !include);
+  }
+  return include;
+}

  NS_IMETHODIMP ExternalWrapper::Connect(const nsACString& url,
                const nsACString& sessionKey, const nsACString& aAddr,
@@ -84,12 +140,16 @@
    std::string hostedUrl(addrAutoStr.get());
    std::string urlStr(urlAutoStr.get());

-  if (!AllowedConnections::isAllowed(urlStr)) {
-    // TODO(jat): allow the user to allow the connection, for now just  
reject it
+  bool allowed = false;
+  if (!AllowedConnections::matchesRule(urlStr, &allowed)) {
+    // If we didn't match an existing rule, prompt the user
+    allowed = askUserToAllow(urlStr);
+  }
+  if (!allowed) {
      *_retval = false;
-       return NS_OK;
-  }
-
+    return NS_OK;
+  }
+
    size_t index = hostedUrl.find(':');
    if (index == std::string::npos) {
      *_retval = false;
@@ -128,7 +188,7 @@
      return res;
    }

-  std::string tabKeyStr(""); // TODO(jat): add support for tab identity
+  std::string tabKeyStr = computeTabIdentity();
    std::string sessionKeyStr(sessionKeyAutoStr.get());

    LoadModuleMessage::send(*channel, urlStr, tabKeyStr, sessionKeyStr,
=======================================
--- /changes/jat/plugins/plugins/xpcom/ExternalWrapper.h        Sat Aug 29  
13:11:38 2009
+++ /changes/jat/plugins/plugins/xpcom/ExternalWrapper.h        Sat Aug 29  
22:15:21 2009
@@ -30,6 +30,8 @@
  #include "nsCOMPtr.h"
  #include "nsISecurityCheckedComponent.h"
  #include "nsStringAPI.h"
+#include "nsIWindowWatcher.h"
+#include "nsIDOMWindow.h"

  class nsIDOMWindow;

@@ -49,9 +51,27 @@

    ExternalWrapper();
    virtual ~ExternalWrapper();
+
  private:
-  scoped_ptr<FFSessionHandler> sessionHandler;
+  nsCOMPtr<nsIDOMWindow> domWindow;
    nsCOMPtr<Preferences> preferences;
+  scoped_ptr<FFSessionHandler> sessionHandler;
+  nsCOMPtr<nsIWindowWatcher> windowWatcher;
+
+  /**
+   * Prompt the user whether a connection should be allowed, and optionally
+   * update the preferences.
+   */
+  bool askUserToAllow(const std::string& url);
+
+  /**
+   * Compute a stable tab identity value for the DOM window.
+   *
+   * @return a unique tab identifier which is stable across reloads, or an
+   *     empty string if it cannot be computed
+   */
+  std::string computeTabIdentity();
+
  };

  inline Debug::DebugStream& operator<<(Debug::DebugStream& dbg, const  
nsACString& str) {
=======================================
--- /changes/jat/plugins/plugins/xpcom/FFSessionHandler.cpp     Mon Aug 24  
16:45:48 2009
+++ /changes/jat/plugins/plugins/xpcom/FFSessionHandler.cpp     Sat Aug 29  
22:15:21 2009
@@ -24,9 +24,11 @@
  #include "RootedObject.h"
  #include "InvokeMessage.h"
  #include "ServerMethods.h"
+#include "AllowedConnections.h"

  #include "jsapi.h"
  #include "nsCOMPtr.h"
+#include "nsStringAPI.h"
  #include "nsIJSContextStack.h"
  #include "nsIPrincipal.h"
  #include "nsServiceManagerUtils.h"
@@ -45,8 +47,9 @@
    }

    if (cx == nsnull) {
-    Debug::log(Debug::Error) << "Null context" << Debug::flush;
-  }
+    // TODO(jat): figure out why this can be null at plugin unload time
+    Debug::log(Debug::Error) << "GWT DMP: Null JS context" << Debug::flush;
+  }

    return cx;
  }
=======================================
--- /changes/jat/plugins/plugins/xpcom/FFSessionHandler.h       Sat Aug 22  
16:59:24 2009
+++ /changes/jat/plugins/plugins/xpcom/FFSessionHandler.h       Sat Aug 29  
22:15:21 2009
@@ -21,6 +21,7 @@

  #include "mozincludes.h"
  #include "SessionData.h"
+#include "Preferences.h"

  #include "jsapi.h"

=======================================
--- /changes/jat/plugins/plugins/xpcom/Makefile Sat Aug 29 13:11:38 2009
+++ /changes/jat/plugins/plugins/xpcom/Makefile Sat Aug 29 22:15:21 2009
@@ -14,7 +14,7 @@

  include ../config.mk

-# Make variables intended to be settable fromthe command line:
+# Make variables intended to be settable from the command line:
  #   DEFAULT_FIREFOX_LIBS      points to /usr/lib/firefox or equivalent
  #   PLUGIN_SDKS                       points to GWT /plugin-sdks directory
  #   GECKO_PLATFORM            XPCOM ABI (ie, Linux_x86_64-gcc3)
@@ -158,6 +158,7 @@
                FFSessionHandler.cpp \
                JavaObject.cpp \
                JSRunner.cpp \
+               Preferences.cpp \
                XpcomDebug.cpp

  FF_OBJS = $(patsubst %.cpp,$(OBJ_OUTDIR)/%.o,$(SRCS))
=======================================
--- /changes/jat/plugins/plugins/xpcom/ModuleOOPHM.cpp  Sat Aug 22 16:59:24  
2009
+++ /changes/jat/plugins/plugins/xpcom/ModuleOOPHM.cpp  Sat Aug 29 22:15:21  
2009
@@ -51,7 +51,8 @@
      const char *aLoaderStr, const char *aType,
      const nsModuleComponentInfo *aInfo) {

-  Debug::log(Debug::Info) << "Registered GWT hosted mode plugin"
+  Debug::log(Debug::Info)
+      << "  successfully registered GWT Development Mode plugin"
        << Debug::flush;
    nsresult rv;
    nsCOMPtr<nsICategoryManager> categoryManager =
@@ -78,7 +79,7 @@
  static NS_IMETHODIMP unregisterSelf(nsIComponentManager *aCompMgr,
      nsIFile *aPath, const char *aLoaderStr,
      const nsModuleComponentInfo *aInfo) {
-  Debug::log(Debug::Debugging) << "ModuleOOPHM unRegisterSelf()"
+  Debug::log(Debug::Info) << "Unregistered GWT Development Mode plugin"
        << Debug::flush;
    return NS_OK;
  }
@@ -111,7 +112,7 @@

  NSGETMODULE_ENTRY_POINT(ExternalWrapperModule) (nsIComponentManager  
*servMgr,
      nsIFile* location, nsIModule** result) {
-  Debug::log(Debug::Debugging) << "OOPHM ExternalWrapperModule entry point"
+  Debug::log(Debug::Debugging) << "GWT DMP ExternalWrapperModule entry  
point"
        << Debug::flush;

    // CURRENTLY BUILT AS SEPARATE PLUGINS FOR FF1.5/2 and FF3, so the below
@@ -129,7 +130,8 @@

    nsCString gecko_version;
    app_info->GetPlatformVersion(gecko_version);
-  Debug::log(Debug::Info) << "  gecko version = "
+  Debug::log(Debug::Info)
+      << "Initializing GWT Development Mode Plugin - gecko version = "
        << gecko_version.BeginReading() << Debug::flush;
  #if defined(BROWSER_FF2)
    if (strncmp(gecko_version.BeginReading(), "1.8", 3) != 0) {
=======================================
--- /changes/jat/plugins/plugins/xpcom/Preferences.cpp  Sat Aug 29 13:11:38  
2009
+++ /changes/jat/plugins/plugins/xpcom/Preferences.cpp  Sat Aug 29 22:15:21  
2009
@@ -79,6 +79,29 @@
    }
    return NS_OK;
  }
+
+void Preferences::addNewRule(const std::string& pattern, bool exclude) {
+  nsCString prefValue;
+  if (prefs->GetCharPref(DMP_ACCESS_LIST, getter_Copies(prefValue)) !=  
NS_OK) {
+    Debug::log(Debug::Error) << "Unable to retrieve access list preference"
+        << Debug::flush;
+    return;
+  }
+  // TODO(jat): see if the same rule already exists
+  std::string pref(prefValue.get());
+  if (pref.length() > 0) {
+    pref += ',';
+  }
+  if (exclude) {
+    pref += '!';
+  }
+  pref += pattern;
+  if (prefs->SetCharPref(DMP_ACCESS_LIST, pref.c_str()) != NS_OK) {
+    Debug::log(Debug::Error) << "Unable to save modified access list  
preference"
+        << Debug::flush;
+    return;
+  }
+}

  void Preferences::loadAccessList(const char* prefValue) {
    if (!prefValue) {
=======================================
--- /changes/jat/plugins/plugins/xpcom/Preferences.h    Sat Aug 29 13:11:38  
2009
+++ /changes/jat/plugins/plugins/xpcom/Preferences.h    Sat Aug 29 22:15:21  
2009
@@ -16,6 +16,8 @@
   * the License.
   */

+#include <string>
+
  #include "mozincludes.h"

  #include "nsCOMPtr.h"
@@ -33,6 +35,15 @@
    Preferences();
    virtual ~Preferences();

+  /**
+   * Add a new rule to the access list preference.
+   *
+   * @param pattern pattern to add (currently only an exact-match literal)
+   * @param exclude true if the pattern should be excluded from matches,
+   *     otherwise included
+   */
+  void addNewRule(const std::string& pattern, bool exclude);
+
  private:
    static void loadAccessList(const char*);

=======================================
---  
/changes/jat/plugins/plugins/xpcom/prebuilt/extension/content/options.xul       
 
Sat Aug 29 13:11:38 2009
+++  
/changes/jat/plugins/plugins/xpcom/prebuilt/extension/content/options.xul       
 
Sat Aug 29 22:15:21 2009
@@ -42,7 +42,7 @@
      <button id="addButton" label="Add Entry"  
oncommand="GwtDevelopmentModePlugin.addEntry()"/>
    </hbox>

-  <listbox id="listbox" rows="5">
+  <listbox id="accessListListbox" rows="5">
      <listhead>
        <listheader label="Inc/Exc"/>
        <listheader label="Host Name"/>
@@ -56,6 +56,7 @@
    <hbox>
      <button id="removeButton" label="Remove Selected"
          oncommand="GwtDevelopmentModePlugin.removeEntry()"/>
+    <!-- TODO(jat): add move up/down buttons -->
    </hbox>

  </vbox>
=======================================
---  
/changes/jat/plugins/plugins/xpcom/prebuilt/extension/content/prefScript.js     
 
Sat Aug 29 13:11:38 2009
+++  
/changes/jat/plugins/plugins/xpcom/prebuilt/extension/content/prefScript.js     
 
Sat Aug 29 22:15:21 2009
@@ -9,7 +9,7 @@
      return;
    }
    if (hostname.indexOf(",") >=0 || hostname.indexOf("!") >= 0) {
-    alert("Host name must not contain , or !");
+    alert("Host name must not contain ',' or '!'");
      return;
    }
    var exclude = document.getElementById("exclude");
@@ -23,7 +23,7 @@
    }
    var listboxEntry = this.makeLBE(incText, hostname);
    var prefsEntry = prefix + hostname;
-  var listbox = document.getElementById("listbox");
+  var listbox = document.getElementById("accessListListbox");
    listbox.appendChild(listboxEntry);
    prefs.push(prefsEntry.toString());
    this.saveAccessList(prefs);
@@ -31,7 +31,7 @@

  // Remove the selected entry when the Remove Entry button is clicked.
  removeEntry: function() {
-  var listbox = document.getElementById("listbox");
+  var listbox = document.getElementById("accessListListbox");
    var idx = listbox.selectedIndex;
    if (idx >= 0) {
      listbox.removeItemAt(idx);
@@ -43,7 +43,7 @@

  // Populate the listbox when the dialog window is loaded
  onload: function() {
-  var listbox = document.getElementById("listbox");
+  var listbox = document.getElementById("accessListListbox");
    var prefs = this.getAccessList();
    for (var i = 0 ; i < prefs.length; ++i) {
      var pref = prefs[i];
@@ -72,10 +72,9 @@

  // Internal - load the access list from the gwt-dmp.accessList preference
  getAccessList: function() {
-  var prefs = Components.classes["@mozilla.org/preferences-service;1"]
-                  .getService(Components.interfaces.nsIPrefService)
-                  .getBranch("gwt-dmp.");
-  prefs.QueryInterface(Components.interfaces.nsIPrefBranch2);
+  var prefServ = Components.classes["@mozilla.org/preferences-service;1"]
+                  .getService(Components.interfaces.nsIPrefService);
+  var prefs = prefServ.getBranch("gwt-dmp.");
    var pref = prefs.getCharPref("accessList");
    if (!pref) {
      return [];
@@ -88,7 +87,6 @@
    var prefServ = Components.classes["@mozilla.org/preferences-service;1"]
                    .getService(Components.interfaces.nsIPrefService);
    var prefs = prefServ.getBranch("gwt-dmp.");
-  prefs.QueryInterface(Components.interfaces.nsIPrefBranch2);
    prefs.setCharPref("accessList", list.join(","));
    prefServ.savePrefFile(null);
  }

--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/Google-Web-Toolkit-Contributors
-~----------~----~----~----~------~----~------~--~---

Reply via email to