diff options
author | dglazkov@google.com <dglazkov@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-12-23 21:43:20 +0000 |
---|---|---|
committer | dglazkov@google.com <dglazkov@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-12-23 21:43:20 +0000 |
commit | acc90caf9a9a01e60ffd29eed704cbfa91571593 (patch) | |
tree | 02a8291eff4ac172dab4e4ed900d2268000cebf7 /webkit | |
parent | 0598a381833f136ab211a9f566afcc854eed022e (diff) | |
download | chromium_src-acc90caf9a9a01e60ffd29eed704cbfa91571593.zip chromium_src-acc90caf9a9a01e60ffd29eed704cbfa91571593.tar.gz chromium_src-acc90caf9a9a01e60ffd29eed704cbfa91571593.tar.bz2 |
Spam webkit/port/page/Location on top of the one in WebCore/page, Mac build.
Review URL: http://codereview.chromium.org/16462
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@7443 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r-- | webkit/port/page/Location.cpp | 301 | ||||
-rw-r--r-- | webkit/webkit.xcodeproj/project.pbxproj | 12 |
2 files changed, 0 insertions, 313 deletions
diff --git a/webkit/port/page/Location.cpp b/webkit/port/page/Location.cpp deleted file mode 100644 index d17e5d9..0000000 --- a/webkit/port/page/Location.cpp +++ /dev/null @@ -1,301 +0,0 @@ -// Copyright (c) 2008, Google Inc. -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -#include "config.h" -#include "Location.h" -#include "PlatformString.h" -#include "KURL.h" -#include "Document.h" -#include "FrameLoader.h" -#include "ScriptController.h" -#include "CSSHelper.h" -#include "Frame.h" - -namespace { - -// The value of the location bar while the page is still loading (before we -// have a frame). -const char* kUrlWhileLoading = "about:blank"; - -// Get the URL for a WebCore::Frame. If the frame is null or the URL is not -// defined, return about:blank instead. This mostly matches Firefox's -// behavior of returning about:blank while a URL is loading. -WebCore::KURL GetFrameUrl(WebCore::Frame* frame) { - if (!frame) - return WebCore::KURL(kUrlWhileLoading); - - const WebCore::KURL& url = frame->loader()->url(); - - if (!url.isValid()) - return WebCore::KURL(kUrlWhileLoading); - return url; -} - -} - -namespace WebCore { - -#if USE(V8) - // Notes about V8/JSC porting of this file. - // The getter functions on this class are generic across V8/JSC. - // The setter functions are basically custom. In JSC, this gets separated - // into Location.h and JSLocation.h, with the implementation in - // JSLocationCustom.cpp. For V8, we include the custom functions here. - // - // This class is not very JS-engine specific. If we can move a couple of - // methods to the scriptController, we should be able to unify the code - // between JSC and V8: - // retrieveActiveFrame() - in JSC, this needs an ExecState. Is there - // a static accessor? - // isSafeScript() -#endif - -Location::Location(Frame* frame) - : m_frame(frame) -{ -} - -void Location::disconnectFrame() -{ - m_frame = 0; -} - -String Location::hash() const { - if (!m_frame) - return String(); - KURL url = GetFrameUrl(m_frame); - return url.ref().isNull() ? "" : "#" + url.ref(); -} - -String Location::host() const { - KURL url = GetFrameUrl(m_frame); - - String str = url.host(); - if (url.port()) - str += ":" + String::number((int)url.port()); - - return str; -} - -String Location::hostname() const { - KURL url = GetFrameUrl(m_frame); - return url.host(); -} - -String Location::href() const { - KURL url = GetFrameUrl(m_frame); - - if (!url.hasPath()) - return url.prettyURL() + "/"; - return url.prettyURL(); -} - -String Location::pathname() const { - KURL url = GetFrameUrl(m_frame); - return url.path().isEmpty() ? "/" : url.path(); -} - -String Location::port() const { - KURL url = GetFrameUrl(m_frame); - return url.port() ? String::number((int)url.port()) : String(); -} - -String Location::protocol() const { - KURL url = GetFrameUrl(m_frame); - return url.protocol() + ":"; -} - -String Location::search() const { - KURL url = GetFrameUrl(m_frame); - return url.query(); -} - -String Location::toString() const { - return href(); -} - -#if USE(V8) -static void navigateIfAllowed(Frame* frame, const KURL& url, bool lock_history) -{ - if (url.isEmpty()) - return; - - Frame* activeFrame = ScriptController::retrieveActiveFrame(); - if (!activeFrame) - return; - - if (!url.protocolIs("javascript") || ScriptController::isSafeScript(frame)) { - bool user_gesture = activeFrame->script()->processingUserGesture(); - frame->loader()->scheduleLocationChange(url.string(), - activeFrame->loader()->outgoingReferrer(), lock_history, user_gesture); - } -} - -void Location::setHash(const String& hash) { - if (!m_frame) - return; - - KURL url = m_frame->loader()->url(); - String old_ref = url.ref(); - String str = hash; - - if (str.startsWith("#")) - str = str.substring(1); - if (old_ref == str || (old_ref.isNull() && str.isEmpty())) - return; - url.setRef(str); - - navigateIfAllowed(m_frame, url, false); -} - -void Location::setHost(const String& host) { - if (!m_frame) - return; - - KURL url = m_frame->loader()->url(); - String str = host; - String newhost = str.left(str.find(":")); - String newport = str.substring(str.find(":") + 1); - url.setHost(newhost); - url.setPort(newport.toUInt()); - - navigateIfAllowed(m_frame, url, false); -} - -void Location::setHostname(const String& hostname) { - if (!m_frame) - return; - - KURL url = m_frame->loader()->url(); - url.setHost(hostname); - - navigateIfAllowed(m_frame, url, false); -} - -void Location::setHref(const String& value) { - if (!m_frame) - return; - - Frame* active_frame = ScriptController::retrieveActiveFrame(); - if (!active_frame) - return; - - if (!active_frame->loader()->shouldAllowNavigation(m_frame)) - return; - - navigateIfAllowed(m_frame, active_frame->loader()->completeURL(value), false); -} - -void Location::setPathname(const String& pathname) { - if (!m_frame) - return; - - KURL url = m_frame->loader()->url(); - url.setPath(pathname); - - navigateIfAllowed(m_frame, url, false); -} - -void Location::setPort(const String& port) { - if (!m_frame) - return; - - KURL url = m_frame->loader()->url(); - url.setPort(port.toUInt()); - - navigateIfAllowed(m_frame, url, false); -} - -void Location::setProtocol(const String& protocol) { - if (!m_frame) - return; - - KURL url = m_frame->loader()->url(); - url.setProtocol(protocol); - - navigateIfAllowed(m_frame, url, false); -} - -void Location::setSearch(const String& query) { - if (!m_frame) - return; - - KURL url = m_frame->loader()->url(); - url.setQuery(query); - - navigateIfAllowed(m_frame, url, false); -} - -void Location::reload(bool forceget) -{ - if (!m_frame) - return; - - Frame* active_frame = ScriptController::retrieveActiveFrame(); - if (!active_frame) - return; - - if (!ScriptController::isSafeScript(m_frame)) - return; - - bool userGesture = active_frame->script()->processingUserGesture(); - m_frame->loader()->scheduleRefresh(userGesture); -} - -void Location::replace(const String& url) { - if (!m_frame) - return; - - Frame* active_frame = ScriptController::retrieveActiveFrame(); - if (!active_frame) - return; - - if (!active_frame->loader()->shouldAllowNavigation(m_frame)) - return; - - navigateIfAllowed(m_frame, active_frame->loader()->completeURL(url), true); -} - -void Location::assign(const String& url) { - if (!m_frame) - return; - - Frame* active_frame = ScriptController::retrieveActiveFrame(); - if (!active_frame) - return; - - if (!active_frame->loader()->shouldAllowNavigation(m_frame)) - return; - - navigateIfAllowed(m_frame, active_frame->loader()->completeURL(url), false); -} - -#endif // USE(V8) - -} // namespace WebCore diff --git a/webkit/webkit.xcodeproj/project.pbxproj b/webkit/webkit.xcodeproj/project.pbxproj index 9e1ec46..af23877 100644 --- a/webkit/webkit.xcodeproj/project.pbxproj +++ b/webkit/webkit.xcodeproj/project.pbxproj @@ -89,7 +89,6 @@ 4D1638210EBFA4FC008F024E /* StorageMap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4D16380A0EBFA4FB008F024E /* StorageMap.cpp */; }; 4D1640E50EC29BB4008F024E /* Geolocation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4D1640D80EC29BB4008F024E /* Geolocation.cpp */; }; 4D1640E60EC29BB4008F024E /* Geoposition.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4D1640DA0EC29BB4008F024E /* Geoposition.cpp */; }; - 4D1641090EC29C84008F024E /* Location.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7B0096150DAFF19C00F72082 /* Location.cpp */; }; 4D16411F0EC29D01008F024E /* GeolocationService.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4D1641140EC29D01008F024E /* GeolocationService.cpp */; }; 4D1641310EC29E80008F024E /* ActiveDOMObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4D1641280EC29E80008F024E /* ActiveDOMObject.cpp */; }; 4D1641330EC29E80008F024E /* ScriptExecutionContext.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4D16412F0EC29E80008F024E /* ScriptExecutionContext.cpp */; }; @@ -2329,7 +2328,6 @@ 7B0095EC0DAFF0DD00F72082 /* v8_utility.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = v8_utility.h; sourceTree = "<group>"; }; 7B0095ED0DAFF0DD00F72082 /* v8_vectornodelist.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = v8_vectornodelist.cpp; sourceTree = "<group>"; }; 7B0095EE0DAFF0DD00F72082 /* v8_vectornodelist.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = v8_vectornodelist.h; sourceTree = "<group>"; }; - 7B0096150DAFF19C00F72082 /* Location.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Location.cpp; sourceTree = "<group>"; }; 7B00961D0DAFF19C00F72082 /* ScheduledAction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScheduledAction.h; sourceTree = "<group>"; }; 7B0096290DAFF1D000F72082 /* InspectorController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = InspectorController.cpp; path = port/page/inspector/InspectorController.cpp; sourceTree = "<group>"; }; 7B0E595B0DB3D195007D4907 /* IconDatabase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = IconDatabase.h; path = icon/IconDatabase.h; sourceTree = "<group>"; }; @@ -6710,7 +6708,6 @@ 7B9375960D919010008B9587 /* port */ = { isa = PBXGroup; children = ( - E4A970880E3614F200E8EF3B /* page */, 822B1BE60DC778FF005C9A96 /* platform */, 938181210EF6D25700993F02 /* plugins */, ); @@ -7847,14 +7844,6 @@ path = style; sourceTree = "<group>"; }; - E4A970880E3614F200E8EF3B /* page */ = { - isa = PBXGroup; - children = ( - 7B0096150DAFF19C00F72082 /* Location.cpp */, - ); - path = page; - sourceTree = "<group>"; - }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -9426,7 +9415,6 @@ E45627EB0E2694B8005E4685 /* ICOImageDecoder.cpp in Sources */, E4E4C94A0E797648009A687C /* ImageSourceCG.cpp in Sources */, 7B2B0A630E3143EC00D4C6B7 /* JPEGImageDecoder.cpp in Sources */, - 4D1641090EC29C84008F024E /* Location.cpp in Sources */, 93AF4CE00EFAEDF80073C62D /* PlatformScreenMac.mm in Sources */, 7B2B0A650E3143EC00D4C6B7 /* PNGImageDecoder.cpp in Sources */, E40060DB0EA69E0B0055B38E /* ScriptController.cpp in Sources */, |