MediaStream API: Adding a username field to the RTCIceServer dictionary
This has been discussed and approved on the W3C email list. The main reason
is the TURN URI Spec will(has) removed the username component.

Review URL: https://chromiumcodereview.appspot.com/14644003

git-svn-id: svn://svn.chromium.org/blink/trunk@149442 bbb929c8-8fbe-4397-9dbb-9b2b20218538
diff --git a/Source/Platform/chromium/public/WebRTCConfiguration.h b/Source/Platform/chromium/public/WebRTCConfiguration.h
index e99c14d..e641ba7 100644
--- a/Source/Platform/chromium/public/WebRTCConfiguration.h
+++ b/Source/Platform/chromium/public/WebRTCConfiguration.h
@@ -63,6 +63,7 @@
     bool isNull() const { return m_private.isNull(); }
 
     WEBKIT_EXPORT WebURL uri() const;
+    WEBKIT_EXPORT WebString username() const;
     WEBKIT_EXPORT WebString credential() const;
 
 #if WEBKIT_IMPLEMENTATION
diff --git a/Source/core/platform/chromium/support/WebRTCConfiguration.cpp b/Source/core/platform/chromium/support/WebRTCConfiguration.cpp
index 2109927..f4fbe37 100644
--- a/Source/core/platform/chromium/support/WebRTCConfiguration.cpp
+++ b/Source/core/platform/chromium/support/WebRTCConfiguration.cpp
@@ -64,6 +64,12 @@
     return m_private->uri();
 }
 
+WebString WebRTCICEServer::username() const
+{
+    ASSERT(!isNull());
+    return m_private->username();
+}
+
 WebString WebRTCICEServer::credential() const
 {
     ASSERT(!isNull());
diff --git a/Source/core/platform/mediastream/RTCConfiguration.h b/Source/core/platform/mediastream/RTCConfiguration.h
index aab97d9..6b3a90a 100644
--- a/Source/core/platform/mediastream/RTCConfiguration.h
+++ b/Source/core/platform/mediastream/RTCConfiguration.h
@@ -43,23 +43,26 @@
 
 class RTCIceServer : public RefCounted<RTCIceServer> {
 public:
-    static PassRefPtr<RTCIceServer> create(const KURL& uri, const String& credential)
+    static PassRefPtr<RTCIceServer> create(const KURL& uri, const String& username, const String& credential)
     {
-        return adoptRef(new RTCIceServer(uri, credential));
+        return adoptRef(new RTCIceServer(uri, username, credential));
     }
     virtual ~RTCIceServer() { }
 
     const KURL& uri() { return m_uri; }
+    const String& username() { return m_username; }
     const String& credential() { return m_credential; }
 
 private:
-    RTCIceServer(const KURL& uri, const String& credential)
+    RTCIceServer(const KURL& uri, const String& username, const String& credential)
         : m_uri(uri)
+        , m_username(username)
         , m_credential(credential)
     {
     }
 
     KURL m_uri;
+    String m_username;
     String m_credential;
 };
 
diff --git a/Source/modules/mediastream/RTCPeerConnection.cpp b/Source/modules/mediastream/RTCPeerConnection.cpp
index b2e96d7..d2c5f6e 100644
--- a/Source/modules/mediastream/RTCPeerConnection.cpp
+++ b/Source/modules/mediastream/RTCPeerConnection.cpp
@@ -93,7 +93,7 @@
             return 0;
         }
 
-        String urlString, credential;
+        String urlString, username, credential;
         ok = iceServer.get("url", urlString);
         if (!ok) {
             ec = TYPE_MISMATCH_ERR;
@@ -105,9 +105,10 @@
             return 0;
         }
 
+        iceServer.get("username", username);
         iceServer.get("credential", credential);
 
-        rtcConfiguration->appendServer(RTCIceServer::create(url, credential));
+        rtcConfiguration->appendServer(RTCIceServer::create(url, username, credential));
     }
 
     return rtcConfiguration.release();