summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPierre Rossi <pierre.rossi@digia.com>2014-03-05 11:06:09 +0100
committerAllan Sandfeld Jensen <allan.jensen@digia.com>2014-08-08 17:19:15 +0200
commit3860d79c0b0d1c623746e40b1d0234674535cc90 (patch)
tree57a52a6e52c26bcbb2d73410e92aaefdd5d52caf
parent5c89832668288db79ed0c79d3dda68af62285d18 (diff)
Use VisitedLinks component.
This allows to resolve visited links in the render process. The newly introduced API at the Core layer should allow exposing this functionality to our widgets and Qt quick API layers. Change-Id: I256376afcfe79014dc274e2dddbac1986a884a93 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@digia.com>
-rw-r--r--src/core/core_gyp_generator.pro2
-rw-r--r--src/core/qtwebengine.gypi8
-rw-r--r--src/core/renderer/content_renderer_client_qt.cpp25
-rw-r--r--src/core/renderer/content_renderer_client_qt.h14
-rw-r--r--src/core/web_contents_delegate_qt.cpp8
-rw-r--r--src/core/web_contents_delegate_qt.h1
-rw-r--r--src/core/web_engine_context.cpp9
-rw-r--r--src/core/web_engine_context.h4
-rw-r--r--src/core/web_engine_visited_links_manager.cpp105
-rw-r--r--src/core/web_engine_visited_links_manager.h78
-rwxr-xr-xtools/scripts/take_snapshot.py2
11 files changed, 253 insertions, 3 deletions
diff --git a/src/core/core_gyp_generator.pro b/src/core/core_gyp_generator.pro
index 5e6d0821..8d8298e9 100644
--- a/src/core/core_gyp_generator.pro
+++ b/src/core/core_gyp_generator.pro
@@ -76,6 +76,7 @@ SOURCES = \
web_engine_context.cpp \
web_engine_error.cpp \
web_engine_library_info.cpp \
+ web_engine_visited_links_manager.cpp \
web_event_factory.cpp \
yuv_video_node.cpp
@@ -122,5 +123,6 @@ HEADERS = \
web_engine_context.h \
web_engine_error.h \
web_engine_library_info.h \
+ web_engine_visited_links_manager.h \
web_event_factory.h \
yuv_video_node.h
diff --git a/src/core/qtwebengine.gypi b/src/core/qtwebengine.gypi
index d1bee5fb..f4482a85 100644
--- a/src/core/qtwebengine.gypi
+++ b/src/core/qtwebengine.gypi
@@ -6,6 +6,10 @@
'version_script_location%': '<(chromium_src_dir)/chrome/tools/build/version.py',
},
'dependencies': [
+ '<(chromium_src_dir)/base/base.gyp:base',
+ '<(chromium_src_dir)/base/third_party/dynamic_annotations/dynamic_annotations.gyp:dynamic_annotations',
+ '<(chromium_src_dir)/components/components.gyp:visitedlink_browser',
+ '<(chromium_src_dir)/components/components.gyp:visitedlink_renderer',
'<(chromium_src_dir)/content/content.gyp:content',
'<(chromium_src_dir)/content/content.gyp:content_app_browser',
'<(chromium_src_dir)/content/content.gyp:content_browser',
@@ -15,19 +19,17 @@
'<(chromium_src_dir)/content/content.gyp:content_utility',
'<(chromium_src_dir)/content/content.gyp:content_worker',
'<(chromium_src_dir)/content/content_resources.gyp:content_resources',
- '<(chromium_src_dir)/base/base.gyp:base',
- '<(chromium_src_dir)/base/third_party/dynamic_annotations/dynamic_annotations.gyp:dynamic_annotations',
'<(chromium_src_dir)/ipc/ipc.gyp:ipc',
'<(chromium_src_dir)/media/media.gyp:media',
'<(chromium_src_dir)/net/net.gyp:net',
'<(chromium_src_dir)/net/net.gyp:net_resources',
'<(chromium_src_dir)/skia/skia.gyp:skia',
+ '<(chromium_src_dir)/third_party/WebKit/Source/web/web.gyp:webkit',
'<(chromium_src_dir)/ui/gl/gl.gyp:gl',
'<(chromium_src_dir)/ui/ui.gyp:ui',
'<(chromium_src_dir)/url/url.gyp:url_lib',
'<(chromium_src_dir)/v8/tools/gyp/v8.gyp:v8',
'<(chromium_src_dir)/webkit/glue/webkit_glue.gyp:*',
- '<(chromium_src_dir)/third_party/WebKit/Source/web/web.gyp:webkit',
'chrome_qt.gyp:chrome_qt',
],
'include_dirs': [
diff --git a/src/core/renderer/content_renderer_client_qt.cpp b/src/core/renderer/content_renderer_client_qt.cpp
index ecb469a9..af1ba7dc 100644
--- a/src/core/renderer/content_renderer_client_qt.cpp
+++ b/src/core/renderer/content_renderer_client_qt.cpp
@@ -43,6 +43,7 @@
#include "base/strings/utf_string_conversions.h"
#include "chrome/common/localized_error.h"
+#include "components/visitedlink/renderer/visitedlink_slave.h"
#include "content/public/renderer/render_thread.h"
#include "net/base/net_errors.h"
#include "third_party/WebKit/public/platform/WebURLError.h"
@@ -56,6 +57,20 @@
static const char kHttpErrorDomain[] = "http";
+ContentRendererClientQt::ContentRendererClientQt()
+{
+}
+
+ContentRendererClientQt::~ContentRendererClientQt()
+{
+}
+
+void ContentRendererClientQt::RenderThreadStarted()
+{
+ m_visitedLinkSlave.reset(new visitedlink::VisitedLinkSlave);
+ content::RenderThread::Get()->AddObserver(m_visitedLinkSlave.data());
+}
+
void ContentRendererClientQt::RenderViewCreated(content::RenderView* render_view)
{
// RenderViewObserver destroys itself with its RenderView.
@@ -93,3 +108,13 @@ void ContentRendererClientQt::GetNavigationErrorStrings(blink::WebFrame *frame,
*error_description = LocalizedError::GetErrorDetails(error, isPost);
}
}
+
+unsigned long long ContentRendererClientQt::VisitedLinkHash(const char *canonicalUrl, size_t length)
+{
+ return m_visitedLinkSlave->ComputeURLFingerprint(canonicalUrl, length);
+}
+
+bool ContentRendererClientQt::IsLinkVisited(unsigned long long linkHash)
+{
+ return m_visitedLinkSlave->IsVisited(linkHash);
+}
diff --git a/src/core/renderer/content_renderer_client_qt.h b/src/core/renderer/content_renderer_client_qt.h
index 360e82f2..00705cdc 100644
--- a/src/core/renderer/content_renderer_client_qt.h
+++ b/src/core/renderer/content_renderer_client_qt.h
@@ -42,12 +42,26 @@
#include "content/public/renderer/content_renderer_client.h"
#include <QtGlobal>
+#include <QScopedPointer>
+
+namespace visitedlink {
+class VisitedLinkSlave;
+}
class ContentRendererClientQt : public content::ContentRendererClient {
public:
+ ContentRendererClientQt();
+ ~ContentRendererClientQt();
+ virtual void RenderThreadStarted() Q_DECL_OVERRIDE;
virtual void RenderViewCreated(content::RenderView *render_view) Q_DECL_OVERRIDE;
virtual bool ShouldSuppressErrorPage(const GURL &) Q_DECL_OVERRIDE { return false; }
virtual void GetNavigationErrorStrings(blink::WebFrame* frame, const blink::WebURLRequest& failed_request, const blink::WebURLError& error
, const std::string& accept_languages, std::string* error_html, base::string16* error_description) Q_DECL_OVERRIDE;
+
+ virtual unsigned long long VisitedLinkHash(const char *canonicalUrl, size_t length) Q_DECL_OVERRIDE;
+ virtual bool IsLinkVisited(unsigned long long linkHash) Q_DECL_OVERRIDE;
+
+private:
+ QScopedPointer<visitedlink::VisitedLinkSlave> m_visitedLinkSlave;
};
diff --git a/src/core/web_contents_delegate_qt.cpp b/src/core/web_contents_delegate_qt.cpp
index b003a63a..1de3ce16 100644
--- a/src/core/web_contents_delegate_qt.cpp
+++ b/src/core/web_contents_delegate_qt.cpp
@@ -50,6 +50,7 @@
#include "web_contents_adapter.h"
#include "web_contents_adapter_client.h"
#include "web_engine_context.h"
+#include "web_engine_visited_links_manager.h"
#include "content/public/browser/favicon_status.h"
#include "content/public/browser/invalidate_type.h"
@@ -58,6 +59,7 @@
#include "content/public/browser/web_contents.h"
#include "content/public/common/favicon_url.h"
#include "content/public/common/file_chooser_params.h"
+#include "content/public/common/frame_navigate_params.h"
// Maps the LogSeverity defines in base/logging.h to the web engines message levels.
@@ -251,3 +253,9 @@ void WebContentsDelegateQt::UpdateTargetURL(content::WebContents *source, int32
Q_UNUSED(page_id)
m_viewClient->didUpdateTargetURL(toQt(url));
}
+void WebContentsDelegateQt::DidNavigateAnyFrame(const content::LoadCommittedDetails &, const content::FrameNavigateParams &params)
+{
+ if (!params.should_update_history)
+ return;
+ WebEngineContext::current()->visitedLinksManager()->addUrl(params.url);
+}
diff --git a/src/core/web_contents_delegate_qt.h b/src/core/web_contents_delegate_qt.h
index 33f06bf8..44be7719 100644
--- a/src/core/web_contents_delegate_qt.h
+++ b/src/core/web_contents_delegate_qt.h
@@ -84,6 +84,7 @@ public:
virtual void FindReply(content::WebContents *source, int request_id, int number_of_matches, const gfx::Rect& selection_rect, int active_match_ordinal, bool final_update) Q_DECL_OVERRIDE;
virtual void RequestMediaAccessPermission(content::WebContents* web_contents, const content::MediaStreamRequest& request, const content::MediaResponseCallback& callback) Q_DECL_OVERRIDE;
virtual void UpdateTargetURL(content::WebContents *source, int32 page_id, const GURL &url) Q_DECL_OVERRIDE;
+ virtual void DidNavigateAnyFrame(const content::LoadCommittedDetails&, const content::FrameNavigateParams& params) Q_DECL_OVERRIDE;
private:
WebContentsAdapterClient *m_viewClient;
diff --git a/src/core/web_engine_context.cpp b/src/core/web_engine_context.cpp
index 82a6872a..709000c1 100644
--- a/src/core/web_engine_context.cpp
+++ b/src/core/web_engine_context.cpp
@@ -77,6 +77,7 @@
#include "type_conversion.h"
#include "surface_factory_qt.h"
#include "web_engine_library_info.h"
+#include "web_engine_visited_links_manager.h"
#include <QGuiApplication>
#include <QStringList>
#include <QVector>
@@ -109,6 +110,11 @@ scoped_refptr<WebEngineContext> WebEngineContext::current()
return sContext;
}
+WebEngineVisitedLinksManager *WebEngineContext::visitedLinksManager()
+{
+ return m_visitedLinksManager.get();
+}
+
#ifndef CHROMIUM_VERSION
#error Chromium version should be defined at gyp-time. Something must have gone wrong
#define CHROMIUM_VERSION // This is solely to keep Qt Creator happy.
@@ -204,4 +210,7 @@ WebEngineContext::WebEngineContext()
// thread to avoid a thread check assertion in its constructor when it
// first gets referenced on the IO thread.
MediaCaptureDevicesDispatcher::GetInstance();
+
+ // Ensure we have a VisitedLinksMaster instance up and running
+ m_visitedLinksManager.reset(new WebEngineVisitedLinksManager);
}
diff --git a/src/core/web_engine_context.h b/src/core/web_engine_context.h
index 13554066..8a10700f 100644
--- a/src/core/web_engine_context.h
+++ b/src/core/web_engine_context.h
@@ -56,11 +56,14 @@ class ContentMainRunner;
class ContentMainDelegateQt;
class SurfaceFactoryQt;
+class WebEngineVisitedLinksManager;
class WebEngineContext : public base::RefCounted<WebEngineContext> {
public:
static scoped_refptr<WebEngineContext> current();
+ WebEngineVisitedLinksManager *visitedLinksManager();
+
private:
friend class base::RefCounted<WebEngineContext>;
WebEngineContext();
@@ -73,6 +76,7 @@ private:
#if defined(OS_ANDROID)
scoped_ptr<SurfaceFactoryQt> m_surfaceFactory;
#endif
+ scoped_ptr<WebEngineVisitedLinksManager> m_visitedLinksManager;
};
#endif // WEB_ENGINE_CONTEXT_H
diff --git a/src/core/web_engine_visited_links_manager.cpp b/src/core/web_engine_visited_links_manager.cpp
new file mode 100644
index 00000000..c51ce726
--- /dev/null
+++ b/src/core/web_engine_visited_links_manager.cpp
@@ -0,0 +1,105 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtWebEngine module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "web_engine_visited_links_manager.h"
+
+#include "content_browser_client_qt.h"
+#include "browser_context_qt.h"
+#include "type_conversion.h"
+
+#include "base/memory/scoped_ptr.h"
+#include "components/visitedlink/browser/visitedlink_delegate.h"
+#include "components/visitedlink/browser/visitedlink_master.h"
+
+namespace {
+class BasicUrlIterator : public visitedlink::VisitedLinkMaster::URLIterator {
+public:
+ BasicUrlIterator(const QList<QUrl> &urls) : m_urls(urls) {}
+ virtual const GURL& NextURL() { m_currentUrl = toGurl(m_urls.takeFirst()); return m_currentUrl; }
+ virtual bool HasNextURL() const { return !m_urls.isEmpty(); }
+private:
+ QList<QUrl> m_urls;
+ GURL m_currentUrl;
+
+};
+} // Anonymous namespace
+
+// Due to the design of the visitedLink component, it seems safer to provide a
+// basic delegate that will simply rebuild an empty visitedLink table if needed
+// from the application history rather than crashing. This is functionality
+// that was covered by QWebHistoryInterface in QtWebKitWidgets.
+
+class VisitedLinkDelegateQt : public visitedlink::VisitedLinkDelegate
+{
+public:
+ ~VisitedLinkDelegateQt() {}
+ void RebuildTable(const scoped_refptr<URLEnumerator>& enumerator) { enumerator->OnComplete(true); }
+};
+
+void WebEngineVisitedLinksManager::deleteAllVisitedLinkData()
+{
+ m_visitedLinkMaster->DeleteAllURLs();
+}
+
+void WebEngineVisitedLinksManager::deleteVisitedLinkDataForUrls(const QList<QUrl> &urlsToDelete)
+{
+ BasicUrlIterator iterator(urlsToDelete);
+ m_visitedLinkMaster->DeleteURLs(&iterator);
+}
+
+WebEngineVisitedLinksManager::WebEngineVisitedLinksManager()
+ : m_delegate(new VisitedLinkDelegateQt)
+{
+ Q_ASSERT(ContentBrowserClientQt::Get() && ContentBrowserClientQt::Get()->browser_context());
+ BrowserContextQt *browserContext = ContentBrowserClientQt::Get()->browser_context();
+ m_visitedLinkMaster.reset(new visitedlink::VisitedLinkMaster(browserContext, m_delegate.data(), /* persist to disk = */true));
+ m_visitedLinkMaster->Init();
+}
+
+WebEngineVisitedLinksManager::~WebEngineVisitedLinksManager()
+{
+}
+
+void WebEngineVisitedLinksManager::addUrl(const GURL &urlToAdd)
+{
+ Q_ASSERT(m_visitedLinkMaster);
+ m_visitedLinkMaster->AddURL(urlToAdd);
+}
diff --git a/src/core/web_engine_visited_links_manager.h b/src/core/web_engine_visited_links_manager.h
new file mode 100644
index 00000000..0a976d95
--- /dev/null
+++ b/src/core/web_engine_visited_links_manager.h
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtWebEngine module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef WEB_ENGINE_VISITED_LINKS_MANAGER_H
+#define WEB_ENGINE_VISITED_LINKS_MANAGER_H
+
+#include "qtwebenginecoreglobal.h"
+#include <QList>
+#include <QScopedPointer>
+
+QT_BEGIN_NAMESPACE
+class QUrl;
+QT_END_NAMESPACE
+
+namespace visitedlink {
+class VisitedLinkMaster;
+}
+
+class VisitedLinkDelegateQt;
+
+class GURL;
+
+class QWEBENGINE_EXPORT WebEngineVisitedLinksManager {
+
+public:
+ virtual~WebEngineVisitedLinksManager();
+ WebEngineVisitedLinksManager();
+
+ void deleteAllVisitedLinkData();
+ void deleteVisitedLinkDataForUrls(const QList<QUrl> &);
+
+private:
+ void addUrl(const GURL &);
+ friend class WebContentsDelegateQt;
+
+ QScopedPointer<visitedlink::VisitedLinkMaster> m_visitedLinkMaster;
+ QScopedPointer<VisitedLinkDelegateQt> m_delegate;
+};
+
+#endif // WEB_ENGINE_VISITED_LINKS_MANAGER_H
diff --git a/tools/scripts/take_snapshot.py b/tools/scripts/take_snapshot.py
index d6b8fedb..7498a4d7 100755
--- a/tools/scripts/take_snapshot.py
+++ b/tools/scripts/take_snapshot.py
@@ -138,6 +138,8 @@ def isInChromiumBlacklist(file_path):
or file_path.startswith('third_party/apple_sample_code')
or file_path.startswith('third_party/bison')
or file_path.startswith('third_party/brotli')
+ or (file_path.startswith('third_party/cacheinvalidation') and
+ not file_path.endswith('isolate'))
or file_path.startswith('third_party/chromite')
or file_path.startswith('third_party/cld_2')
or file_path.startswith('third_party/codesighs')