Author: yurize
Date: Sat May  5 20:42:40 2012
New Revision: 1334496

URL: http://svn.apache.org/viewvc?rev=1334496&view=rev
Log:
Adds template for generation of Google Analytics javascript snippet.

Added:
    
incubator/wave/trunk/src/org/waveprotocol/box/server/gxp/AnalyticsFragment.gxp
    
incubator/wave/trunk/src/org/waveprotocol/box/server/gxp/RobotRegistrationPage.gxp
      - copied, changed from r1334495, 
incubator/wave/trunk/src/org/waveprotocol/box/server/gxp/robots/RobotRegistrationPage.gxp
    
incubator/wave/trunk/src/org/waveprotocol/box/server/gxp/RobotRegistrationSuccessPage.gxp
      - copied, changed from r1334495, 
incubator/wave/trunk/src/org/waveprotocol/box/server/gxp/robots/RobotRegistrationSuccessPage.gxp
    
incubator/wave/trunk/src/org/waveprotocol/wave/client/wavepanel/impl/title/WindowTitleHandler.java
Removed:
    
incubator/wave/trunk/src/org/waveprotocol/box/server/gxp/robots/RobotRegistrationPage.gxp
    
incubator/wave/trunk/src/org/waveprotocol/box/server/gxp/robots/RobotRegistrationSuccessPage.gxp
Modified:
    incubator/wave/trunk/server-config.xml
    incubator/wave/trunk/server.config.example
    incubator/wave/trunk/src/org/waveprotocol/box/server/CoreSettings.java
    
incubator/wave/trunk/src/org/waveprotocol/box/server/gxp/AuthenticationPage.gxp
    
incubator/wave/trunk/src/org/waveprotocol/box/server/gxp/UserRegistrationPage.gxp
    incubator/wave/trunk/src/org/waveprotocol/box/server/gxp/WaveClientPage.gxp
    
incubator/wave/trunk/src/org/waveprotocol/box/server/robots/RobotRegistrationServlet.java
    
incubator/wave/trunk/src/org/waveprotocol/box/server/rpc/AuthenticationServlet.java
    
incubator/wave/trunk/src/org/waveprotocol/box/server/rpc/UserRegistrationServlet.java
    
incubator/wave/trunk/src/org/waveprotocol/box/server/rpc/WaveClientServlet.java
    
incubator/wave/trunk/src/org/waveprotocol/box/webclient/client/StagesProvider.java
    
incubator/wave/trunk/src/org/waveprotocol/box/webclient/client/WebClient.java
    
incubator/wave/trunk/test/org/waveprotocol/box/server/rpc/AuthenticationServletTest.java
    
incubator/wave/trunk/test/org/waveprotocol/box/server/rpc/UserRegistrationServletTest.java

Modified: incubator/wave/trunk/server-config.xml
URL: 
http://svn.apache.org/viewvc/incubator/wave/trunk/server-config.xml?rev=1334496&r1=1334495&r2=1334496&view=diff
==============================================================================
--- incubator/wave/trunk/server-config.xml (original)
+++ incubator/wave/trunk/server-config.xml Sat May  5 20:42:40 2012
@@ -30,6 +30,7 @@
   <property name="ssl_keystore_password" value="changeme" />
   <property name="search_type" value="lucene" />
   <property name="index_directory" value="_indexes" />
+  <property name="analytics_account" value="" />
 
   <!-- Properties for server.federation.config -->
   <property name="xmpp_server_secret" value="opensesame" />
@@ -99,6 +100,7 @@
           <token key="SSL_KEYSTORE_PASSWORD" value="${ssl_keystore_password}" 
/>
           <token key="SEARCH_TYPE" value="${search_type}" />
           <token key="INDEX_DIRECTORY" value="${index_directory}" />
+          <token key="ANALYTICS_ACCOUNT" value="${analytics_account}" />
         </replacetokens>
       </filterchain>
     </copy>

Modified: incubator/wave/trunk/server.config.example
URL: 
http://svn.apache.org/viewvc/incubator/wave/trunk/server.config.example?rev=1334496&r1=1334495&r2=1334496&view=diff
==============================================================================
--- incubator/wave/trunk/server.config.example (original)
+++ incubator/wave/trunk/server.config.example Sat May  5 20:42:40 2012
@@ -131,7 +131,7 @@ enable_ssl = @ENABLE_SSL@
 # Note: this is only used when enable_ssl set to true.
 ssl_keystore_path = @SSL_KEYSTORE_PATH@
 
-#Password to the keystore.
+# Password to the keystore.
 # Note: this is only used when enable_ssl set to true.
 ssl_keystore_password = @SSL_KEYSTORE_PASSWORD@
 
@@ -148,3 +148,7 @@ search_type = @SEARCH_TYPE@
 # for other search types.
 # Default value: _indexes
 index_directory = @INDEX_DIRECTORY@
+
+ # Google Analytics account.
+ # Default value: empty
+analytics_account = @ANALYTICS_ACCOUNT@

Modified: incubator/wave/trunk/src/org/waveprotocol/box/server/CoreSettings.java
URL: 
http://svn.apache.org/viewvc/incubator/wave/trunk/src/org/waveprotocol/box/server/CoreSettings.java?rev=1334496&r1=1334495&r2=1334496&view=diff
==============================================================================
--- incubator/wave/trunk/src/org/waveprotocol/box/server/CoreSettings.java 
(original)
+++ incubator/wave/trunk/src/org/waveprotocol/box/server/CoreSettings.java Sat 
May  5 20:42:40 2012
@@ -62,6 +62,7 @@ public class CoreSettings {
   public static final String ENABLE_IMPORT = "enable_import";
   public static final String SEARCH_TYPE = "search_type";
   public static final String INDEX_DIRECTORY = "index_directory";
+  public static final String ANALYTICS_ACCOUNT = "analytics_account";
 
   @Setting(name = WAVE_SERVER_DOMAIN)
   private static String waveServerDomain;
@@ -216,4 +217,7 @@ public class CoreSettings {
   @Setting(name = SEARCH_TYPE,
       description = "The wave search type", defaultValue = "lucene")
   private static String searchType;
+
+  @Setting(name = ANALYTICS_ACCOUNT, description = "Google analytics id")
+  private static String analyticsAccount;
 }

Added: 
incubator/wave/trunk/src/org/waveprotocol/box/server/gxp/AnalyticsFragment.gxp
URL: 
http://svn.apache.org/viewvc/incubator/wave/trunk/src/org/waveprotocol/box/server/gxp/AnalyticsFragment.gxp?rev=1334496&view=auto
==============================================================================
--- 
incubator/wave/trunk/src/org/waveprotocol/box/server/gxp/AnalyticsFragment.gxp 
(added)
+++ 
incubator/wave/trunk/src/org/waveprotocol/box/server/gxp/AnalyticsFragment.gxp 
Sat May  5 20:42:40 2012
@@ -0,0 +1,48 @@
+<?xml version="1.0" ?>
+<!--
+  Copyright (C) 2011 Google Inc.
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+
+  Author: [email protected] (Christian Ohler)
+
+  Analytics page view tracking code.  Call in other pages immediately before 
</head>.
+-->
+<!DOCTYPE gxp:template SYSTEM
+  'http://gxp.googlecode.com/svn/trunk/resources/xhtml.ent'>
+<gxp:template name='org.waveprotocol.box.server.gxp.AnalyticsFragment'
+  xmlns='http://www.w3.org/1999/xhtml'
+  xmlns:expr='http://google.com/2001/gxp/expressions'
+  xmlns:call='http://google.com/2001/gxp/call'
+  xmlns:gxp='http://google.com/2001/gxp'>
+
+  <gxp:param name='account' type='String'/>
+  <gxp:param name='error' type='String' default='null'/>
+
+  <gxp:if cond='account != null &amp;&amp; !account.isEmpty()'>
+    <script type="text/javascript">
+      var _gaq = _gaq || [];
+      _gaq.push(['_setAccount', <gxp:eval expr='account'/>]);
+      <gxp:if cond='error != null &amp;&amp; !error.isEmpty()'>
+        _gaq.push(['_setCustomVar', 1, 'error', <gxp:eval expr='error'/>, 3]);
+      </gxp:if>
+      _gaq.push(['_trackPageview']);
+
+      (function() {
+        var ga = document.createElement('script'); ga.type = 
'text/javascript'; ga.async = true;
+        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 
'http://www') + '.google-analytics.com/ga.js';
+        var s = document.getElementsByTagName('script')[0]; 
s.parentNode.insertBefore(ga, s);
+      })();
+    </script>
+  </gxp:if>
+</gxp:template>

Modified: 
incubator/wave/trunk/src/org/waveprotocol/box/server/gxp/AuthenticationPage.gxp
URL: 
http://svn.apache.org/viewvc/incubator/wave/trunk/src/org/waveprotocol/box/server/gxp/AuthenticationPage.gxp?rev=1334496&r1=1334495&r2=1334496&view=diff
==============================================================================
--- 
incubator/wave/trunk/src/org/waveprotocol/box/server/gxp/AuthenticationPage.gxp 
(original)
+++ 
incubator/wave/trunk/src/org/waveprotocol/box/server/gxp/AuthenticationPage.gxp 
Sat May  5 20:42:40 2012
@@ -22,11 +22,14 @@
 
 <gxp:template name='org.waveprotocol.box.server.gxp.AuthenticationPage'
   xmlns='http://www.w3.org/1999/xhtml'
+  xmlns:expr='http://google.com/2001/gxp/expressions'
+  xmlns:call='http://google.com/2001/gxp/call'
   xmlns:gxp='http://google.com/2001/gxp'>
 
   <gxp:param name='domain' type='String' />
   <gxp:param name='message' type='String' />
   <gxp:param name='responseType' type='String' />
+  <gxp:param name='analyticsAccount' type='String'/>
 
   <html dir="ltr">
   <head>
@@ -34,6 +37,7 @@
   <link type="text/css" rel="stylesheet" href="/static/auth.css" />
   <link rel="shortcut icon" href="/static/favicon.ico" />
   <title>Wave in a Box login</title>
+  <call:AnalyticsFragment expr:account='analyticsAccount'/>
   </head>
   <body onload="init()">
   <table width="100%" border="0" align="center" cellpadding="0"

Copied: 
incubator/wave/trunk/src/org/waveprotocol/box/server/gxp/RobotRegistrationPage.gxp
 (from r1334495, 
incubator/wave/trunk/src/org/waveprotocol/box/server/gxp/robots/RobotRegistrationPage.gxp)
URL: 
http://svn.apache.org/viewvc/incubator/wave/trunk/src/org/waveprotocol/box/server/gxp/RobotRegistrationPage.gxp?p2=incubator/wave/trunk/src/org/waveprotocol/box/server/gxp/RobotRegistrationPage.gxp&p1=incubator/wave/trunk/src/org/waveprotocol/box/server/gxp/robots/RobotRegistrationPage.gxp&r1=1334495&r2=1334496&rev=1334496&view=diff
==============================================================================
--- 
incubator/wave/trunk/src/org/waveprotocol/box/server/gxp/robots/RobotRegistrationPage.gxp
 (original)
+++ 
incubator/wave/trunk/src/org/waveprotocol/box/server/gxp/RobotRegistrationPage.gxp
 Sat May  5 20:42:40 2012
@@ -5,18 +5,22 @@
 -->
 
 <gxp:template
-    name='org.waveprotocol.box.server.gxp.robots.RobotRegistrationPage'
+    name='org.waveprotocol.box.server.gxp.RobotRegistrationPage'
     xmlns='http://www.w3.org/1999/xhtml'
+    xmlns:expr='http://google.com/2001/gxp/expressions'
+    xmlns:call='http://google.com/2001/gxp/call'
     xmlns:gxp='http://google.com/2001/gxp'>
 
   <gxp:param name='domain' type='String' />
   <gxp:param name='message' type='String' />
+  <gxp:param name='analyticsAccount' type='String'/>
 
   <html>
     <head>
       <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
       <title>Robot Registration</title>
       <link rel="shortcut icon" href="/static/favicon.ico" />
+      <call:AnalyticsFragment expr:account='analyticsAccount'/>
     </head>
 
     <body>

Copied: 
incubator/wave/trunk/src/org/waveprotocol/box/server/gxp/RobotRegistrationSuccessPage.gxp
 (from r1334495, 
incubator/wave/trunk/src/org/waveprotocol/box/server/gxp/robots/RobotRegistrationSuccessPage.gxp)
URL: 
http://svn.apache.org/viewvc/incubator/wave/trunk/src/org/waveprotocol/box/server/gxp/RobotRegistrationSuccessPage.gxp?p2=incubator/wave/trunk/src/org/waveprotocol/box/server/gxp/RobotRegistrationSuccessPage.gxp&p1=incubator/wave/trunk/src/org/waveprotocol/box/server/gxp/robots/RobotRegistrationSuccessPage.gxp&r1=1334495&r2=1334496&rev=1334496&view=diff
==============================================================================
--- 
incubator/wave/trunk/src/org/waveprotocol/box/server/gxp/robots/RobotRegistrationSuccessPage.gxp
 (original)
+++ 
incubator/wave/trunk/src/org/waveprotocol/box/server/gxp/RobotRegistrationSuccessPage.gxp
 Sat May  5 20:42:40 2012
@@ -5,17 +5,22 @@
 -->
 
 <gxp:template
-  name='org.waveprotocol.box.server.gxp.robots.RobotRegistrationSuccessPage'
-  xmlns='http://www.w3.org/1999/xhtml' xmlns:gxp='http://google.com/2001/gxp'>
+  name='org.waveprotocol.box.server.gxp.RobotRegistrationSuccessPage'
+  xmlns='http://www.w3.org/1999/xhtml'
+  xmlns:expr='http://google.com/2001/gxp/expressions'
+  xmlns:call='http://google.com/2001/gxp/call'
+  xmlns:gxp='http://google.com/2001/gxp'>
 
   <gxp:param name='token' type='String' />
   <gxp:param name='tokenSecret' type='String' />
+  <gxp:param name='analyticsAccount' type='String'/>
 
   <html>
   <head>
   <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
   <title>Robot Successfully Registered</title>
   <link rel="shortcut icon" href="/static/favicon.ico" />
+  <call:AnalyticsFragment expr:account='analyticsAccount'/>
   </head>
 
   <body>

Modified: 
incubator/wave/trunk/src/org/waveprotocol/box/server/gxp/UserRegistrationPage.gxp
URL: 
http://svn.apache.org/viewvc/incubator/wave/trunk/src/org/waveprotocol/box/server/gxp/UserRegistrationPage.gxp?rev=1334496&r1=1334495&r2=1334496&view=diff
==============================================================================
--- 
incubator/wave/trunk/src/org/waveprotocol/box/server/gxp/UserRegistrationPage.gxp
 (original)
+++ 
incubator/wave/trunk/src/org/waveprotocol/box/server/gxp/UserRegistrationPage.gxp
 Sat May  5 20:42:40 2012
@@ -7,13 +7,15 @@
 <gxp:template
   name='org.waveprotocol.box.server.gxp.UserRegistrationPage'
   xmlns='http://www.w3.org/1999/xhtml'
+  xmlns:expr='http://google.com/2001/gxp/expressions'
+  xmlns:call='http://google.com/2001/gxp/call'
   xmlns:gxp='http://google.com/2001/gxp'>
 
   <gxp:param name='domain' type='String' />
   <gxp:param name='message' type='String' />
   <gxp:param name='responseType' type='String' />
   <gxp:param name='disableRegistration' type='Boolean' />
-
+  <gxp:param name='analyticsAccount' type='String'/>
 
   <html dir="ltr">
   <head>
@@ -21,7 +23,7 @@
   <link type="text/css" rel="stylesheet" href="/static/auth.css" />
   <title>Register a New Account - Wave in a Box</title>
   <link rel="shortcut icon" href="/static/favicon.ico" />
-
+  <call:AnalyticsFragment expr:account='analyticsAccount'/>
   </head>
   <body onload="init()">
   <table width="100%" border="0" align="center" cellpadding="0"

Modified: 
incubator/wave/trunk/src/org/waveprotocol/box/server/gxp/WaveClientPage.gxp
URL: 
http://svn.apache.org/viewvc/incubator/wave/trunk/src/org/waveprotocol/box/server/gxp/WaveClientPage.gxp?rev=1334496&r1=1334495&r2=1334496&view=diff
==============================================================================
--- incubator/wave/trunk/src/org/waveprotocol/box/server/gxp/WaveClientPage.gxp 
(original)
+++ incubator/wave/trunk/src/org/waveprotocol/box/server/gxp/WaveClientPage.gxp 
Sat May  5 20:42:40 2012
@@ -23,6 +23,8 @@
 <gxp:template
     name='org.waveprotocol.box.server.gxp.WaveClientPage'
     xmlns='http://www.w3.org/1999/xhtml'
+    xmlns:expr='http://google.com/2001/gxp/expressions'
+    xmlns:call='http://google.com/2001/gxp/call'
     xmlns:gxp='http://google.com/2001/gxp'>
 
   <gxp:import class="org.json.JSONObject" />
@@ -31,6 +33,7 @@
   <gxp:param name='clientFlags' type='JSONObject' />
   <gxp:param name='topBar' type='HtmlClosure' />
   <gxp:param name='useSocketIO' type='boolean' />
+  <gxp:param name='analyticsAccount' type='String'/>
 
   <!-- Generate doctype to trigger standards mode -->
   <html gxp:doctype='transitional'>
@@ -110,6 +113,7 @@
       </style>
       <!-- GWT-compiled JS. -->
       <script type="text/javascript" language="javascript" 
src="webclient/webclient.nocache.js" />
+      <call:AnalyticsFragment expr:account='analyticsAccount'/>
     </head>
 
     <body>

Modified: 
incubator/wave/trunk/src/org/waveprotocol/box/server/robots/RobotRegistrationServlet.java
URL: 
http://svn.apache.org/viewvc/incubator/wave/trunk/src/org/waveprotocol/box/server/robots/RobotRegistrationServlet.java?rev=1334496&r1=1334495&r2=1334496&view=diff
==============================================================================
--- 
incubator/wave/trunk/src/org/waveprotocol/box/server/robots/RobotRegistrationServlet.java
 (original)
+++ 
incubator/wave/trunk/src/org/waveprotocol/box/server/robots/RobotRegistrationServlet.java
 Sat May  5 20:42:40 2012
@@ -25,8 +25,8 @@ import com.google.inject.name.Named;
 
 import org.waveprotocol.box.server.CoreSettings;
 import org.waveprotocol.box.server.account.RobotAccountData;
-import org.waveprotocol.box.server.gxp.robots.RobotRegistrationPage;
-import org.waveprotocol.box.server.gxp.robots.RobotRegistrationSuccessPage;
+import org.waveprotocol.box.server.gxp.RobotRegistrationPage;
+import org.waveprotocol.box.server.gxp.RobotRegistrationSuccessPage;
 import org.waveprotocol.box.server.persistence.PersistenceException;
 import org.waveprotocol.box.server.robots.register.RobotRegistrar;
 import 
org.waveprotocol.box.server.robots.util.RobotsUtil.RobotRegistrationException;
@@ -55,12 +55,15 @@ public class RobotRegistrationServlet ex
 
   private final RobotRegistrar robotRegistrar;
   private final String domain;
+  private final String analyticsAccount;
 
   @Inject
   private RobotRegistrationServlet(@Named(CoreSettings.WAVE_SERVER_DOMAIN) 
String domain,
-      RobotRegistrar robotRegistrar) {
+      RobotRegistrar robotRegistrar,
+      @Named(CoreSettings.ANALYTICS_ACCOUNT) String analyticsAccount) {
     this.robotRegistrar = robotRegistrar;
     this.domain = domain;
+    this.analyticsAccount = analyticsAccount;
   }
 
   @Override
@@ -90,7 +93,8 @@ public class RobotRegistrationServlet ex
    */
   private void doRegisterGet(HttpServletRequest req, HttpServletResponse resp, 
String message)
       throws IOException {
-    RobotRegistrationPage.write(resp.getWriter(), new 
GxpContext(req.getLocale()), domain, message);
+    RobotRegistrationPage.write(resp.getWriter(), new 
GxpContext(req.getLocale()), domain, message,
+        analyticsAccount);
     resp.setContentType("text/html");
     resp.setStatus(HttpServletResponse.SC_OK);
   }
@@ -139,7 +143,7 @@ public class RobotRegistrationServlet ex
   private void onRegisterSuccess(HttpServletRequest req, HttpServletResponse 
resp,
       RobotAccountData robotAccount) throws IOException {
     RobotRegistrationSuccessPage.write(resp.getWriter(), new 
GxpContext(req.getLocale()),
-        robotAccount.getId().getAddress(), robotAccount.getConsumerSecret());
+        robotAccount.getId().getAddress(), robotAccount.getConsumerSecret(), 
analyticsAccount);
     resp.setContentType("text/html");
     resp.setStatus(HttpServletResponse.SC_OK);
   }

Modified: 
incubator/wave/trunk/src/org/waveprotocol/box/server/rpc/AuthenticationServlet.java
URL: 
http://svn.apache.org/viewvc/incubator/wave/trunk/src/org/waveprotocol/box/server/rpc/AuthenticationServlet.java?rev=1334496&r1=1334495&r2=1334496&view=diff
==============================================================================
--- 
incubator/wave/trunk/src/org/waveprotocol/box/server/rpc/AuthenticationServlet.java
 (original)
+++ 
incubator/wave/trunk/src/org/waveprotocol/box/server/rpc/AuthenticationServlet.java
 Sat May  5 20:42:40 2012
@@ -78,15 +78,18 @@ public class AuthenticationServlet exten
   private final Configuration configuration;
   private final SessionManager sessionManager;
   private final String domain;
+  private final String analyticsAccount;
 
   @Inject
   public AuthenticationServlet(Configuration configuration, SessionManager 
sessionManager,
-      @Named(CoreSettings.WAVE_SERVER_DOMAIN) String domain) {
+      @Named(CoreSettings.WAVE_SERVER_DOMAIN) String domain,
+      @Named(CoreSettings.ANALYTICS_ACCOUNT) String analyticsAccount) {
     Preconditions.checkNotNull(configuration, "Configuration is null");
     Preconditions.checkNotNull(sessionManager, "Session manager is null");
     this.configuration = configuration;
     this.sessionManager = sessionManager;
     this.domain = domain.toLowerCase();
+    this.analyticsAccount = analyticsAccount;
   }
 
   @SuppressWarnings("unchecked")
@@ -137,7 +140,7 @@ public class AuthenticationServlet exten
       LOG.info("User authentication failed: " + e.getLocalizedMessage());
       resp.setStatus(HttpServletResponse.SC_FORBIDDEN);
       AuthenticationPage.write(resp.getWriter(), new 
GxpContext(req.getLocale()), domain, message,
-          responseType);
+          analyticsAccount, responseType);
       return;
     }
 
@@ -212,7 +215,7 @@ public class AuthenticationServlet exten
       resp.setStatus(HttpServletResponse.SC_OK);
       resp.setContentType("text/html;charset=utf-8");
       AuthenticationPage.write(resp.getWriter(), new 
GxpContext(req.getLocale()), domain, "",
-          RESPONSE_STATUS_NONE);
+          RESPONSE_STATUS_NONE, analyticsAccount);
     }
   }
 

Modified: 
incubator/wave/trunk/src/org/waveprotocol/box/server/rpc/UserRegistrationServlet.java
URL: 
http://svn.apache.org/viewvc/incubator/wave/trunk/src/org/waveprotocol/box/server/rpc/UserRegistrationServlet.java?rev=1334496&r1=1334495&r2=1334496&view=diff
==============================================================================
--- 
incubator/wave/trunk/src/org/waveprotocol/box/server/rpc/UserRegistrationServlet.java
 (original)
+++ 
incubator/wave/trunk/src/org/waveprotocol/box/server/rpc/UserRegistrationServlet.java
 Sat May  5 20:42:40 2012
@@ -54,17 +54,20 @@ public final class UserRegistrationServl
   private final String domain;
   private final WelcomeRobot welcomeBot;
   private final boolean registrationDisabled;
+  private final String analyticsAccount;
 
   private final Log LOG = Log.get(UserRegistrationServlet.class);
 
   @Inject
   public UserRegistrationServlet(AccountStore accountStore,
       @Named(CoreSettings.WAVE_SERVER_DOMAIN) String domain, WelcomeRobot 
welcomeBot,
-      @Named(CoreSettings.DISABLE_REGISTRATION) boolean registrationDisabled) {
+      @Named(CoreSettings.DISABLE_REGISTRATION) boolean registrationDisabled,
+      @Named(CoreSettings.ANALYTICS_ACCOUNT) String analyticsAccount) {
     this.accountStore = accountStore;
     this.domain = domain;
     this.welcomeBot = welcomeBot;
     this.registrationDisabled = registrationDisabled;
+    this.analyticsAccount = analyticsAccount;
   }
 
   @Override
@@ -162,6 +165,6 @@ public final class UserRegistrationServl
     dest.setCharacterEncoding("UTF-8");
     dest.setContentType("text/html;charset=utf-8");
     UserRegistrationPage.write(dest.getWriter(), new GxpContext(locale), 
domain, message,
-        responseType, registrationDisabled);
+        responseType, registrationDisabled, analyticsAccount);
   }
 }

Modified: 
incubator/wave/trunk/src/org/waveprotocol/box/server/rpc/WaveClientServlet.java
URL: 
http://svn.apache.org/viewvc/incubator/wave/trunk/src/org/waveprotocol/box/server/rpc/WaveClientServlet.java?rev=1334496&r1=1334495&r2=1334496&view=diff
==============================================================================
--- 
incubator/wave/trunk/src/org/waveprotocol/box/server/rpc/WaveClientServlet.java 
(original)
+++ 
incubator/wave/trunk/src/org/waveprotocol/box/server/rpc/WaveClientServlet.java 
Sat May  5 20:42:40 2012
@@ -68,6 +68,7 @@ public class WaveClientServlet extends H
 
   private final String domain;
   private final Boolean useSocketIO;
+  private final String analyticsAccount;
   private final SessionManager sessionManager;
 
   /**
@@ -77,9 +78,11 @@ public class WaveClientServlet extends H
   public WaveClientServlet(
       @Named(CoreSettings.WAVE_SERVER_DOMAIN) String domain,
       @Named(CoreSettings.USE_SOCKETIO) Boolean useSocketIO,
+      @Named(CoreSettings.ANALYTICS_ACCOUNT) String analyticsAccount,
       SessionManager sessionManager) {
     this.domain = domain;
     this.useSocketIO = useSocketIO;
+    this.analyticsAccount = analyticsAccount;
     this.sessionManager = sessionManager;
   }
 
@@ -107,7 +110,7 @@ public class WaveClientServlet extends H
     try {
       WaveClientPage.write(response.getWriter(), new 
GxpContext(request.getLocale()),
           getSessionJson(request.getSession(false)), getClientFlags(request),
-          TopBar.getGxpClosure(username, userDomain), useSocketIO);
+          TopBar.getGxpClosure(username, userDomain), useSocketIO, 
analyticsAccount);
     } catch (IOException e) {
       LOG.warning("Failed to write GXP for request " + request, e);
       response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);

Modified: 
incubator/wave/trunk/src/org/waveprotocol/box/webclient/client/StagesProvider.java
URL: 
http://svn.apache.org/viewvc/incubator/wave/trunk/src/org/waveprotocol/box/webclient/client/StagesProvider.java?rev=1334496&r1=1334495&r2=1334496&view=diff
==============================================================================
--- 
incubator/wave/trunk/src/org/waveprotocol/box/webclient/client/StagesProvider.java
 (original)
+++ 
incubator/wave/trunk/src/org/waveprotocol/box/webclient/client/StagesProvider.java
 Sat May  5 20:42:40 2012
@@ -22,6 +22,7 @@ import com.google.gwt.dom.client.Element
 
 import org.waveprotocol.box.webclient.search.WaveContext;
 import org.waveprotocol.box.webclient.search.WaveStore;
+import org.waveprotocol.box.webclient.widget.frame.FramedPanel;
 import org.waveprotocol.wave.client.StageOne;
 import org.waveprotocol.wave.client.StageThree;
 import org.waveprotocol.wave.client.StageTwo;
@@ -35,6 +36,7 @@ import org.waveprotocol.wave.client.wave
 import org.waveprotocol.wave.client.wavepanel.impl.focus.FocusFramePresenter;
 import org.waveprotocol.wave.client.wavepanel.impl.focus.ViewTraverser;
 import org.waveprotocol.wave.client.wavepanel.impl.reader.Reader;
+import org.waveprotocol.wave.client.wavepanel.impl.title.WindowTitleHandler;
 import org.waveprotocol.wave.client.wavepanel.view.BlipView;
 import org.waveprotocol.wave.client.wavepanel.view.dom.ModelAsViewProvider;
 import org.waveprotocol.wave.client.wavepanel.view.dom.full.BlipQueueRenderer;
@@ -58,6 +60,7 @@ public class StagesProvider extends Stag
 
   private final Element wavePanelElement;
   private final Element unsavedIndicatorElement;
+  private final FramedPanel waveFrame;
   private final LogicalPanel rootPanel;
   private final WaveRef waveRef;
   private final RemoteViewServiceMultiplexer channel;
@@ -74,21 +77,24 @@ public class StagesProvider extends Stag
   private WaveContext wave;
 
   /**
-   * @param wavePanelElement The dom element to become the wave panel
-   * @param rootPanel A panel that this an ancestor of wavePanelElement. This 
is
+   * @param wavePanelElement the DOM element to become the wave panel.
+   * @param unsavedIndicatorElement the element that displays the wave saved 
state.
+   * @param rootPanel a panel that this an ancestor of wavePanelElement. This 
is
    *        used for adopting to the GWT widget tree.
+   * @param waveFrame the wave frame.
    * @param waveRef the id of the wave to open. If null, it means, create a new
    *        wave.
-   * @param channel communication channel.
+   * @param channel the communication channel.
    * @param isNewWave true if the wave is a new client-created wave
    * @param idGenerator
    */
   public StagesProvider(Element wavePanelElement, Element 
unsavedIndicatorElement,
-      LogicalPanel rootPanel, WaveRef waveRef, RemoteViewServiceMultiplexer 
channel,
+      LogicalPanel rootPanel, FramedPanel waveFrame, WaveRef waveRef, 
RemoteViewServiceMultiplexer channel,
       IdGenerator idGenerator, ProfileManager profiles, WaveStore store, 
boolean isNewWave,
       String localDomain) {
     this.wavePanelElement = wavePanelElement;
     this.unsavedIndicatorElement = unsavedIndicatorElement;
+    this.waveFrame = waveFrame;
     this.rootPanel = rootPanel;
     this.waveRef = waveRef;
     this.channel = channel;
@@ -160,6 +166,7 @@ public class StagesProvider extends Stag
     wave = new WaveContext(
         two.getWave(), two.getConversations(), two.getSupplement(), 
two.getReadMonitor());
     waveStore.add(wave);
+    install();
     whenReady.use(x);
   }
 
@@ -184,6 +191,13 @@ public class StagesProvider extends Stag
     }
   }
 
+  /**
+   * A hook to install features that are not dependent an a certain stage.
+   */
+  protected void install() {
+    WindowTitleHandler.install(waveStore, waveFrame);
+  }
+
   public void destroy() {
     if (wave != null) {
       waveStore.remove(wave);

Modified: 
incubator/wave/trunk/src/org/waveprotocol/box/webclient/client/WebClient.java
URL: 
http://svn.apache.org/viewvc/incubator/wave/trunk/src/org/waveprotocol/box/webclient/client/WebClient.java?rev=1334496&r1=1334495&r2=1334496&view=diff
==============================================================================
--- 
incubator/wave/trunk/src/org/waveprotocol/box/webclient/client/WebClient.java 
(original)
+++ 
incubator/wave/trunk/src/org/waveprotocol/box/webclient/client/WebClient.java 
Sat May  5 20:42:40 2012
@@ -303,7 +303,7 @@ public class WebClient implements EntryP
     Element holder = 
waveHolder.getElement().appendChild(Document.get().createDivElement());
     Element unsavedIndicator = 
Document.get().getElementById("unsavedStateContainer");
     StagesProvider wave =
-        new StagesProvider(holder, unsavedIndicator, waveHolder, waveRef, 
channel, idGenerator,
+        new StagesProvider(holder, unsavedIndicator, waveHolder, waveFrame, 
waveRef, channel, idGenerator,
             profiles, waveStore, isNewWave, Session.get().getDomain());
     this.wave = wave;
     wave.load(new Command() {

Added: 
incubator/wave/trunk/src/org/waveprotocol/wave/client/wavepanel/impl/title/WindowTitleHandler.java
URL: 
http://svn.apache.org/viewvc/incubator/wave/trunk/src/org/waveprotocol/wave/client/wavepanel/impl/title/WindowTitleHandler.java?rev=1334496&view=auto
==============================================================================
--- 
incubator/wave/trunk/src/org/waveprotocol/wave/client/wavepanel/impl/title/WindowTitleHandler.java
 (added)
+++ 
incubator/wave/trunk/src/org/waveprotocol/wave/client/wavepanel/impl/title/WindowTitleHandler.java
 Sat May  5 20:42:40 2012
@@ -0,0 +1,79 @@
+/**
+ * Copyright 2012 Apache Wave
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.waveprotocol.wave.client.wavepanel.impl.title;
+
+import com.google.gwt.user.client.Window;
+
+import org.waveprotocol.box.webclient.client.Session;
+import org.waveprotocol.box.webclient.search.WaveContext;
+import org.waveprotocol.box.webclient.search.WaveStore;
+import org.waveprotocol.box.webclient.widget.frame.FramedPanel;
+import org.waveprotocol.wave.model.conversation.TitleHelper;
+import org.waveprotocol.wave.model.document.Document;
+
+/**
+ * Sets the browser window title to the wave title.
+ *
+ * @author [email protected] (Yuri Zelikov)
+ */
+public final class WindowTitleHandler implements WaveStore.Listener {
+
+  private static final String APP_NAME = "WIAB";
+
+  private static final String DEFAULT_TITLE = "Communicate and collaborate in 
real-time";
+
+  private final WaveStore waveStore;
+  private final FramedPanel waveFrame;
+
+  public static WindowTitleHandler install(WaveStore waveStore, FramedPanel 
waveFrame) {
+    return new WindowTitleHandler(waveStore, waveFrame);
+  }
+
+  private WindowTitleHandler(WaveStore waveStore, FramedPanel waveFrame) {
+    this.waveStore = waveStore;
+    this.waveFrame = waveFrame;
+    init();
+  }
+
+  private void init() {
+    waveStore.addListener(this);
+  }
+
+  @Override
+  public void onOpened(WaveContext wave) {
+    Document document =
+        
wave.getConversations().getRoot().getRootThread().getFirstBlip().getContent();
+    String waveTitle = TitleHelper.extractTitle(document);
+     String windowTitle = formatTitle(waveTitle);
+    if (waveTitle == null || waveTitle.isEmpty()) {
+      windowTitle = DEFAULT_TITLE;
+    }
+    Window.setTitle(windowTitle);
+    waveFrame.setTitle(waveTitle);
+    waveFrame.setTitleText(waveTitle);
+  }
+
+  @Override
+  public void onClosed(WaveContext wave) {
+    Window.setTitle(DEFAULT_TITLE);
+  }
+
+  private String formatTitle(String title) {
+    return  title + " - " + Session.get().getAddress() + " - " + APP_NAME;
+  }
+}
\ No newline at end of file

Modified: 
incubator/wave/trunk/test/org/waveprotocol/box/server/rpc/AuthenticationServletTest.java
URL: 
http://svn.apache.org/viewvc/incubator/wave/trunk/test/org/waveprotocol/box/server/rpc/AuthenticationServletTest.java?rev=1334496&r1=1334495&r2=1334496&view=diff
==============================================================================
--- 
incubator/wave/trunk/test/org/waveprotocol/box/server/rpc/AuthenticationServletTest.java
 (original)
+++ 
incubator/wave/trunk/test/org/waveprotocol/box/server/rpc/AuthenticationServletTest.java
 Sat May  5 20:42:40 2012
@@ -73,7 +73,9 @@ public class AuthenticationServletTest e
         new HumanAccountDataImpl(USER, new 
PasswordDigest("password".toCharArray()));
     store.putAccount(account);
 
-    servlet = new AuthenticationServlet(AuthTestUtil.makeConfiguration(), 
manager, "examPLe.com");
+    servlet =
+        new AuthenticationServlet(AuthTestUtil.makeConfiguration(), manager, 
"examPLe.com",
+            "UA-someid");
     AccountStoreHolder.init(store, "eXaMple.com");
   }
 

Modified: 
incubator/wave/trunk/test/org/waveprotocol/box/server/rpc/UserRegistrationServletTest.java
URL: 
http://svn.apache.org/viewvc/incubator/wave/trunk/test/org/waveprotocol/box/server/rpc/UserRegistrationServletTest.java?rev=1334496&r1=1334495&r2=1334496&view=diff
==============================================================================
--- 
incubator/wave/trunk/test/org/waveprotocol/box/server/rpc/UserRegistrationServletTest.java
 (original)
+++ 
incubator/wave/trunk/test/org/waveprotocol/box/server/rpc/UserRegistrationServletTest.java
 Sat May  5 20:42:40 2012
@@ -17,9 +17,9 @@
 
 package org.waveprotocol.box.server.rpc;
 
+import static org.mockito.Matchers.anyString;
 import static org.mockito.Matchers.eq;
 import static org.mockito.Mockito.atLeastOnce;
-import static org.mockito.Mockito.anyString;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
@@ -38,7 +38,6 @@ import org.waveprotocol.wave.model.wave.
 
 import java.io.IOException;
 import java.io.PrintWriter;
-import java.io.StringWriter;
 import java.util.Locale;
 
 import javax.servlet.http.HttpServletRequest;
@@ -128,8 +127,10 @@ public class UserRegistrationServletTest
       HttpServletRequest req, HttpServletResponse resp, String address,
       String password, boolean disabledRegistration) throws IOException {
 
-    UserRegistrationServlet enabledServlet = new 
UserRegistrationServlet(store, "example.com", welcomeBot, false);
-    UserRegistrationServlet disabledServlet = new 
UserRegistrationServlet(store, "example.com", welcomeBot, true);
+    UserRegistrationServlet enabledServlet =
+        new UserRegistrationServlet(store, "example.com", welcomeBot, false, 
"UA-someid");
+    UserRegistrationServlet disabledServlet =
+        new UserRegistrationServlet(store, "example.com", welcomeBot, true, 
"UA-someid");
 
     when(req.getParameter("address")).thenReturn(address);
     when(req.getParameter("password")).thenReturn(password);


Reply via email to