diff options
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/in_process_webkit/indexed_db_dispatcher_host.cc | 65 | ||||
-rw-r--r-- | chrome/browser/in_process_webkit/indexed_db_dispatcher_host.h | 11 | ||||
-rw-r--r-- | chrome/common/indexed_db_messages.h | 16 | ||||
-rw-r--r-- | chrome/renderer/indexed_db_dispatcher.cc | 22 | ||||
-rw-r--r-- | chrome/renderer/indexed_db_dispatcher.h | 6 | ||||
-rw-r--r-- | chrome/renderer/renderer_webidbfactory_impl.cc | 19 | ||||
-rw-r--r-- | chrome/renderer/renderer_webidbfactory_impl.h | 8 |
7 files changed, 129 insertions, 18 deletions
diff --git a/chrome/browser/in_process_webkit/indexed_db_dispatcher_host.cc b/chrome/browser/in_process_webkit/indexed_db_dispatcher_host.cc index fad4720..bf3da6c 100644 --- a/chrome/browser/in_process_webkit/indexed_db_dispatcher_host.cc +++ b/chrome/browser/in_process_webkit/indexed_db_dispatcher_host.cc @@ -123,6 +123,8 @@ bool IndexedDBDispatcherHost::OnMessageReceived(const IPC::Message& message, handled = true; IPC_BEGIN_MESSAGE_MAP_EX(IndexedDBDispatcherHost, message, *message_was_ok) IPC_MESSAGE_HANDLER(IndexedDBHostMsg_FactoryOpen, OnIDBFactoryOpen) + IPC_MESSAGE_HANDLER(IndexedDBHostMsg_FactoryDeleteDatabase, + OnIDBFactoryDeleteDatabase) IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP() } @@ -176,36 +178,47 @@ int32 IndexedDBDispatcherHost::Add(WebIDBTransaction* idb_transaction) { return id; } -void IndexedDBDispatcherHost::OnIDBFactoryOpen( - const IndexedDBHostMsg_FactoryOpen_Params& params) { - FilePath base_path = webkit_context_->data_path(); - FilePath indexed_db_path; - if (!base_path.empty()) { - indexed_db_path = base_path.Append( - IndexedDBContext::kIndexedDBDirectory); - } - - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); +bool IndexedDBDispatcherHost::CheckContentSetting(const string16& origin, + const string16& description, + int routing_id, + int response_id) { GURL host(string16(WebSecurityOrigin::createFromDatabaseIdentifier( - params.origin).toString())); + origin).toString())); ContentSetting content_setting = host_content_settings_map_->GetContentSetting( host, CONTENT_SETTINGS_TYPE_COOKIES, ""); CallRenderViewHostContentSettingsDelegate( - process_id_, params.routing_id, + process_id_, routing_id, &RenderViewHostDelegate::ContentSettings::OnIndexedDBAccessed, - host, params.name, content_setting == CONTENT_SETTING_BLOCK); + host, description, content_setting == CONTENT_SETTING_BLOCK); if (content_setting == CONTENT_SETTING_BLOCK) { // TODO(jorlow): Change this to the proper error code once we figure out // one. int error_code = 0; // Defined by the IndexedDB spec. static string16 error_message = ASCIIToUTF16( - "The user denied permission to open the database."); - Send(new IndexedDBMsg_CallbacksError(params.response_id, error_code, + "The user denied permission to access the database."); + Send(new IndexedDBMsg_CallbacksError(response_id, error_code, error_message)); + return false; + } + return true; +} + +void IndexedDBDispatcherHost::OnIDBFactoryOpen( + const IndexedDBHostMsg_FactoryOpen_Params& params) { + FilePath base_path = webkit_context_->data_path(); + FilePath indexed_db_path; + if (!base_path.empty()) { + indexed_db_path = base_path.Append( + IndexedDBContext::kIndexedDBDirectory); + } + + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); + if (!CheckContentSetting(params.origin, params.name, params.routing_id, + params.response_id)) { return; } @@ -224,6 +237,28 @@ void IndexedDBDispatcherHost::OnIDBFactoryOpen( webkit_glue::FilePathToWebString(indexed_db_path), quota); } +void IndexedDBDispatcherHost::OnIDBFactoryDeleteDatabase( + const IndexedDBHostMsg_FactoryDeleteDatabase_Params& params) { + FilePath base_path = webkit_context_->data_path(); + FilePath indexed_db_path; + if (!base_path.empty()) { + indexed_db_path = base_path.Append( + IndexedDBContext::kIndexedDBDirectory); + } + + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); + if (!CheckContentSetting(params.origin, params.name, params.routing_id, + params.response_id)) { + return; + } + + Context()->GetIDBFactory()->deleteDatabase( + params.name, + new IndexedDBCallbacks<WebIDBDatabase>(this, params.response_id), + WebSecurityOrigin::createFromDatabaseIdentifier(params.origin), NULL, + webkit_glue::FilePathToWebString(indexed_db_path)); +} + ////////////////////////////////////////////////////////////////////// // Helper templates. // diff --git a/chrome/browser/in_process_webkit/indexed_db_dispatcher_host.h b/chrome/browser/in_process_webkit/indexed_db_dispatcher_host.h index 0d83c69..da8a176 100644 --- a/chrome/browser/in_process_webkit/indexed_db_dispatcher_host.h +++ b/chrome/browser/in_process_webkit/indexed_db_dispatcher_host.h @@ -18,6 +18,7 @@ class NullableString16; class Profile; class SerializedScriptValue; struct IndexedDBHostMsg_DatabaseCreateObjectStore_Params; +struct IndexedDBHostMsg_FactoryDeleteDatabase_Params; struct IndexedDBHostMsg_FactoryOpen_Params; struct IndexedDBHostMsg_IndexOpenCursor_Params; struct IndexedDBHostMsg_ObjectStoreCreateIndex_Params; @@ -61,10 +62,20 @@ class IndexedDBDispatcherHost : public BrowserMessageFilter { private: ~IndexedDBDispatcherHost(); + // True if the given |origin| can use databases according to the content + // settings. + bool CheckContentSetting(const string16& origin, + const string16& description, + int routing_id, + int response_id); + // Message processing. Most of the work is delegated to the dispatcher hosts // below. void OnIDBFactoryOpen(const IndexedDBHostMsg_FactoryOpen_Params& p); + void OnIDBFactoryDeleteDatabase( + const IndexedDBHostMsg_FactoryDeleteDatabase_Params& p); + // Helper templates. template <class ReturnType> ReturnType* GetOrTerminateProcess( diff --git a/chrome/common/indexed_db_messages.h b/chrome/common/indexed_db_messages.h index 4203f61..d20ea6b 100644 --- a/chrome/common/indexed_db_messages.h +++ b/chrome/common/indexed_db_messages.h @@ -34,6 +34,18 @@ IPC_STRUCT_BEGIN(IndexedDBHostMsg_FactoryOpen_Params) IPC_STRUCT_MEMBER(uint64, maximum_size) IPC_STRUCT_END() +// Used to delete an indexed database. +IPC_STRUCT_BEGIN(IndexedDBHostMsg_FactoryDeleteDatabase_Params) + // The routing ID of the view initiating the deletion. + IPC_STRUCT_MEMBER(int32, routing_id) + // The response should have this id. + IPC_STRUCT_MEMBER(int32, response_id) + // The origin doing the initiating. + IPC_STRUCT_MEMBER(string16, origin) + // The name of the database. + IPC_STRUCT_MEMBER(string16, name) +IPC_STRUCT_END() + // Used to create an object store. IPC_STRUCT_BEGIN(IndexedDBHostMsg_DatabaseCreateObjectStore_Params) // The name of the object store. @@ -200,6 +212,10 @@ IPC_SYNC_MESSAGE_CONTROL2_1(IndexedDBHostMsg_CursorDelete, IPC_MESSAGE_CONTROL1(IndexedDBHostMsg_FactoryOpen, IndexedDBHostMsg_FactoryOpen_Params) +// WebIDBFactory::deleteDatabase() message. +IPC_MESSAGE_CONTROL1(IndexedDBHostMsg_FactoryDeleteDatabase, + IndexedDBHostMsg_FactoryDeleteDatabase_Params) + // WebIDBDatabase::name() message. IPC_SYNC_MESSAGE_CONTROL1_1(IndexedDBHostMsg_DatabaseName, int32, /* idb_database_id */ diff --git a/chrome/renderer/indexed_db_dispatcher.cc b/chrome/renderer/indexed_db_dispatcher.cc index f612dc7..a48dda4 100644 --- a/chrome/renderer/indexed_db_dispatcher.cc +++ b/chrome/renderer/indexed_db_dispatcher.cc @@ -125,6 +125,28 @@ void IndexedDBDispatcher::RequestIDBFactoryOpen( RenderThread::current()->Send(new IndexedDBHostMsg_FactoryOpen(params)); } +void IndexedDBDispatcher::RequestIDBFactoryDeleteDatabase( + const string16& name, + WebIDBCallbacks* callbacks_ptr, + const string16& origin, + WebFrame* web_frame) { + scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); + + if (!web_frame) + return; // We must be shutting down. + RenderView* render_view = RenderView::FromWebView(web_frame->view()); + if (!render_view) + return; // We must be shutting down. + + IndexedDBHostMsg_FactoryDeleteDatabase_Params params; + params.routing_id = render_view->routing_id(); + params.response_id = pending_callbacks_.Add(callbacks.release()); + params.origin = origin; + params.name = name; + RenderThread::current()->Send( + new IndexedDBHostMsg_FactoryDeleteDatabase(params)); +} + void IndexedDBDispatcher::RequestIDBDatabaseSetVersion( const string16& version, WebIDBCallbacks* callbacks_ptr, diff --git a/chrome/renderer/indexed_db_dispatcher.h b/chrome/renderer/indexed_db_dispatcher.h index 42bd0e9..a190ffb 100644 --- a/chrome/renderer/indexed_db_dispatcher.h +++ b/chrome/renderer/indexed_db_dispatcher.h @@ -40,6 +40,12 @@ class IndexedDBDispatcher : public IPC::Channel::Listener { WebKit::WebFrame* web_frame, uint64 maximum_size); + void RequestIDBFactoryDeleteDatabase( + const string16& name, + WebKit::WebIDBCallbacks* callbacks, + const string16& origin, + WebKit::WebFrame* web_frame); + void RequestIDBCursorUpdate( const SerializedScriptValue& value, WebKit::WebIDBCallbacks* callbacks_ptr, diff --git a/chrome/renderer/renderer_webidbfactory_impl.cc b/chrome/renderer/renderer_webidbfactory_impl.cc index d75f065..5efa552 100644 --- a/chrome/renderer/renderer_webidbfactory_impl.cc +++ b/chrome/renderer/renderer_webidbfactory_impl.cc @@ -28,11 +28,26 @@ void RendererWebIDBFactoryImpl::open( WebIDBCallbacks* callbacks, const WebSecurityOrigin& origin, WebFrame* web_frame, - const WebString& dataDir, + const WebString& data_dir, unsigned long long maximum_size) { - // Don't send the dataDir. We know what we want on the Browser side of things. + // Don't send the data_dir. We know what we want on the Browser side of + // things. IndexedDBDispatcher* dispatcher = RenderThread::current()->indexed_db_dispatcher(); dispatcher->RequestIDBFactoryOpen( name, callbacks, origin.databaseIdentifier(), web_frame, maximum_size); } + +void RendererWebIDBFactoryImpl::deleteDatabase( + const WebString& name, + WebIDBCallbacks* callbacks, + const WebSecurityOrigin& origin, + WebFrame* web_frame, + const WebString& data_dir) { + // Don't send the data_dir. We know what we want on the Browser side of + // things. + IndexedDBDispatcher* dispatcher = + RenderThread::current()->indexed_db_dispatcher(); + dispatcher->RequestIDBFactoryDeleteDatabase( + name, callbacks, origin.databaseIdentifier(), web_frame); +} diff --git a/chrome/renderer/renderer_webidbfactory_impl.h b/chrome/renderer/renderer_webidbfactory_impl.h index a59b425..63eaaba 100644 --- a/chrome/renderer/renderer_webidbfactory_impl.h +++ b/chrome/renderer/renderer_webidbfactory_impl.h @@ -29,8 +29,14 @@ class RendererWebIDBFactoryImpl : public WebKit::WebIDBFactory { WebKit::WebIDBCallbacks* callbacks, const WebKit::WebSecurityOrigin& origin, WebKit::WebFrame* web_frame, - const WebKit::WebString& dataDir, + const WebKit::WebString& data_dir, unsigned long long maximum_size); + virtual void deleteDatabase( + const WebKit::WebString& name, + WebKit::WebIDBCallbacks* callbacks, + const WebKit::WebSecurityOrigin& origin, + WebKit::WebFrame* web_frame, + const WebKit::WebString& data_dir); }; #endif // CHROME_RENDERER_RENDERER_WEBIDBFACTORY_IMPL_H_ |