<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre, #msg p { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[28422] trunk/WebKit/win</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/28422">28422</a></dd>
<dt>Author</dt> <dd>adachan@apple.com</dd>
<dt>Date</dt> <dd>2007-12-04 17:05:00 -0800 (Tue, 04 Dec 2007)</dd>
</dl>

<h3>Log Message</h3>
<pre>        Provide API for setting the default storage quota per database origin

        Reviewed by Jon.

        * Interfaces/IWebPreferencesPrivate.idl: added SPI to get/set default database quota
        * WebPreferenceKeysPrivate.h:
        * WebPreferences.cpp:
        (WebPreferences::initializeDefaultSettings): default database quota is 5MB
        (WebPreferences::longlongValueForKey):
        (WebPreferences::setLongLongValue):
        (WebPreferences::defaultDatabaseQuota):
        (WebPreferences::setDefaultDatabaseQuota):
        * WebPreferences.h:
        * WebView.cpp:
        (WebView::notifyPreferencesChanged): propagate default database quota change to WebCore settings.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkWebKitwinChangeLog">trunk/WebKit/win/ChangeLog</a></li>
<li><a href="#trunkWebKitwinInterfacesIWebPreferencesPrivateidl">trunk/WebKit/win/Interfaces/IWebPreferencesPrivate.idl</a></li>
<li><a href="#trunkWebKitwinWebPreferenceKeysPrivateh">trunk/WebKit/win/WebPreferenceKeysPrivate.h</a></li>
<li><a href="#trunkWebKitwinWebPreferencescpp">trunk/WebKit/win/WebPreferences.cpp</a></li>
<li><a href="#trunkWebKitwinWebPreferencesh">trunk/WebKit/win/WebPreferences.h</a></li>
<li><a href="#trunkWebKitwinWebViewcpp">trunk/WebKit/win/WebView.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkWebKitwinChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/WebKit/win/ChangeLog (28421 => 28422)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebKit/win/ChangeLog        2007-12-05 00:46:38 UTC (rev 28421)
+++ trunk/WebKit/win/ChangeLog        2007-12-05 01:05:00 UTC (rev 28422)
</span><span class="lines">@@ -1,3 +1,21 @@
</span><ins>+2007-12-04  Ada Chan  &lt;adachan@apple.com&gt;
+
+        Provide API for setting the default storage quota per database origin
+
+        Reviewed by Jon.
+
+        * Interfaces/IWebPreferencesPrivate.idl: added SPI to get/set default database quota
+        * WebPreferenceKeysPrivate.h:
+        * WebPreferences.cpp:
+        (WebPreferences::initializeDefaultSettings): default database quota is 5MB
+        (WebPreferences::longlongValueForKey):
+        (WebPreferences::setLongLongValue):
+        (WebPreferences::defaultDatabaseQuota):
+        (WebPreferences::setDefaultDatabaseQuota):
+        * WebPreferences.h:
+        * WebView.cpp:
+        (WebView::notifyPreferencesChanged): propagate default database quota change to WebCore settings.
+
</ins><span class="cx"> 2007-12-04  Kevin McCullough  &lt;kmccullough@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Reviewed by Adam and Darin.
</span></span></pre></div>
<a id="trunkWebKitwinInterfacesIWebPreferencesPrivateidl"></a>
<div class="modfile"><h4>Modified: trunk/WebKit/win/Interfaces/IWebPreferencesPrivate.idl (28421 => 28422)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebKit/win/Interfaces/IWebPreferencesPrivate.idl        2007-12-05 00:46:38 UTC (rev 28421)
+++ trunk/WebKit/win/Interfaces/IWebPreferencesPrivate.idl        2007-12-05 01:05:00 UTC (rev 28422)
</span><span class="lines">@@ -74,4 +74,7 @@
</span><span class="cx"> 
</span><span class="cx">     HRESULT setAuthorAndUserStylesEnabled([in] BOOL enabled);
</span><span class="cx">     HRESULT authorAndUserStylesEnabled([out, retval] BOOL* enabled);
</span><ins>+
+    HRESULT defaultDatabaseQuota([out, retval] unsigned long long* quota);
+    HRESULT setDefaultDatabaseQuota([in] unsigned long long quota);
</ins><span class="cx"> }
</span></span></pre></div>
<a id="trunkWebKitwinWebPreferenceKeysPrivateh"></a>
<div class="modfile"><h4>Modified: trunk/WebKit/win/WebPreferenceKeysPrivate.h (28421 => 28422)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebKit/win/WebPreferenceKeysPrivate.h        2007-12-05 00:46:38 UTC (rev 28421)
+++ trunk/WebKit/win/WebPreferenceKeysPrivate.h        2007-12-05 01:05:00 UTC (rev 28422)
</span><span class="lines">@@ -67,6 +67,7 @@
</span><span class="cx"> #define WebKitPDFDisplayModePreferenceKey &quot;WebKitPDFDisplayMode&quot;
</span><span class="cx"> #define WebKitPDFScaleFactorPreferenceKey &quot;WebKitPDFScaleFactor&quot;
</span><span class="cx"> #define WebKitEditableLinkBehaviorPreferenceKey &quot;WebKitEditableLinkBehavior&quot;
</span><ins>+#define WebKitDefaultDatabaseQuotaKey &quot;WebKitDefaultDatabaseQuota&quot;
</ins><span class="cx"> 
</span><span class="cx"> // Window display is throttled to 60 frames per second if WebKitThrottleWindowDisplayPreferenceKey
</span><span class="cx"> // is set to YES.  The window display throttle is OFF by default for compatibility with Mac OS X
</span></span></pre></div>
<a id="trunkWebKitwinWebPreferencescpp"></a>
<div class="modfile"><h4>Modified: trunk/WebKit/win/WebPreferences.cpp (28421 => 28422)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebKit/win/WebPreferences.cpp        2007-12-05 00:46:38 UTC (rev 28421)
+++ trunk/WebKit/win/WebPreferences.cpp        2007-12-05 01:05:00 UTC (rev 28422)
</span><span class="lines">@@ -191,6 +191,7 @@
</span><span class="cx"> 
</span><span class="cx">     RetainPtr&lt;CFStringRef&gt; cacheModelRef(AdoptCF, CFStringCreateWithFormat(0, 0, CFSTR(&quot;%d&quot;), WebCacheModelDocumentViewer));
</span><span class="cx">     CFDictionaryAddValue(defaults, CFSTR(WebKitCacheModelPreferenceKey), cacheModelRef.get());
</span><ins>+    CFDictionaryAddValue(defaults, CFSTR(WebKitDefaultDatabaseQuotaKey), CFSTR(&quot;5242880&quot;));     // 5 MB
</ins><span class="cx"> 
</span><span class="cx">     CFDictionaryAddValue(defaults, CFSTR(WebKitAuthorAndUserStylesEnabledPreferenceKey), kCFBooleanTrue);
</span><span class="cx"> 
</span><span class="lines">@@ -280,6 +281,28 @@
</span><span class="cx">     return 0.0;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+LONGLONG WebPreferences::longlongValueForKey(CFStringRef key)
+{
+    CFTypeRef cfVal = (CFTypeRef) valueForKey(key);
+    if (!cfVal)
+        return 0;
+
+    CFTypeID cfType = CFGetTypeID(cfVal);
+    if (cfType == CFStringGetTypeID())
+        return (LONGLONG) CFStringGetIntValue((CFStringRef)cfVal);
+    else if (cfType == CFBooleanGetTypeID()) {
+        Boolean boolVal = CFBooleanGetValue((CFBooleanRef)cfVal);
+        return (boolVal) ? 1 : 0;
+    }
+    else if (cfType == CFNumberGetTypeID()) {
+        LONGLONG val = 0;
+        CFNumberGetValue((CFNumberRef)cfVal, kCFNumberLongLongType, &amp;val);
+        return val;
+    }
+
+    return 0;
+}
+
</ins><span class="cx"> void WebPreferences::setStringValue(CFStringRef key, LPCTSTR value)
</span><span class="cx"> {
</span><span class="cx">     BSTR val = stringValueForKey(key);
</span><span class="lines">@@ -321,6 +344,19 @@
</span><span class="cx">     postPreferencesChangesNotification();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void WebPreferences::setLongLongValue(CFStringRef key, LONGLONG value)
+{
+    if (longlongValueForKey(key) == value)
+        return;
+
+    RetainPtr&lt;CFNumberRef&gt; valueRef(AdoptCF, CFNumberCreate(0, kCFNumberLongLongType, &amp;value));
+    CFDictionarySetValue(m_privatePrefs.get(), key, valueRef.get());
+    if (m_autoSaves)
+        save();
+
+    postPreferencesChangesNotification();
+}
+
</ins><span class="cx"> BSTR WebPreferences::webPreferencesChangedNotification()
</span><span class="cx"> {
</span><span class="cx">     static BSTR webPreferencesChangedNotification = SysAllocString(WebPreferencesChangedNotification);
</span><span class="lines">@@ -1095,6 +1131,28 @@
</span><span class="cx">     return S_OK;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+HRESULT STDMETHODCALLTYPE WebPreferences::defaultDatabaseQuota(unsigned long long* quota)
+{
+    if (!quota)
+        return E_POINTER;
+
+    long long value = longlongValueForKey(CFSTR(WebKitDefaultDatabaseQuotaKey));
+    if (value &lt; 0 || value &gt; LLONG_MAX) {
+        value = 0;
+        setDefaultDatabaseQuota(0);
+    }
+    *quota = value;
+    return S_OK;
+}
+
+HRESULT STDMETHODCALLTYPE WebPreferences::setDefaultDatabaseQuota(unsigned long long quota)
+{
+    if (quota &gt; LLONG_MAX)
+        quota = 0;
+    setLongLongValue(CFSTR(WebKitDefaultDatabaseQuotaKey), quota);
+    return S_OK;
+}
+
</ins><span class="cx"> HRESULT STDMETHODCALLTYPE WebPreferences::setAuthorAndUserStylesEnabled(BOOL enabled)
</span><span class="cx"> {
</span><span class="cx">     setBoolValue(CFSTR(WebKitAuthorAndUserStylesEnabledPreferenceKey), enabled);
</span></span></pre></div>
<a id="trunkWebKitwinWebPreferencesh"></a>
<div class="modfile"><h4>Modified: trunk/WebKit/win/WebPreferences.h (28421 => 28422)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebKit/win/WebPreferences.h        2007-12-05 00:46:38 UTC (rev 28421)
+++ trunk/WebKit/win/WebPreferences.h        2007-12-05 01:05:00 UTC (rev 28422)
</span><span class="lines">@@ -288,6 +288,12 @@
</span><span class="cx">      virtual HRESULT STDMETHODCALLTYPE automaticallyDetectsCacheModel(
</span><span class="cx">          /* [out, retval] */ BOOL* automaticallyDetectsCacheModel);
</span><span class="cx"> 
</span><ins>+    virtual HRESULT STDMETHODCALLTYPE defaultDatabaseQuota(
+        /* [retval][out] */ unsigned long long *quota);
+
+    virtual HRESULT STDMETHODCALLTYPE setDefaultDatabaseQuota( 
+        /* [in] */ unsigned long long quota);
+
</ins><span class="cx">     virtual HRESULT STDMETHODCALLTYPE setAuthorAndUserStylesEnabled(BOOL);
</span><span class="cx">     virtual HRESULT STDMETHODCALLTYPE authorAndUserStylesEnabled(BOOL*);
</span><span class="cx"> 
</span><span class="lines">@@ -321,9 +327,11 @@
</span><span class="cx">     int integerValueForKey(CFStringRef key);
</span><span class="cx">     BOOL boolValueForKey(CFStringRef key);
</span><span class="cx">     float floatValueForKey(CFStringRef key);
</span><ins>+    LONGLONG longlongValueForKey(CFStringRef key);
</ins><span class="cx">     void setStringValue(CFStringRef key, LPCTSTR value);
</span><span class="cx">     void setIntegerValue(CFStringRef key, int value);
</span><span class="cx">     void setBoolValue(CFStringRef key, BOOL value);
</span><ins>+    void setLongLongValue(CFStringRef key, LONGLONG value);
</ins><span class="cx">     static WebPreferences* getInstanceForIdentifier(BSTR identifier);
</span><span class="cx">     static void initializeDefaultSettings();
</span><span class="cx">     void save();
</span></span></pre></div>
<a id="trunkWebKitwinWebViewcpp"></a>
<div class="modfile"><h4>Modified: trunk/WebKit/win/WebView.cpp (28421 => 28422)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebKit/win/WebView.cpp        2007-12-05 00:46:38 UTC (rev 28421)
+++ trunk/WebKit/win/WebView.cpp        2007-12-05 01:05:00 UTC (rev 28422)
</span><span class="lines">@@ -3786,6 +3786,12 @@
</span><span class="cx"> 
</span><span class="cx">     COMPtr&lt;IWebPreferencesPrivate&gt; prefsPrivate(Query, preferences);
</span><span class="cx">     if (prefsPrivate) {
</span><ins>+        unsigned long long defaultQuota = 0;
+        hr = prefsPrivate-&gt;defaultDatabaseQuota(&amp;defaultQuota);
+        if (FAILED(hr))
+            return hr;
+        settings-&gt;setDefaultDatabaseOriginQuota(defaultQuota);
+
</ins><span class="cx">         hr = prefsPrivate-&gt;authorAndUserStylesEnabled(&amp;enabled);
</span><span class="cx">         if (FAILED(hr))
</span><span class="cx">             return hr;
</span></span></pre>
</div>
</div>

</body>
</html>