Cleanup: Use ScriptExecutionContext::topOrigin when relevant.
authormkwst@chromium.org <mkwst@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 31 Jan 2013 20:48:49 +0000 (20:48 +0000)
committermkwst@chromium.org <mkwst@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 31 Jan 2013 20:48:49 +0000 (20:48 +0000)
https://bugs.webkit.org/show_bug.cgi?id=108476

Source/WebCore:

Reviewed by Jochen Eisinger.

Rather than diving through 'frame()->top()' or 'topDocument()' to get
the SecurityOrigin of the top-level document in a frame, we can now
directly grab the 'topOrigin()' off of a ScriptExecutionContext. This
patch adjusts a few callsites to use the new hotness rather than the
old brokenness.

This is a pure refactoring: No web-visible changes should result.

* Modules/webdatabase/DOMWindowWebDatabase.cpp:
(WebCore::DOMWindowWebDatabase::openDatabase):
* page/DOMWindow.cpp:
(WebCore::DOMWindow::sessionStorage):
(WebCore::DOMWindow::localStorage):
* workers/SharedWorker.cpp:
(WebCore::SharedWorker::create):
* workers/WorkerMessagingProxy.cpp:
(WebCore::WorkerMessagingProxy::startWorkerContext):

Source/WebKit2:

Reviewed by Anders Carlsson.

* WebProcess/Plugins/PluginView.cpp:
(WebKit::PluginView::storageBlockingStateChanged):
(WebKit::PluginView::isPrivateBrowsingEnabled):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@141466 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/Modules/webdatabase/DOMWindowWebDatabase.cpp
Source/WebCore/page/DOMWindow.cpp
Source/WebCore/workers/SharedWorker.cpp
Source/WebCore/workers/WorkerMessagingProxy.cpp
Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/Plugins/PluginView.cpp

index 1d56ef8..e172052 100644 (file)
@@ -1,3 +1,28 @@
+2013-01-31  Mike West  <mkwst@chromium.org>
+
+        Cleanup: Use ScriptExecutionContext::topOrigin when relevant.
+        https://bugs.webkit.org/show_bug.cgi?id=108476
+
+        Reviewed by Jochen Eisinger.
+
+        Rather than diving through 'frame()->top()' or 'topDocument()' to get
+        the SecurityOrigin of the top-level document in a frame, we can now
+        directly grab the 'topOrigin()' off of a ScriptExecutionContext. This
+        patch adjusts a few callsites to use the new hotness rather than the
+        old brokenness.
+
+        This is a pure refactoring: No web-visible changes should result.
+
+        * Modules/webdatabase/DOMWindowWebDatabase.cpp:
+        (WebCore::DOMWindowWebDatabase::openDatabase):
+        * page/DOMWindow.cpp:
+        (WebCore::DOMWindow::sessionStorage):
+        (WebCore::DOMWindow::localStorage):
+        * workers/SharedWorker.cpp:
+        (WebCore::SharedWorker::create):
+        * workers/WorkerMessagingProxy.cpp:
+        (WebCore::WorkerMessagingProxy::startWorkerContext):
+
 2013-01-31  peavo@outlook.com  <peavo@outlook.com>
 
         [Curl] There is no way for a WebKit client to set the Curl cookie jar path
index 2b53188..53325e1 100644 (file)
@@ -47,7 +47,7 @@ PassRefPtr<Database> DOMWindowWebDatabase::openDatabase(DOMWindow* window, const
 
     RefPtr<Database> database = 0;
     DatabaseManager& dbManager = DatabaseManager::manager();
-    if (dbManager.isAvailable() && window->document()->securityOrigin()->canAccessDatabase(window->document()->topDocument()->securityOrigin()))
+    if (dbManager.isAvailable() && window->document()->securityOrigin()->canAccessDatabase(window->document()->topOrigin()))
         database = dbManager.openDatabase(window->document(), name, version, displayName, estimatedSize, creationCallback, ec);
 
     if (!database && !ec)
index 2f51a81..1ccbf3c 100644 (file)
@@ -740,7 +740,7 @@ Storage* DOMWindow::sessionStorage(ExceptionCode& ec) const
     if (!document)
         return 0;
 
-    if (!document->securityOrigin()->canAccessLocalStorage(document->topDocument()->securityOrigin())) {
+    if (!document->securityOrigin()->canAccessLocalStorage(document->topOrigin())) {
         ec = SECURITY_ERR;
         return 0;
     }
@@ -777,7 +777,7 @@ Storage* DOMWindow::localStorage(ExceptionCode& ec) const
     if (!document)
         return 0;
 
-    if (!document->securityOrigin()->canAccessLocalStorage(document->topDocument()->securityOrigin())) {
+    if (!document->securityOrigin()->canAccessLocalStorage(document->topOrigin())) {
         ec = SECURITY_ERR;
         return 0;
     }
index a626e88..c66f0b7 100644 (file)
@@ -72,7 +72,7 @@ PassRefPtr<SharedWorker> SharedWorker::create(ScriptExecutionContext* context, c
     // We don't currently support nested workers, so workers can only be created from documents.
     ASSERT(context->isDocument());
     Document* document = static_cast<Document*>(context);
-    if (!document->securityOrigin()->canAccessSharedWorkers(document->topDocument()->securityOrigin())) {
+    if (!document->securityOrigin()->canAccessSharedWorkers(document->topOrigin())) {
         ec = SECURITY_ERR;
         return 0;
     }
index 39f8289..79aea82 100644 (file)
@@ -279,10 +279,7 @@ void WorkerMessagingProxy::startWorkerContext(const KURL& scriptURL, const Strin
     GroupSettings* settings = 0;
     if (document->page())
         settings = document->page()->group().groupSettings();
-    RefPtr<DedicatedWorkerThread> thread = DedicatedWorkerThread::create(scriptURL, userAgent, settings, sourceCode, *this, *this, startMode,
-                                                                         document->contentSecurityPolicy()->deprecatedHeader(),
-                                                                         document->contentSecurityPolicy()->deprecatedHeaderType(),
-                                                                         document->topDocument()->securityOrigin());
+    RefPtr<DedicatedWorkerThread> thread = DedicatedWorkerThread::create(scriptURL, userAgent, settings, sourceCode, *this, *this, startMode, document->contentSecurityPolicy()->deprecatedHeader(), document->contentSecurityPolicy()->deprecatedHeaderType(), document->topOrigin());
     workerThreadCreated(thread);
     thread->start();
     InspectorInstrumentation::didStartWorkerContext(m_scriptExecutionContext.get(), this, scriptURL);
index 5d3e7c7..3bf1b6b 100644 (file)
@@ -1,3 +1,14 @@
+2013-01-31  Mike West  <mkwst@chromium.org>
+
+        Cleanup: Use ScriptExecutionContext::topOrigin when relevant.
+        https://bugs.webkit.org/show_bug.cgi?id=108476
+
+        Reviewed by Anders Carlsson.
+
+        * WebProcess/Plugins/PluginView.cpp:
+        (WebKit::PluginView::storageBlockingStateChanged):
+        (WebKit::PluginView::isPrivateBrowsingEnabled):
+
 2013-01-31  Anders Carlsson  <andersca@apple.com>
 
         Get rid of IncomingMessage
index 10f2f72..61bb7bf 100644 (file)
@@ -634,7 +634,7 @@ void PluginView::storageBlockingStateChanged()
     if (!m_isInitialized || !m_plugin)
         return;
 
-    bool storageBlockingPolicy = !frame()->document()->securityOrigin()->canAccessPluginStorage(frame()->tree()->top()->document()->securityOrigin());
+    bool storageBlockingPolicy = !frame()->document()->securityOrigin()->canAccessPluginStorage(frame()->document()->topOrigin());
 
     m_plugin->storageBlockingStateChanged(storageBlockingPolicy);
 }
@@ -1440,7 +1440,7 @@ bool PluginView::isPrivateBrowsingEnabled()
     if (!frame())
         return true;
 
-    if (!frame()->document()->securityOrigin()->canAccessPluginStorage(frame()->tree()->top()->document()->securityOrigin()))
+    if (!frame()->document()->securityOrigin()->canAccessPluginStorage(frame()->document()->topOrigin()))
         return true;
 
     Settings* settings = frame()->settings();