Title: [128312] trunk/Source/WebCore
Revision
128312
Author
[email protected]
Date
2012-09-12 08:21:46 -0700 (Wed, 12 Sep 2012)

Log Message

[BlackBerry] Use own instance of CertMgrWrapper in BlackBerry CredentialBackingStore.
https://bugs.webkit.org/show_bug.cgi?id=96457
Internal PR: 205769

Internally reviewed by George Staikos, Jonathan Dong.
Patch by Lianghui Chen <[email protected]> on 2012-09-12
Reviewed by George Staikos.

CertMgrWrapper in BlackBerry platform layer has been changed from
singleton to normal class, every user of it need to create its own
instance now.

No new tests for platform specific interface change.

* platform/network/blackberry/CredentialBackingStore.cpp:
(WebCore::CredentialBackingStore::CredentialBackingStore):
(WebCore::CredentialBackingStore::~CredentialBackingStore):
(WebCore::CredentialBackingStore::addLogin):
(WebCore::CredentialBackingStore::updateLogin):
(WebCore::CredentialBackingStore::getLogin):
(WebCore::CredentialBackingStore::certMgrWrapper):
(WebCore):
* platform/network/blackberry/CredentialBackingStore.h:
(Platform):
(CredentialBackingStore):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (128311 => 128312)


--- trunk/Source/WebCore/ChangeLog	2012-09-12 15:08:07 UTC (rev 128311)
+++ trunk/Source/WebCore/ChangeLog	2012-09-12 15:21:46 UTC (rev 128312)
@@ -1,3 +1,30 @@
+2012-09-12  Lianghui Chen  <[email protected]>
+
+        [BlackBerry] Use own instance of CertMgrWrapper in BlackBerry CredentialBackingStore.
+        https://bugs.webkit.org/show_bug.cgi?id=96457
+        Internal PR: 205769
+
+        Internally reviewed by George Staikos, Jonathan Dong.
+        Reviewed by George Staikos.
+
+        CertMgrWrapper in BlackBerry platform layer has been changed from
+        singleton to normal class, every user of it need to create its own
+        instance now.
+
+        No new tests for platform specific interface change.
+
+        * platform/network/blackberry/CredentialBackingStore.cpp:
+        (WebCore::CredentialBackingStore::CredentialBackingStore):
+        (WebCore::CredentialBackingStore::~CredentialBackingStore):
+        (WebCore::CredentialBackingStore::addLogin):
+        (WebCore::CredentialBackingStore::updateLogin):
+        (WebCore::CredentialBackingStore::getLogin):
+        (WebCore::CredentialBackingStore::certMgrWrapper):
+        (WebCore):
+        * platform/network/blackberry/CredentialBackingStore.h:
+        (Platform):
+        (CredentialBackingStore):
+
 2012-09-12  Kenneth Rohde Christiansen  <[email protected]>
 
         [EFL] Avoid manual memory management in RenderThemeEfl

Modified: trunk/Source/WebCore/platform/network/blackberry/CredentialBackingStore.cpp (128311 => 128312)


--- trunk/Source/WebCore/platform/network/blackberry/CredentialBackingStore.cpp	2012-09-12 15:08:07 UTC (rev 128311)
+++ trunk/Source/WebCore/platform/network/blackberry/CredentialBackingStore.cpp	2012-09-12 15:21:46 UTC (rev 128312)
@@ -69,12 +69,14 @@
     , m_hasNeverRememberStatement(0)
     , m_getNeverRememberStatement(0)
     , m_removeNeverRememberStatement(0)
-    , m_usingCertManager(BlackBerry::Platform::CertMgrWrapper::instance()->isReady())
+    , m_certMgrWrapper(0)
 {
 }
 
 CredentialBackingStore::~CredentialBackingStore()
 {
+    delete m_certMgrWrapper;
+    m_certMgrWrapper = 0;
     delete m_addLoginStatement;
     m_addLoginStatement = 0;
     delete m_updateLoginStatement;
@@ -184,17 +186,17 @@
     m_addLoginStatement->bindText(5, protectionSpace.realm());
     m_addLoginStatement->bindInt(6, static_cast<int>(protectionSpace.authenticationScheme()));
     m_addLoginStatement->bindText(7, credential.user());
-    m_addLoginStatement->bindBlob(8, m_usingCertManager ? "" : encryptedString(credential.password()));
+    m_addLoginStatement->bindBlob(8, certMgrWrapper()->isReady() ? "" : encryptedString(credential.password()));
 
     int result = m_addLoginStatement->step();
     m_addLoginStatement->reset();
     HANDLE_SQL_EXEC_FAILURE(result != SQLResultDone, false,
         "Failed to add login info into table logins - %i", result);
 
-    if (!m_usingCertManager)
+    if (!certMgrWrapper()->isReady())
         return true;
     unsigned hash = hashCredentialInfo(url.string(), protectionSpace, credential.user());
-    return BlackBerry::Platform::CertMgrWrapper::instance()->savePassword(hash, encryptedString(credential.password()).latin1().data());
+    return certMgrWrapper()->savePassword(hash, encryptedString(credential.password()).latin1().data());
 }
 
 bool CredentialBackingStore::updateLogin(const KURL& url, const ProtectionSpace& protectionSpace, const Credential& credential)
@@ -206,7 +208,7 @@
         return false;
 
     m_updateLoginStatement->bindText(1, credential.user());
-    m_updateLoginStatement->bindBlob(2, m_usingCertManager ? "" : encryptedString(credential.password()));
+    m_updateLoginStatement->bindBlob(2, certMgrWrapper()->isReady() ? "" : encryptedString(credential.password()));
     m_updateLoginStatement->bindText(3, url.string());
     m_updateLoginStatement->bindText(4, protectionSpace.host());
     m_updateLoginStatement->bindInt(5, protectionSpace.port());
@@ -219,10 +221,10 @@
     HANDLE_SQL_EXEC_FAILURE(result != SQLResultDone, false,
         "Failed to update login info in table logins - %i", result);
 
-    if (!m_usingCertManager)
+    if (!certMgrWrapper()->isReady())
         return true;
     unsigned hash = hashCredentialInfo(url.string(), protectionSpace, credential.user());
-    return BlackBerry::Platform::CertMgrWrapper::instance()->savePassword(hash, encryptedString(credential.password()).latin1().data());
+    return certMgrWrapper()->savePassword(hash, encryptedString(credential.password()).latin1().data());
 }
 
 bool CredentialBackingStore::hasLogin(const KURL& url, const ProtectionSpace& protectionSpace)
@@ -267,18 +269,18 @@
 
     int result = m_getLoginStatement->step();
     String username = m_getLoginStatement->getColumnText(0);
-    String password = m_usingCertManager ? "" : m_getLoginStatement->getColumnBlobAsString(1);
+    String password = certMgrWrapper()->isReady() ? "" : m_getLoginStatement->getColumnBlobAsString(1);
     String url = ""
     m_getLoginStatement->reset();
     HANDLE_SQL_EXEC_FAILURE(result != SQLResultRow, Credential(),
         "Failed to execute select login info from table logins in getLogin - %i", result);
 
-    if (!m_usingCertManager)
+    if (!certMgrWrapper()->isReady())
         return Credential(username, decryptedString(password), CredentialPersistencePermanent);
 
     unsigned hash = hashCredentialInfo(url, protectionSpace, username);
     std::string passwordBlob;
-    if (!BlackBerry::Platform::CertMgrWrapper::instance()->getPassword(hash, passwordBlob))
+    if (!certMgrWrapper()->getPassword(hash, passwordBlob))
         return Credential();
     return Credential(username, decryptedString(passwordBlob.c_str()), CredentialPersistencePermanent);
 }
@@ -295,7 +297,7 @@
 
     int result = m_getLoginByURLStatement->step();
     String username = m_getLoginByURLStatement->getColumnText(0);
-    String password = m_usingCertManager ? "" : m_getLoginByURLStatement->getColumnBlobAsString(1);
+    String password = certMgrWrapper()->isReady() ? "" : m_getLoginByURLStatement->getColumnBlobAsString(1);
     String host = m_getLoginByURLStatement->getColumnText(2);
     int port = m_getLoginByURLStatement->getColumnInt(3);
     int serviceType = m_getLoginByURLStatement->getColumnInt(4);
@@ -305,14 +307,14 @@
     HANDLE_SQL_EXEC_FAILURE(result != SQLResultRow, Credential(),
         "Failed to execute select login info from table logins in getLoginByURL - %i", result);
 
-    if (!m_usingCertManager)
+    if (!certMgrWrapper()->isReady())
         return Credential(username, decryptedString(password), CredentialPersistencePermanent);
 
     ProtectionSpace protectionSpace(host, port, static_cast<ProtectionSpaceServerType>(serviceType),
                                     realm, static_cast<ProtectionSpaceAuthenticationScheme>(authenticationScheme));
     unsigned hash = hashCredentialInfo(url, protectionSpace, username);
     std::string passwordBlob;
-    if (!BlackBerry::Platform::CertMgrWrapper::instance()->getPassword(hash, passwordBlob))
+    if (!certMgrWrapper()->getPassword(hash, passwordBlob))
         return Credential();
     return Credential(username, decryptedString(passwordBlob.c_str()), CredentialPersistencePermanent);
 }
@@ -469,6 +471,15 @@
     return String(plainText.c_str());
 }
 
+BlackBerry::Platform::CertMgrWrapper* CredentialBackingStore::certMgrWrapper()
+{
+    if (!m_certMgrWrapper)
+        m_certMgrWrapper = new BlackBerry::Platform::CertMgrWrapper();
+
+    return m_certMgrWrapper;
+}
+
+
 } // namespace WebCore
 
 #endif // ENABLE(BLACKBERRY_CREDENTIAL_PERSIST)

Modified: trunk/Source/WebCore/platform/network/blackberry/CredentialBackingStore.h (128311 => 128312)


--- trunk/Source/WebCore/platform/network/blackberry/CredentialBackingStore.h	2012-09-12 15:08:07 UTC (rev 128311)
+++ trunk/Source/WebCore/platform/network/blackberry/CredentialBackingStore.h	2012-09-12 15:21:46 UTC (rev 128312)
@@ -24,6 +24,12 @@
 #include "Credential.h"
 #include "SQLiteDatabase.h"
 
+namespace BlackBerry {
+namespace Platform {
+class CertMgrWrapper;
+}
+}
+
 namespace WebCore {
 
 class KURL;
@@ -53,6 +59,8 @@
     String encryptedString(const String& plainText) const;
     String decryptedString(const String& cipherText) const;
 
+    BlackBerry::Platform::CertMgrWrapper* certMgrWrapper();
+
     SQLiteDatabase m_database;
     SQLiteStatement* m_addLoginStatement;
     SQLiteStatement* m_updateLoginStatement;
@@ -65,7 +73,7 @@
     SQLiteStatement* m_getNeverRememberStatement;
     SQLiteStatement* m_removeNeverRememberStatement;
 
-    bool m_usingCertManager;
+    BlackBerry::Platform::CertMgrWrapper* m_certMgrWrapper;
 };
 
 CredentialBackingStore& credentialBackingStore();
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to