OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "content/renderer/dom_storage/dom_storage_dispatcher.h" |
| 6 |
| 7 #include "content/common/dom_storage_messages.h" |
| 8 #include "content/renderer/dom_storage/webstoragearea_impl.h" |
| 9 #include "content/renderer/dom_storage/webstoragenamespace_impl.h" |
| 10 #include "content/renderer/render_thread_impl.h" |
| 11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebStorageEventDispat
cher.h" |
| 12 |
| 13 bool DomStorageDispatcher::OnMessageReceived(const IPC::Message& msg) { |
| 14 bool handled = true; |
| 15 IPC_BEGIN_MESSAGE_MAP(DomStorageDispatcher, msg) |
| 16 IPC_MESSAGE_HANDLER(DOMStorageMsg_Event, OnStorageEvent) |
| 17 IPC_MESSAGE_UNHANDLED(handled = false) |
| 18 IPC_END_MESSAGE_MAP() |
| 19 return handled; |
| 20 } |
| 21 |
| 22 void DomStorageDispatcher::OnStorageEvent( |
| 23 const DOMStorageMsg_Event_Params& params) { |
| 24 RenderThreadImpl::current()->EnsureWebKitInitialized(); |
| 25 |
| 26 bool originated_in_process = params.connection_id != 0; |
| 27 WebStorageAreaImpl* originating_area = NULL; |
| 28 if (originated_in_process) { |
| 29 originating_area = WebStorageAreaImpl::FromConnectionId( |
| 30 params.connection_id); |
| 31 } |
| 32 |
| 33 if (params.namespace_id == dom_storage::kLocalStorageNamespaceId) { |
| 34 WebKit::WebStorageEventDispatcher::dispatchLocalStorageEvent( |
| 35 params.key, |
| 36 params.old_value, |
| 37 params.new_value, |
| 38 params.origin, |
| 39 params.page_url, |
| 40 originating_area, |
| 41 originated_in_process); |
| 42 } else if (originated_in_process) { |
| 43 // TODO(michaeln): For now, we only raise session storage events into the |
| 44 // process which caused the event to occur. However there are cases where |
| 45 // sessions can span process boundaries, so there are correctness issues. |
| 46 WebStorageNamespaceImpl |
| 47 session_namespace_for_event_dispatch(params.namespace_id); |
| 48 WebKit::WebStorageEventDispatcher::dispatchSessionStorageEvent( |
| 49 params.key, |
| 50 params.old_value, |
| 51 params.new_value, |
| 52 params.origin, |
| 53 params.page_url, |
| 54 session_namespace_for_event_dispatch, |
| 55 originating_area, |
| 56 originated_in_process); |
| 57 } |
| 58 } |
OLD | NEW |