Reviewed by Sam Weinig.
* Add FrameLoader::shouldTreatSchemeAsLocal which is similar to
shouldTreatURLAsLocal.
* Make use of FrameLoader::shouldTreatSchemeAsLocal in SecurityOrigin
and do not hardcode "file". This is needed for the WebKit/qt port to make
the Web Inspector work as it using the qrc protocol instead of file.
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::shouldTreatSchemeAsLocal):
* loader/FrameLoader.h:
* platform/SecurityOrigin.cpp:
(WebCore::SecurityOrigin::isSecureTransitionTo):
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@28343
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2007-12-02 Holger Hans Peter Freyther <holger.freyther@trolltech.com>
+
+ Reviewed by Sam Weinig.
+
+ * Add FrameLoader::shouldTreatSchemeAsLocal which is similar to
+ shouldTreatURLAsLocal.
+ * Make use of FrameLoader::shouldTreatSchemeAsLocal in SecurityOrigin
+ and do not hardcode "file". This is needed for the WebKit/qt port to make
+ the Web Inspector work as it using the qrc protocol instead of file.
+
+
+ * loader/FrameLoader.cpp:
+ (WebCore::FrameLoader::shouldTreatSchemeAsLocal):
+ * loader/FrameLoader.h:
+ * platform/SecurityOrigin.cpp:
+ (WebCore::SecurityOrigin::isSecureTransitionTo):
+
2007-12-02 Holger Hans Peter Freyther <holger.freyther@trolltech.com>
Rubber stamped by Sam Weinig.
return localSchemes().contains(scheme);
}
+bool FrameLoader::shouldTreatSchemeAsLocal(const String& scheme)
+{
+ // This avoids an allocation of another String and the HashSet contains()
+ // call for the file: and http: schemes.
+ if (scheme.length() == 4) {
+ const UChar* s = scheme.characters();
+ if (s[0] == 'h' && s[1] == 't' && s[2] == 't' && s[3] == 'p')
+ return false;
+ if (s[0] == 'f' && s[1] == 'i' && s[2] == 'l' && s[3] == 'e')
+ return true;
+ }
+
+ if (scheme.isEmpty())
+ return false;
+
+ return localSchemes().contains(scheme);
+}
+
void FrameLoader::dispatchDidCommitLoad()
{
m_client->dispatchDidCommitLoad();
static void registerURLSchemeAsLocal(const String& scheme);
static bool restrictAccessToLocal();
static void setRestrictAccessToLocal(bool);
- static bool shouldTreatURLAsLocal(const String& url);
+ static bool shouldTreatURLAsLocal(const String&);
+ static bool shouldTreatSchemeAsLocal(const String&);
#if USE(LOW_BANDWIDTH_DISPLAY)
bool addLowBandwidthDisplayRequest(CachedResource*);
bool SecurityOrigin::canAccess(const SecurityOrigin& other) const
{
- if (m_protocol == "file")
+ if (FrameLoader::shouldTreatSchemeAsLocal(m_protocol))
return true;
if (m_noAccess || other.m_noAccess)
if (isEmpty())
return true;
- if (m_protocol == "file")
+ if (FrameLoader::shouldTreatSchemeAsLocal(m_protocol))
return true;
return equalIgnoringCase(m_host, String(url.host())) && equalIgnoringCase(m_protocol, String(url.protocol())) && m_port == url.port();