diff options
author | brettw@google.com <brettw@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-12-13 17:18:50 +0000 |
---|---|---|
committer | brettw@google.com <brettw@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-12-13 17:18:50 +0000 |
commit | 8a6e174c293dfcce6b1c409f5f508537eaaa7f9c (patch) | |
tree | f4014f19df5697338cf5977fd5a70ec8c2b00c0c /webkit/glue | |
parent | dca408e49016c2bdf1fef64be587f6f2d3b81cf8 (diff) | |
download | chromium_src-8a6e174c293dfcce6b1c409f5f508537eaaa7f9c.zip chromium_src-8a6e174c293dfcce6b1c409f5f508537eaaa7f9c.tar.gz chromium_src-8a6e174c293dfcce6b1c409f5f508537eaaa7f9c.tar.bz2 |
Implement visited link coloring.
Review URL: http://codereview.chromium.org/12928
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@6970 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue')
-rw-r--r-- | webkit/glue/chromium_bridge_impl.cc | 44 | ||||
-rw-r--r-- | webkit/glue/webkit_glue.h | 8 |
2 files changed, 44 insertions, 8 deletions
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_ |