diff options
-rw-r--r-- | chrome/common/visitedlink_common.cc | 2 | ||||
-rw-r--r-- | chrome/common/visitedlink_common.h | 19 | ||||
-rw-r--r-- | chrome/renderer/renderer_glue.cc | 9 | ||||
-rw-r--r-- | webkit/build/WebCore/WebCore.vcproj | 4 | ||||
-rw-r--r-- | webkit/build/port/port.vcproj | 4 | ||||
-rw-r--r-- | webkit/glue/chromium_bridge_impl.cc | 44 | ||||
-rw-r--r-- | webkit/glue/webkit_glue.h | 8 | ||||
-rw-r--r-- | webkit/port/platform/chromium/ChromiumBridge.h | 11 | ||||
-rw-r--r-- | webkit/port/platform/chromium/LinkHashChromium.cpp | 47 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_shell.cc | 8 |
10 files changed, 132 insertions, 24 deletions
diff --git a/chrome/common/visitedlink_common.cc b/chrome/common/visitedlink_common.cc index 39273e0..6bda05d 100644 --- a/chrome/common/visitedlink_common.cc +++ b/chrome/common/visitedlink_common.cc @@ -29,7 +29,7 @@ bool VisitedLinkCommon::IsVisited(const char* canonical_url, NOTREACHED(); return false; } - return IsVisited(ComputeURLFingerprint(canonical_url, url_len, salt_)); + return IsVisited(ComputeURLFingerprint(canonical_url, url_len)); } bool VisitedLinkCommon::IsVisited(Fingerprint fingerprint) const { diff --git a/chrome/common/visitedlink_common.h b/chrome/common/visitedlink_common.h index 65f540b..06a4f5c 100644 --- a/chrome/common/visitedlink_common.h +++ b/chrome/common/visitedlink_common.h @@ -55,13 +55,20 @@ class VisitedLinkCommon { VisitedLinkCommon(); virtual ~VisitedLinkCommon(); - // Computes the fingerprint of the key and looks it up in the table. We - // return true if found. Does not modify the hastable. The input should be - // the canonical 16-bit URL. + // Returns the fingerprint for the given URL. + Fingerprint ComputeURLFingerprint(const char* canonical_url, + size_t url_len) const { + return ComputeURLFingerprint(canonical_url, url_len, salt_); + } + + // Looks up the given key in the table. The fingerprint for the URL is + // computed if you call one with the string argument. Returns true if found. + // Does not modify the hastable. bool IsVisited(const char* canonical_url, size_t url_len) const; bool IsVisited(const GURL& url) const { return IsVisited(url.spec().data(), url.spec().size()); } + bool IsVisited(Fingerprint fingerprint) const; #ifdef UNIT_TEST // Returns statistics about DB usage @@ -93,12 +100,10 @@ class VisitedLinkCommon { return hash_table_[table_offset]; } - // Returns true if the given fingerprint is in the table. - bool IsVisited(Fingerprint fingerprint) const; - // Computes the fingerprint of the given canonical URL. It is static so the // same algorithm can be re-used by the table rebuilder, so you will have to - // pass the salt as a parameter. + // pass the salt as a parameter. See the non-static version above if you + // want to use the current class' salt. static Fingerprint ComputeURLFingerprint(const char* canonical_url, size_t url_len, const uint8 salt[LINK_SALT_LENGTH]); diff --git a/chrome/renderer/renderer_glue.cc b/chrome/renderer/renderer_glue.cc index 35f2a73..bf325fb 100644 --- a/chrome/renderer/renderer_glue.cc +++ b/chrome/renderer/renderer_glue.cc @@ -252,6 +252,15 @@ webkit_glue::ScreenInfo webkit_glue::GetScreenInfo(gfx::NativeView window) { return results; } +uint64 webkit_glue::VisitedLinkHash(const char* canonical_url, size_t length) { + return RenderThread::current()->visited_link_slave()->ComputeURLFingerprint( + canonical_url, length); +} + +bool webkit_glue::IsLinkVisited(uint64 link_hash) { + return RenderThread::current()->visited_link_slave()->IsVisited(link_hash); +} + #ifndef USING_SIMPLE_RESOURCE_LOADER_BRIDGE // Each RenderView has a ResourceDispatcher. In unit tests, this function may diff --git a/webkit/build/WebCore/WebCore.vcproj b/webkit/build/WebCore/WebCore.vcproj index d50a256..c32d654 100644 --- a/webkit/build/WebCore/WebCore.vcproj +++ b/webkit/build/WebCore/WebCore.vcproj @@ -1042,10 +1042,6 @@ >
</File>
<File
- RelativePath="..\..\..\third_party\WebKit\WebCore\platform\LinkHash.cpp"
- >
- </File>
- <File
RelativePath="..\..\..\third_party\WebKit\WebCore\platform\LinkHash.h"
>
</File>
diff --git a/webkit/build/port/port.vcproj b/webkit/build/port/port.vcproj index 0bebbd2..5e7eee0 100644 --- a/webkit/build/port/port.vcproj +++ b/webkit/build/port/port.vcproj @@ -928,6 +928,10 @@ >
</File>
<File
+ RelativePath="..\..\port\platform\chromium\LinkHashChromium.cpp"
+ >
+ </File>
+ <File
RelativePath="..\..\port\platform\chromium\MimeTypeRegistryChromium.cpp"
>
</File>
diff --git a/webkit/glue/chromium_bridge_impl.cc b/webkit/glue/chromium_bridge_impl.cc index c02d472..6c66835 100644 --- a/webkit/glue/chromium_bridge_impl.cc +++ b/webkit/glue/chromium_bridge_impl.cc @@ -33,6 +33,7 @@ #include "base/time.h" #include "base/trace_event.h" #include "build/build_config.h" +#include "googleurl/src/url_util.h" #include "net/base/mime_util.h" #if USE(V8) #include <v8.h> @@ -521,6 +522,41 @@ KURL ChromiumBridge::inspectorURL() { return webkit_glue::GURLToKURL(webkit_glue::GetInspectorURL()); } +// Visited links -------------------------------------------------------------- + +WebCore::LinkHash ChromiumBridge::visitedLinkHash(const UChar* url, + unsigned length) { + url_canon::RawCanonOutput<2048> buffer; + url_parse::Parsed parsed; + if (!url_util::Canonicalize(url, length, NULL, &buffer, &parsed)) + return false; // Invalid URLs are unvisited. + return webkit_glue::VisitedLinkHash(buffer.data(), buffer.length()); +} + +WebCore::LinkHash ChromiumBridge::visitedLinkHash( + const WebCore::KURL& base, + const WebCore::AtomicString& attributeURL) { + // Resolve the relative URL using googleurl and pass the absolute URL up to + // the embedder. We could create a GURL object from the base and resolve the + // relative URL that way, but calling the lower-level functions directly + // saves us the std::string allocation in most cases. + url_canon::RawCanonOutput<2048> buffer; + url_parse::Parsed parsed; + + WebCore::CString cstr = base.utf8String(); + if (!url_util::ResolveRelative(cstr.data(), cstr.length(), base.parsed(), + attributeURL.characters(), + attributeURL.length(), NULL, + &buffer, &parsed)) + return false; // Invalid resolved URL. + + return webkit_glue::VisitedLinkHash(buffer.data(), buffer.length()); +} + +bool ChromiumBridge::isLinkVisited(WebCore::LinkHash visitedLinkHash) { + return webkit_glue::IsLinkVisited(visitedLinkHash); +} + // Widget --------------------------------------------------------------------- void ChromiumBridge::widgetSetCursor(Widget* widget, const Cursor& cursor) { @@ -535,12 +571,4 @@ void ChromiumBridge::widgetSetFocus(Widget* widget) { chrome_client->focus(); } -// Link history --------------------------------------------------------------- - -bool ChromiumBridge::isLinkVisited(LinkHash) { - // NOT IMPLEMENTED - // http://code.google.com/p/chromium/issues/detail?id=5401 - return false; -} - } // namespace WebCore diff --git a/webkit/glue/webkit_glue.h b/webkit/glue/webkit_glue.h index 51e60e5..843c6e7 100644 --- a/webkit/glue/webkit_glue.h +++ b/webkit/glue/webkit_glue.h @@ -273,6 +273,14 @@ void SetForcefullyTerminatePluginProcess(bool value); // instead of exiting cleanly. bool ShouldForcefullyTerminatePluginProcess(); +// Returns the hash for the given canonicalized URL for use in visited link +// coloring. +uint64 VisitedLinkHash(const char* canonical_url, size_t length); + +// Returns whether the given link hash is in the user's history. The hash must +// have been generated by calling VisitedLinkHash(). +bool IsLinkVisited(uint64 link_hash); + } // namespace webkit_glue #endif // WEBKIT_GLUE_WEBKIT_GLUE_H_ diff --git a/webkit/port/platform/chromium/ChromiumBridge.h b/webkit/port/platform/chromium/ChromiumBridge.h index eaf0ccd..a882df9 100644 --- a/webkit/port/platform/chromium/ChromiumBridge.h +++ b/webkit/port/platform/chromium/ChromiumBridge.h @@ -85,7 +85,7 @@ namespace WebCore { #if PLATFORM(WIN_OS) static bool ensureFontLoaded(HFONT font); #endif - + // Forms -------------------------------------------------------------- static void notifyFormStateChanged(const Document* doc); @@ -145,12 +145,15 @@ namespace WebCore { // URL ---------------------------------------------------------------- static KURL inspectorURL(); + // Visited links ------------------------------------------------------ + static LinkHash visitedLinkHash(const UChar* url, unsigned length); + static LinkHash visitedLinkHash(const KURL& base, + const AtomicString& attributeURL); + static bool isLinkVisited(LinkHash); + // Widget ------------------------------------------------------------- static void widgetSetCursor(Widget*, const Cursor&); static void widgetSetFocus(Widget*); - - // Link history ------------------------------------------------------- - static bool isLinkVisited(LinkHash); }; } diff --git a/webkit/port/platform/chromium/LinkHashChromium.cpp b/webkit/port/platform/chromium/LinkHashChromium.cpp new file mode 100644 index 0000000..91a7195 --- /dev/null +++ b/webkit/port/platform/chromium/LinkHashChromium.cpp @@ -0,0 +1,47 @@ +// 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 "LinkHash.h" + +#include "ChromiumBridge.h" + +namespace WebCore { + +LinkHash visitedLinkHash(const UChar* url, unsigned length) +{ + return ChromiumBridge::visitedLinkHash(url, length); +} + +LinkHash visitedLinkHash(const KURL& base, const AtomicString& attributeURL) +{ + return ChromiumBridge::visitedLinkHash(base, attributeURL); +} + +} // namespace WebCore diff --git a/webkit/tools/test_shell/test_shell.cc b/webkit/tools/test_shell/test_shell.cc index 87da3bd..6367712 100644 --- a/webkit/tools/test_shell/test_shell.cc +++ b/webkit/tools/test_shell/test_shell.cc @@ -566,4 +566,12 @@ std::wstring GetWebKitLocale() { return L"en-US"; } +uint64 VisitedLinkHash(const char* canonical_url, size_t length) { + return 0; +} + +bool IsLinkVisited(uint64 link_hash) { + return false; +} + } // namespace webkit_glue |