Title: [116842] trunk/Source/WebCore
Revision
116842
Author
[email protected]
Date
2012-05-12 01:31:30 -0700 (Sat, 12 May 2012)

Log Message

Cleanup ContentSecurityPolicy naming conventions.
https://bugs.webkit.org/show_bug.cgi?id=86282

Patch by Mike West <[email protected]> on 2012-05-12
Reviewed by Adam Barth.

Two tiny changes:

1. `reportURI` and `reportURL` are both used within the CSP
   implementation. We should standardize on `reportURI` to match the
   spec.

2. Renames `ContentSecurityPolicy::allowConnectFromSource` to
   `ContentSecurityPolicy::allowConnectToSource` for clarity.

No new tests, as there's no user-visible change.

* Modules/websockets/WebSocket.cpp:
(WebCore::WebSocket::connect):
* page/ContentSecurityPolicy.cpp:
(CSPDirectiveList):
(WebCore::CSPDirectiveList::reportViolation):
(WebCore::CSPDirectiveList::allowConnectToSource):
(WebCore::CSPDirectiveList::parseReportURI):
(WebCore::CSPDirectiveList::addDirective):
(WebCore::ContentSecurityPolicy::allowConnectToSource):
* page/ContentSecurityPolicy.h:
* page/EventSource.cpp:
(WebCore::EventSource::create):
* xml/XMLHttpRequest.cpp:
(WebCore::XMLHttpRequest::open):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (116841 => 116842)


--- trunk/Source/WebCore/ChangeLog	2012-05-12 07:43:03 UTC (rev 116841)
+++ trunk/Source/WebCore/ChangeLog	2012-05-12 08:31:30 UTC (rev 116842)
@@ -1,3 +1,36 @@
+2012-05-12  Mike West  <[email protected]>
+
+        Cleanup ContentSecurityPolicy naming conventions.
+        https://bugs.webkit.org/show_bug.cgi?id=86282
+
+        Reviewed by Adam Barth.
+
+        Two tiny changes:
+        
+        1. `reportURI` and `reportURL` are both used within the CSP
+           implementation. We should standardize on `reportURI` to match the
+           spec.
+        
+        2. Renames `ContentSecurityPolicy::allowConnectFromSource` to
+           `ContentSecurityPolicy::allowConnectToSource` for clarity.
+
+        No new tests, as there's no user-visible change.
+
+        * Modules/websockets/WebSocket.cpp:
+        (WebCore::WebSocket::connect):
+        * page/ContentSecurityPolicy.cpp:
+        (CSPDirectiveList):
+        (WebCore::CSPDirectiveList::reportViolation):
+        (WebCore::CSPDirectiveList::allowConnectToSource):
+        (WebCore::CSPDirectiveList::parseReportURI):
+        (WebCore::CSPDirectiveList::addDirective):
+        (WebCore::ContentSecurityPolicy::allowConnectToSource):
+        * page/ContentSecurityPolicy.h:
+        * page/EventSource.cpp:
+        (WebCore::EventSource::create):
+        * xml/XMLHttpRequest.cpp:
+        (WebCore::XMLHttpRequest::open):
+
 2012-05-11  Mark Pilgrim  <[email protected]>
 
         [Chromium] Call isLinkVisited directly

Modified: trunk/Source/WebCore/Modules/websockets/WebSocket.cpp (116841 => 116842)


--- trunk/Source/WebCore/Modules/websockets/WebSocket.cpp	2012-05-12 07:43:03 UTC (rev 116841)
+++ trunk/Source/WebCore/Modules/websockets/WebSocket.cpp	2012-05-12 08:31:30 UTC (rev 116842)
@@ -221,7 +221,7 @@
         return;
     }
 
-    if (!scriptExecutionContext()->contentSecurityPolicy()->allowConnectFromSource(m_url)) {
+    if (!scriptExecutionContext()->contentSecurityPolicy()->allowConnectToSource(m_url)) {
         m_state = CLOSED;
 
         // FIXME: Should this be throwing an exception?

Modified: trunk/Source/WebCore/page/ContentSecurityPolicy.cpp (116841 => 116842)


--- trunk/Source/WebCore/page/ContentSecurityPolicy.cpp	2012-05-12 07:43:03 UTC (rev 116841)
+++ trunk/Source/WebCore/page/ContentSecurityPolicy.cpp	2012-05-12 08:31:30 UTC (rev 116842)
@@ -503,7 +503,7 @@
     bool allowStyleFromSource(const KURL&) const;
     bool allowFontFromSource(const KURL&) const;
     bool allowMediaFromSource(const KURL&) const;
-    bool allowConnectFromSource(const KURL&) const;
+    bool allowConnectToSource(const KURL&) const;
 
 private:
     explicit CSPDirectiveList(ScriptExecutionContext*);
@@ -544,7 +544,7 @@
     OwnPtr<CSPDirective> m_mediaSrc;
     OwnPtr<CSPDirective> m_connectSrc;
 
-    Vector<KURL> m_reportURLs;
+    Vector<KURL> m_reportURIs;
 };
 
 CSPDirectiveList::CSPDirectiveList(ScriptExecutionContext* scriptExecutionContext)
@@ -580,7 +580,7 @@
     String message = m_reportOnly ? "[Report Only] " + consoleMessage : consoleMessage;
     m_scriptExecutionContext->addConsoleMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, message);
 
-    if (m_reportURLs.isEmpty())
+    if (m_reportURIs.isEmpty())
         return;
 
     // FIXME: Support sending reports from worker.
@@ -618,8 +618,8 @@
 
     RefPtr<FormData> report = FormData::create(reportObject->toJSONString().utf8());
 
-    for (size_t i = 0; i < m_reportURLs.size(); ++i)
-        PingLoader::reportContentSecurityPolicyViolation(frame, m_reportURLs[i], report);
+    for (size_t i = 0; i < m_reportURIs.size(); ++i)
+        PingLoader::reportContentSecurityPolicyViolation(frame, m_reportURIs[i], report);
 }
 
 void CSPDirectiveList::logUnrecognizedDirective(const String& name) const
@@ -738,7 +738,7 @@
     return checkSourceAndReportViolation(operativeDirective(m_mediaSrc.get()), url, type);
 }
 
-bool CSPDirectiveList::allowConnectFromSource(const KURL& url) const
+bool CSPDirectiveList::allowConnectToSource(const KURL& url) const
 {
     DEFINE_STATIC_LOCAL(String, type, ("connect"));
     return checkSourceAndReportViolation(operativeDirective(m_connectSrc.get()), url, type);
@@ -826,7 +826,7 @@
 
         if (urlBegin < position) {
             String url = "" position - urlBegin);
-            m_reportURLs.append(m_scriptExecutionContext->completeURL(url));
+            m_reportURIs.append(m_scriptExecutionContext->completeURL(url));
         }
     }
 }
@@ -879,7 +879,7 @@
         m_connectSrc = createCSPDirective(name, value);
     else if (!m_haveSandboxPolicy && equalIgnoringCase(name, sandbox))
         applySandboxPolicy(value);
-    else if (m_reportURLs.isEmpty() && equalIgnoringCase(name, reportURI))
+    else if (m_reportURIs.isEmpty() && equalIgnoringCase(name, reportURI))
         parseReportURI(value);
     else
         logUnrecognizedDirective(name);
@@ -1004,9 +1004,9 @@
     return isAllowedByAll<&CSPDirectiveList::allowMediaFromSource>(m_policies, url);
 }
 
-bool ContentSecurityPolicy::allowConnectFromSource(const KURL& url) const
+bool ContentSecurityPolicy::allowConnectToSource(const KURL& url) const
 {
-    return isAllowedByAll<&CSPDirectiveList::allowConnectFromSource>(m_policies, url);
+    return isAllowedByAll<&CSPDirectiveList::allowConnectToSource>(m_policies, url);
 }
 
 }

Modified: trunk/Source/WebCore/page/ContentSecurityPolicy.h (116841 => 116842)


--- trunk/Source/WebCore/page/ContentSecurityPolicy.h	2012-05-12 07:43:03 UTC (rev 116841)
+++ trunk/Source/WebCore/page/ContentSecurityPolicy.h	2012-05-12 08:31:30 UTC (rev 116842)
@@ -74,7 +74,7 @@
     bool allowStyleFromSource(const KURL&) const;
     bool allowFontFromSource(const KURL&) const;
     bool allowMediaFromSource(const KURL&) const;
-    bool allowConnectFromSource(const KURL&) const;
+    bool allowConnectToSource(const KURL&) const;
 
     void setOverrideAllowInlineStyle(bool);
 

Modified: trunk/Source/WebCore/page/EventSource.cpp (116841 => 116842)


--- trunk/Source/WebCore/page/EventSource.cpp	2012-05-12 07:43:03 UTC (rev 116841)
+++ trunk/Source/WebCore/page/EventSource.cpp	2012-05-12 08:31:30 UTC (rev 116842)
@@ -88,7 +88,7 @@
         return 0;
     }
 
-    if (!context->contentSecurityPolicy()->allowConnectFromSource(fullURL)) {
+    if (!context->contentSecurityPolicy()->allowConnectToSource(fullURL)) {
         // FIXME: Should this be throwing an exception?
         ec = SECURITY_ERR;
         return 0;

Modified: trunk/Source/WebCore/xml/XMLHttpRequest.cpp (116841 => 116842)


--- trunk/Source/WebCore/xml/XMLHttpRequest.cpp	2012-05-12 07:43:03 UTC (rev 116841)
+++ trunk/Source/WebCore/xml/XMLHttpRequest.cpp	2012-05-12 08:31:30 UTC (rev 116842)
@@ -478,7 +478,7 @@
         return;
     }
 
-    if (!scriptExecutionContext()->contentSecurityPolicy()->allowConnectFromSource(url)) {
+    if (!scriptExecutionContext()->contentSecurityPolicy()->allowConnectToSource(url)) {
         // FIXME: Should this be throwing an exception?
         ec = SECURITY_ERR;
         return;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to