Source/WebCore/ChangeLog

 12012-01-20 Mark Pilgrim <pilgrim@chromium.org>
 2
 3 Switch indexeddb to use supplemental IDL for DOMWindow
 4 https://bugs.webkit.org/show_bug.cgi?id=76723
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 No new tests required, all existing tests pass.
 9
 10 * Modules/indexeddb: Added.
 11 * Modules/indexeddb/DOMWindowIndexedDatabase.cpp: Added. webkitIndexedDB() method previously in DOMWindow.cpp
 12 (WebCore::DOMWindowIndexedDatabase::DOMWindowIndexedDatabase):
 13 (WebCore::DOMWindowIndexedDatabase::~DOMWindowIndexedDatabase):
 14 (WebCore::DOMWindowIndexedDatabase::webkitIndexedDB):
 15 * Modules/indexeddb/DOMWindowIndexedDatabase.h: Added.
 16 * Modules/indexeddb/DOMWindowIndexedDatabase.idl: Added. attributes previously in DOMWindow.idl
 17 * WebCore.gyp/WebCore.gyp: add Modules/indexeddb/ directory
 18 * WebCore.gypi: add Modules/indexeddb/*
 19 * page/DOMWindow.cpp: remove webkitIndexedDB() method, add accessor methods for m_idbFactory
 20 (WebCore::DOMWindow::getIDBFactory):
 21 (WebCore::DOMWindow::setIDBFactory):
 22 * page/DOMWindow.h:
 23 * page/DOMWindow.idl:
 24
1252012-01-20 Brady Eidson <beidson@apple.com>
226
327 <rdar://problem/9328684> and https://bugs.webkit.org/show_bug.cgi?id=62764
105558

Source/WebCore/WebCore.gypi

11481148 'Modules/gamepad/Gamepad.idl',
11491149 'Modules/gamepad/GamepadList.idl',
11501150 'Modules/gamepad/NavigatorGamepad.idl',
 1151 'Modules/indexeddb/DOMWindowIndexedDatabase.idl',
11511152 'Modules/intents/DOMWindowIntents.idl',
11521153 'Modules/intents/Intent.idl',
11531154 'Modules/intents/IntentResultCallback.idl',

17011702 'Modules/gamepad/GamepadList.h',
17021703 'Modules/gamepad/NavigatorGamepad.cpp',
17031704 'Modules/gamepad/NavigatorGamepad.h',
 1705 'Modules/indexeddb/DOMWindowIndexedDatabase.cpp',
 1706 'Modules/indexeddb/DOMWindowIndexedDatabase.h',
17041707 'Modules/intents/Intent.cpp',
17051708 'Modules/intents/Intent.h',
17061709 'Modules/intents/IntentRequest.cpp',
105556

Source/WebCore/Modules/indexeddb/DOMWindowIndexedDatabase.cpp

 1/*
 2 * Copyright (C) 2011, Google Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions are met:
 6 *
 7 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND
 14 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 16 * ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE
 17 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 18 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 19 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 20 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
 23 * DAMAGE.
 24 */
 25
 26#include "config.h"
 27#include "DOMWindowIndexedDatabase.h"
 28
 29#if ENABLE(INDEXED_DATABASE)
 30
 31#include "DOMWindow.h"
 32#include "Document.h"
 33#include "IDBFactory.h"
 34#include "Page.h"
 35#include "PageGroup.h"
 36#include "SecurityOrigin.h"
 37
 38namespace WebCore {
 39
 40DOMWindowIndexedDatabase::DOMWindowIndexedDatabase()
 41{
 42}
 43
 44DOMWindowIndexedDatabase::~DOMWindowIndexedDatabase()
 45{
 46}
 47
 48IDBFactory* DOMWindowIndexedDatabase::webkitIndexedDB(DOMWindow* window)
 49{
 50 Document* document = window->document();
 51 if (!document)
 52 return 0;
 53
 54 Page* page = document->page();
 55 if (!page)
 56 return 0;
 57
 58 if (!document->securityOrigin()->canAccessDatabase())
 59 return 0;
 60
 61 if (!window->getIDBFactory() && window->isCurrentlyDisplayedInFrame())
 62 window->setIDBFactory(IDBFactory::create(page->group().idbFactory()));
 63 return window->getIDBFactory().get();
 64}
 65
 66} // namespace WebCore
 67
 68#endif // ENABLE(INDEXED_DATABASE)
0

Source/WebCore/Modules/indexeddb/DOMWindowIndexedDatabase.h

 1/*
 2 * Copyright (C) 2011, Google Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions are met:
 6 *
 7 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND
 14 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 16 * ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE
 17 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 18 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 19 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 20 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
 23 * DAMAGE.
 24 */
 25
 26#ifndef DOMWindowIndexedDatabase_h
 27#define DOMWindowIndexedDatabase_h
 28
 29#if ENABLE(INDEXED_DATABASE)
 30
 31namespace WebCore {
 32
 33class IDBFactory;
 34class DOMWindow;
 35
 36class DOMWindowIndexedDatabase {
 37public:
 38 static IDBFactory* webkitIndexedDB(DOMWindow*);
 39
 40private:
 41 DOMWindowIndexedDatabase();
 42 ~DOMWindowIndexedDatabase();
 43};
 44
 45} // namespace WebCore
 46
 47#endif // ENABLE(INDEXED_DATABASE)
 48
 49#endif // DOMWindowIndexedDatabase_h
0

Source/WebCore/Modules/indexeddb/DOMWindowIndexedDatabase.idl

 1/*
 2 * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
 3 * Copyright (C) 2011 Google Inc. All rights reserved.
 4 *
 5 * Redistribution and use in source and binary forms, with or without
 6 * modification, are permitted provided that the following conditions
 7 * are met:
 8 * 1. Redistributions of source code must retain the above copyright
 9 * notice, this list of conditions and the following disclaimer.
 10 * 2. Redistributions in binary form must reproduce the above copyright
 11 * notice, this list of conditions and the following disclaimer in the
 12 * documentation and/or other materials provided with the distribution.
 13 *
 14 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
 18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 25 */
 26
 27module window {
 28
 29 interface [
 30 Conditional=INDEXED_DATABASE,
 31 Supplemental=DOMWindow
 32 ] DOMWindowIndexedDatabase {
 33 readonly attribute IDBFactory webkitIndexedDB;
 34
 35 attribute IDBCursorConstructor webkitIDBCursor;
 36 attribute IDBDatabaseConstructor webkitIDBDatabase;
 37 attribute IDBDatabaseErrorConstructor webkitIDBDatabaseError;
 38 attribute IDBDatabaseExceptionConstructor webkitIDBDatabaseException;
 39 attribute IDBFactoryConstructor webkitIDBFactory;
 40 attribute IDBIndexConstructor webkitIDBIndex;
 41 attribute IDBKeyRangeConstructor webkitIDBKeyRange;
 42 attribute IDBObjectStoreConstructor webkitIDBObjectStore;
 43 attribute IDBRequestConstructor webkitIDBRequest;
 44 attribute IDBTransactionConstructor webkitIDBTransaction;
 45 };
 46
 47}
0

Source/WebCore/WebCore.gyp/WebCore.gyp

5353 '../..',
5454 '../Modules/gamepad',
5555 '../Modules/intents',
 56 '../Modules/indexeddb',
5657 '../accessibility',
5758 '../accessibility/chromium',
5859 '../bindings',
105556

Source/WebCore/page/DOMWindow.cpp

@@void DOMWindow::resetGeolocation()
750750}
751751
752752#if ENABLE(INDEXED_DATABASE)
753 IDBFactory* DOMWindow::webkitIndexedDB() const
 753PassRefPtr<IDBFactory> DOMWindow::getIDBFactory()
754754{
755  Document* document = this->document();
756  if (!document)
757  return 0;
758 
759  Page* page = document->page();
760  if (!page)
761  return 0;
762 
763  if (!document->securityOrigin()->canAccessDatabase())
764  return 0;
 755 return m_idbFactory;
 756}
765757
766  if (!m_idbFactory && isCurrentlyDisplayedInFrame())
767  m_idbFactory = IDBFactory::create(page->group().idbFactory());
768  return m_idbFactory.get();
 758void DOMWindow::setIDBFactory(PassRefPtr<IDBFactory> idbFactory)
 759{
 760 m_idbFactory = idbFactory;
769761}
770762#endif
771763
105556

Source/WebCore/page/DOMWindow.h

@@namespace WebCore {
372372 void webkitResolveLocalFileSystemURL(const String&, PassRefPtr<EntryCallback>, PassRefPtr<ErrorCallback>);
373373#endif
374374
375 #if ENABLE(INDEXED_DATABASE)
376  IDBFactory* webkitIndexedDB() const;
377 #endif
378 
379375#if ENABLE(NOTIFICATIONS)
380376 NotificationCenter* webkitNotifications() const;
381377 // Renders webkitNotifications object safely inoperable, disconnects

@@namespace WebCore {
416412 // by the document that is currently active in m_frame.
417413 bool isCurrentlyDisplayedInFrame() const;
418414
 415#if ENABLE(INDEXED_DATABASE)
 416 PassRefPtr<IDBFactory> getIDBFactory();
 417 void setIDBFactory(PassRefPtr<IDBFactory>);
 418#endif
 419
419420 private:
420421 explicit DOMWindow(Frame*);
421422
105556

Source/WebCore/page/DOMWindow.idl

@@module window {
172172#if defined(ENABLE_NOTIFICATIONS) && ENABLE_NOTIFICATIONS
173173 readonly attribute [EnabledAtRuntime] NotificationCenter webkitNotifications;
174174#endif
175 #if defined(ENABLE_INDEXED_DATABASE) && ENABLE_INDEXED_DATABASE
176  readonly attribute IDBFactory webkitIndexedDB;
177 
178  attribute IDBCursorConstructor webkitIDBCursor;
179  attribute IDBDatabaseConstructor webkitIDBDatabase;
180  attribute IDBDatabaseErrorConstructor webkitIDBDatabaseError;
181  attribute IDBDatabaseExceptionConstructor webkitIDBDatabaseException;
182  attribute IDBFactoryConstructor webkitIDBFactory;
183  attribute IDBIndexConstructor webkitIDBIndex;
184  attribute IDBKeyRangeConstructor webkitIDBKeyRange;
185  attribute IDBObjectStoreConstructor webkitIDBObjectStore;
186  attribute IDBRequestConstructor webkitIDBRequest;
187  attribute IDBTransactionConstructor webkitIDBTransaction;
188 #endif
189175#if defined(ENABLE_FILE_SYSTEM) && ENABLE_FILE_SYSTEM
190176 const unsigned short TEMPORARY = 0;
191177 const unsigned short PERSISTENT = 1;
105556