2012-04-03 03:34:16 +02:00
|
|
|
// Copyright (c) 2012 The Chromium Embedded Framework Authors.
|
|
|
|
// Portions copyright (c) 2011 The Chromium Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
|
|
|
#include "libcef/renderer/webkit_glue.h"
|
|
|
|
|
|
|
|
#include "base/compiler_specific.h"
|
2013-06-22 04:06:32 +02:00
|
|
|
#include "third_party/WebKit/public/web/WebDocument.h"
|
|
|
|
#include "third_party/WebKit/public/web/WebElement.h"
|
2012-04-03 03:34:16 +02:00
|
|
|
|
2013-05-07 23:48:34 +02:00
|
|
|
#include "config.h"
|
2012-04-03 03:34:16 +02:00
|
|
|
MSVC_PUSH_WARNING_LEVEL(0);
|
2013-05-07 23:48:34 +02:00
|
|
|
#include "bindings/v8/ScriptController.h"
|
2013-06-04 19:41:37 +02:00
|
|
|
#include "core/history/BackForwardController.h"
|
2013-05-07 23:48:34 +02:00
|
|
|
#include "core/page/Page.h"
|
2013-07-24 22:15:18 +02:00
|
|
|
#include "third_party/WebKit/Source/web/WebFrameImpl.h"
|
|
|
|
#include "third_party/WebKit/Source/web/WebViewImpl.h"
|
2012-04-03 03:34:16 +02:00
|
|
|
MSVC_POP_WARNING();
|
|
|
|
#undef LOG
|
|
|
|
|
|
|
|
namespace webkit_glue {
|
|
|
|
|
2013-07-24 22:15:18 +02:00
|
|
|
bool CanGoBack(WebKit::WebView* view) {
|
2012-04-03 03:34:16 +02:00
|
|
|
if (!view)
|
|
|
|
return false;
|
|
|
|
WebKit::WebViewImpl* impl = reinterpret_cast<WebKit::WebViewImpl*>(view);
|
2013-09-03 23:48:12 +02:00
|
|
|
return (impl->page()->backForward().backCount() > 0);
|
2012-04-03 03:34:16 +02:00
|
|
|
}
|
|
|
|
|
2013-07-24 22:15:18 +02:00
|
|
|
bool CanGoForward(WebKit::WebView* view) {
|
|
|
|
if (!view)
|
|
|
|
return false;
|
|
|
|
WebKit::WebViewImpl* impl = reinterpret_cast<WebKit::WebViewImpl*>(view);
|
2013-09-03 23:48:12 +02:00
|
|
|
return (impl->page()->backForward().forwardCount() > 0);
|
2013-07-24 22:15:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void GoBack(WebKit::WebView* view) {
|
|
|
|
if (!view)
|
|
|
|
return;
|
|
|
|
WebKit::WebViewImpl* impl = reinterpret_cast<WebKit::WebViewImpl*>(view);
|
2013-09-03 23:48:12 +02:00
|
|
|
WebCore::BackForwardController& controller = impl->page()->backForward();
|
|
|
|
if (controller.backCount() > 0)
|
|
|
|
controller.goBack();
|
2013-07-24 22:15:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void GoForward(WebKit::WebView* view) {
|
2012-04-03 03:34:16 +02:00
|
|
|
if (!view)
|
|
|
|
return;
|
|
|
|
WebKit::WebViewImpl* impl = reinterpret_cast<WebKit::WebViewImpl*>(view);
|
2013-09-03 23:48:12 +02:00
|
|
|
WebCore::BackForwardController& controller = impl->page()->backForward();
|
|
|
|
if (controller.forwardCount() > 0)
|
|
|
|
controller.goForward();
|
2012-04-03 03:34:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
v8::Handle<v8::Context> GetV8Context(WebKit::WebFrame* frame) {
|
|
|
|
WebKit::WebFrameImpl* impl = static_cast<WebKit::WebFrameImpl*>(frame);
|
2012-08-29 00:26:35 +02:00
|
|
|
return WebCore::ScriptController::mainWorldContext(impl->frame());
|
2012-04-03 03:34:16 +02:00
|
|
|
}
|
|
|
|
|
2013-06-04 19:41:37 +02:00
|
|
|
base::string16 DumpDocumentText(WebKit::WebFrame* frame) {
|
|
|
|
// We use the document element's text instead of the body text here because
|
|
|
|
// not all documents have a body, such as XML documents.
|
|
|
|
WebKit::WebElement document_element = frame->document().documentElement();
|
|
|
|
if (document_element.isNull())
|
|
|
|
return base::string16();
|
|
|
|
|
|
|
|
return document_element.innerText();
|
|
|
|
}
|
|
|
|
|
2012-04-03 03:34:16 +02:00
|
|
|
} // webkit_glue
|