diff options
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/in_process_webkit/dom_storage_area.cc | 9 | ||||
-rw-r--r-- | chrome/browser/in_process_webkit/dom_storage_area.h | 8 | ||||
-rw-r--r-- | chrome/browser/in_process_webkit/dom_storage_dispatcher_host.cc | 10 | ||||
-rw-r--r-- | chrome/common/render_messages.h | 36 | ||||
-rw-r--r-- | chrome/common/render_messages_internal.h | 2 | ||||
-rw-r--r-- | chrome/renderer/renderer_webstoragearea_impl.cc | 15 | ||||
-rw-r--r-- | chrome/renderer/renderer_webstoragearea_impl.h | 2 |
7 files changed, 64 insertions, 18 deletions
diff --git a/chrome/browser/in_process_webkit/dom_storage_area.cc b/chrome/browser/in_process_webkit/dom_storage_area.cc index 99f24c6..a3a031b 100644 --- a/chrome/browser/in_process_webkit/dom_storage_area.cc +++ b/chrome/browser/in_process_webkit/dom_storage_area.cc @@ -57,15 +57,16 @@ NullableString16 DOMStorageArea::GetItem(const string16& key) { } NullableString16 DOMStorageArea::SetItem( - const string16& key, const string16& value, bool* quota_exception) { + const string16& key, const string16& value, + WebStorageArea::Result* result) { if (!CheckContentSetting(key, value)) { - *quota_exception = true; - return NullableString16(true); // Ignored if exception is true. + *result = WebStorageArea::ResultBlockedByPolicy; + return NullableString16(true); // Ignored if the content was blocked. } CreateWebStorageAreaIfNecessary(); WebString old_value; - storage_area_->setItem(key, value, WebURL(), *quota_exception, old_value); + storage_area_->setItem(key, value, WebURL(), *result, old_value); return old_value; } diff --git a/chrome/browser/in_process_webkit/dom_storage_area.h b/chrome/browser/in_process_webkit/dom_storage_area.h index 01c068c..4cba146 100644 --- a/chrome/browser/in_process_webkit/dom_storage_area.h +++ b/chrome/browser/in_process_webkit/dom_storage_area.h @@ -11,15 +11,13 @@ #include "base/nullable_string16.h" #include "base/ref_counted.h" #include "base/scoped_ptr.h" +#include "chrome/common/dom_storage_common.h" #include "googleurl/src/gurl.h" +#include "third_party/WebKit/WebKit/chromium/public/WebStorageArea.h" class DOMStorageNamespace; class HostContentSettingsMap; -namespace WebKit { -class WebStorageArea; -} - // Only use on the WebKit thread. DOMStorageNamespace manages our registration // with DOMStorageContext. class DOMStorageArea { @@ -34,7 +32,7 @@ class DOMStorageArea { NullableString16 Key(unsigned index); NullableString16 GetItem(const string16& key); NullableString16 SetItem(const string16& key, const string16& value, - bool* quota_exception); + WebKit::WebStorageArea::Result* result); NullableString16 RemoveItem(const string16& key); bool Clear(); void PurgeMemory(); diff --git a/chrome/browser/in_process_webkit/dom_storage_dispatcher_host.cc b/chrome/browser/in_process_webkit/dom_storage_dispatcher_host.cc index dc5835a..ccd9e97 100644 --- a/chrome/browser/in_process_webkit/dom_storage_dispatcher_host.cc +++ b/chrome/browser/in_process_webkit/dom_storage_dispatcher_host.cc @@ -16,6 +16,8 @@ #include "chrome/common/render_messages.h" #include "googleurl/src/gurl.h" +using WebKit::WebStorageArea; + DOMStorageDispatcherHost* DOMStorageDispatcherHost::storage_event_host_ = NULL; const GURL* DOMStorageDispatcherHost::storage_event_url_ = NULL; @@ -259,7 +261,6 @@ void DOMStorageDispatcherHost::OnSetItem( } DCHECK(ChromeThread::CurrentlyOn(ChromeThread::WEBKIT)); - bool quota_exception = false; DOMStorageArea* storage_area = Context()->GetStorageArea(storage_area_id); if (!storage_area) { BrowserRenderProcessHost::BadMessageTerminateProcess( @@ -268,10 +269,9 @@ void DOMStorageDispatcherHost::OnSetItem( } ScopedStorageEventContext scope(this, &url); - NullableString16 old_value = storage_area->SetItem(key, value, - "a_exception); - ViewHostMsg_DOMStorageSetItem::WriteReplyParams(reply_msg, quota_exception, - old_value); + WebStorageArea::Result result; + NullableString16 old_value = storage_area->SetItem(key, value, &result); + ViewHostMsg_DOMStorageSetItem::WriteReplyParams(reply_msg, result, old_value); Send(reply_msg); } diff --git a/chrome/common/render_messages.h b/chrome/common/render_messages.h index cd6dd75..008e53e 100644 --- a/chrome/common/render_messages.h +++ b/chrome/common/render_messages.h @@ -35,6 +35,7 @@ #include "media/audio/audio_output.h" #include "net/base/upload_data.h" #include "net/http/http_response_headers.h" +#include "third_party/WebKit/WebKit/chromium/public/WebStorageArea.h" #include "webkit/appcache/appcache_interfaces.h" #include "webkit/glue/context_menu.h" #include "webkit/glue/form_data.h" @@ -2317,6 +2318,41 @@ struct ParamTraits<DOMStorageType> { } }; +// Traits for WebKit::WebStorageArea::Result enum. +template <> +struct ParamTraits<WebKit::WebStorageArea::Result> { + typedef WebKit::WebStorageArea::Result param_type; + static void Write(Message* m, const param_type& p) { + m->WriteInt(p); + } + static bool Read(const Message* m, void** iter, param_type* p) { + int type; + if (!m->ReadInt(iter, &type)) + return false; + *p = static_cast<param_type>(type); + return true; + } + static void Log(const param_type& p, std::wstring* l) { + std::wstring control; + switch (p) { + case WebKit::WebStorageArea::ResultOK: + control = L"WebKit::WebStorageArea::ResultOK"; + break; + case WebKit::WebStorageArea::ResultBlockedByQuota: + control = L"WebKit::WebStorageArea::ResultBlockedByQuota"; + break; + case WebKit::WebStorageArea::ResultBlockedByPolicy: + control = L"WebKit::WebStorageArea::ResultBlockedByPolicy"; + break; + default: + NOTIMPLEMENTED(); + control = L"UNKNOWN"; + break; + } + LogParam(control, l); + } +}; + // Traits for ViewMsg_DOMStorageEvent_Params. template <> struct ParamTraits<ViewMsg_DOMStorageEvent_Params> { diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h index 7bd4ef9..90500d1 100644 --- a/chrome/common/render_messages_internal.h +++ b/chrome/common/render_messages_internal.h @@ -1969,7 +1969,7 @@ IPC_BEGIN_MESSAGES(ViewHost) string16 /* key */, string16 /* value */, GURL /* url */, - bool /* quota_exception */, + WebKit::WebStorageArea::Result /* result */, NullableString16 /* old_value */) // Remove the value associated with a key in a storage area. diff --git a/chrome/renderer/renderer_webstoragearea_impl.cc b/chrome/renderer/renderer_webstoragearea_impl.cc index 43caed5..20ce740 100644 --- a/chrome/renderer/renderer_webstoragearea_impl.cc +++ b/chrome/renderer/renderer_webstoragearea_impl.cc @@ -6,8 +6,11 @@ #include "chrome/common/render_messages.h" #include "chrome/renderer/render_thread.h" +#include "chrome/renderer/render_view.h" +#include "third_party/WebKit/WebKit/chromium/public/WebFrame.h" #include "third_party/WebKit/WebKit/chromium/public/WebURL.h" +using WebKit::WebFrame; using WebKit::WebString; using WebKit::WebURL; @@ -44,12 +47,20 @@ WebString RendererWebStorageAreaImpl::getItem(const WebString& key) { void RendererWebStorageAreaImpl::setItem( const WebString& key, const WebString& value, const WebURL& url, - bool& quota_exception, WebString& old_value_webkit) { + WebStorageArea::Result& result, WebString& old_value_webkit) { NullableString16 old_value; RenderThread::current()->Send( new ViewHostMsg_DOMStorageSetItem(storage_area_id_, key, value, url, - "a_exception, &old_value)); + &result, &old_value)); old_value_webkit = old_value; + + if (result == WebStorageArea::ResultBlockedByPolicy) { + RenderView* view = + RenderView::FromWebView(WebFrame::frameForCurrentContext()->view()); + DCHECK(view); + RenderThread::current()->Send(new ViewHostMsg_ContentBlocked( + view->routing_id(), CONTENT_SETTINGS_TYPE_COOKIES)); + } } void RendererWebStorageAreaImpl::removeItem( diff --git a/chrome/renderer/renderer_webstoragearea_impl.h b/chrome/renderer/renderer_webstoragearea_impl.h index 5ce935f..7bd6ff1 100644 --- a/chrome/renderer/renderer_webstoragearea_impl.h +++ b/chrome/renderer/renderer_webstoragearea_impl.h @@ -22,7 +22,7 @@ class RendererWebStorageAreaImpl : public WebKit::WebStorageArea { virtual WebKit::WebString getItem(const WebKit::WebString& key); virtual void setItem( const WebKit::WebString& key, const WebKit::WebString& value, - const WebKit::WebURL& url, bool& quota_exception, + const WebKit::WebURL& url, WebStorageArea::Result& result, WebKit::WebString& old_value); virtual void removeItem( const WebKit::WebString& key, const WebKit::WebURL& url, |