diff --git a/example/quickwindow.qml b/example/quickwindow.qml index 9c90e7241f38d37931f232db0a566a7a33ad7937..54b82d6c7ef742f3b3506dc614f45a9ebcdca3f8 100644 --- a/example/quickwindow.qml +++ b/example/quickwindow.qml @@ -84,6 +84,7 @@ Item { anchors.bottom: parent.bottom anchors.left: parent.left anchors.right: parent.right + url: "http://qt-project.org/" Binding { target: webContentsView.children[0] diff --git a/example/widgetwindow.cpp b/example/widgetwindow.cpp index 89982e509bf8ff8eab8df9c0d4a9fcb31368fd2c..159952715913986b6bf31f313521723a5b3e003a 100644 --- a/example/widgetwindow.cpp +++ b/example/widgetwindow.cpp @@ -84,6 +84,8 @@ WidgetWindow::WidgetWindow() connect(reloadButton, SIGNAL(clicked()), m_webView.data(), SLOT(reload())); connect(m_webView.data(), SIGNAL(titleChanged(const QString&)), SLOT(setWindowTitle(const QString&))); connect(m_webView.data(), SIGNAL(urlChanged(const QUrl&)), SLOT(setAddressBarUrl(const QUrl&))); + + m_webView->load(QUrl(QStringLiteral("http://qt-project.org/"))); } WidgetWindow::~WidgetWindow() diff --git a/lib/browser_context_qt.h b/lib/browser_context_qt.h index dc667cd485e9089b923d60f889209bbddb86f66b..33e23604486e886e70c1f5f259f684cdd9ba9546 100644 --- a/lib/browser_context_qt.h +++ b/lib/browser_context_qt.h @@ -47,7 +47,6 @@ #include "base/files/scoped_temp_dir.h" #include "base/time.h" -#include "content/public/browser/browser_thread.h" #include "content/public/browser/content_browser_client.h" #include "content/public/browser/resource_context.h" #include "content/public/browser/storage_partition.h" @@ -60,8 +59,6 @@ #include "resource_context_qt.h" #include "url_request_context_getter_qt.h" - - class BrowserContextQt : public content::BrowserContext { public: diff --git a/lib/content_browser_client_qt.cpp b/lib/content_browser_client_qt.cpp index d974e8e79b390c241aeb2407199354af94af930b..68eab7f6546044f349c3d203295d9c90147eb52a 100644 --- a/lib/content_browser_client_qt.cpp +++ b/lib/content_browser_client_qt.cpp @@ -42,31 +42,11 @@ #include "content_browser_client_qt.h" #include "content/public/browser/browser_main_parts.h" -#include "content/public/browser/notification_source.h" -#include "content/public/browser/notification_types.h" -#include "content/public/browser/render_process_host.h" #include "content/public/common/main_function_params.h" -#include "net/base/net_module.h" -#include "net/base/net_util.h" #include "browser_context_qt.h" #include "web_contents_view_qt.h" -static GURL GetStartupURL() { - CommandLine* command_line = CommandLine::ForCurrentProcess(); - const CommandLine::StringVector& args = command_line->GetArgs(); - - if (args.empty()) - return GURL("http://www.google.com/"); - - GURL url(args[0]); - if (url.is_valid() && url.has_scheme()) - return url; - - return net::FilePathToFileURL(base::FilePath(args[0])); -} - - class BrowserMainPartsQt : public content::BrowserMainParts { public: diff --git a/lib/qquickwebcontentsview.cpp b/lib/qquickwebcontentsview.cpp index 154f4ea5e4ffaace1bc064e1be1ccef10a5d2e18..dec5211835208c616717998670dd702ba2d9d173 100644 --- a/lib/qquickwebcontentsview.cpp +++ b/lib/qquickwebcontentsview.cpp @@ -45,8 +45,6 @@ #define CONTENT_IMPLEMENTATION #include "content/public/browser/web_contents.h" -#include "content/public/browser/web_contents_view.h" -#include "ipc/ipc_message.h" #include "browser_context_qt.h" #include "content_browser_client_qt.h" @@ -76,7 +74,7 @@ QQuickWebContentsView::QQuickWebContentsView() d->context = WebEngineContext::current(); content::BrowserContext* browser_context = static_cast<ContentBrowserClientQt*>(content::GetContentClient()->browser())->browser_context(); - d->webContentsDelegate.reset(WebContentsDelegateQt::CreateNewWindow(browser_context, GURL(std::string("http://qt-project.org/")), NULL, MSG_ROUTING_NONE, gfx::Size())); + d->webContentsDelegate.reset(WebContentsDelegateQt::CreateNewWindow(browser_context, NULL, MSG_ROUTING_NONE, gfx::Size())); WebContentsViewQt* content_view = static_cast<WebContentsViewQt*>(d->webContentsDelegate->web_contents()->GetView()); QQuickItem* windowContainer = content_view->windowContainer()->qQuickItem(); windowContainer->setParentItem(this); diff --git a/lib/qwebcontentsview.cpp b/lib/qwebcontentsview.cpp index 35eed18237b0aa35b7f643404e4d2df61351d5b2..5cff52ad40ab3bc005a06b2a592dfb4dff847460 100644 --- a/lib/qwebcontentsview.cpp +++ b/lib/qwebcontentsview.cpp @@ -45,8 +45,6 @@ #define CONTENT_IMPLEMENTATION #include "content/public/browser/web_contents.h" -#include "content/public/browser/web_contents_view.h" -#include "ipc/ipc_message.h" #include "browser_context_qt.h" #include "content_browser_client_qt.h" @@ -55,7 +53,6 @@ #include "web_engine_context.h" #include <QVBoxLayout> -#include <QWidget> #include <QUrl> class QWebContentsViewPrivate @@ -72,7 +69,7 @@ QWebContentsView::QWebContentsView() d->context = WebEngineContext::current(); content::BrowserContext* browser_context = static_cast<ContentBrowserClientQt*>(content::GetContentClient()->browser())->browser_context(); - d->webContentsDelegate.reset(WebContentsDelegateQt::CreateNewWindow(browser_context, GURL(std::string("http://qt-project.org/")), NULL, MSG_ROUTING_NONE, gfx::Size())); + d->webContentsDelegate.reset(WebContentsDelegateQt::CreateNewWindow(browser_context, NULL, MSG_ROUTING_NONE, gfx::Size())); QVBoxLayout *layout = new QVBoxLayout; setLayout(layout); diff --git a/lib/web_contents_delegate_qt.cpp b/lib/web_contents_delegate_qt.cpp index db470c7e4664f19c34034eae5ce5f6e442b75cfa..71f3e6d9c1f9252107d1858785829dfd423d6930 100644 --- a/lib/web_contents_delegate_qt.cpp +++ b/lib/web_contents_delegate_qt.cpp @@ -41,42 +41,23 @@ #include "web_contents_delegate_qt.h" +#include "content/public/browser/render_view_host.h" #include "content/public/browser/web_contents.h" -#include "content/public/browser/navigation_controller.h" +#include "content/public/common/renderer_preferences.h" -#include "web_contents_view_qt.h" -#include "qwebcontentsview.h" -#include "qquickwebcontentsview.h" - -#include <QWidget> -#include <QVBoxLayout> -#include <QToolButton> -#include <QLineEdit> -#include <QQuickView> #include <QGuiApplication> #include <QStyleHints> static const int kTestWindowWidth = 800; static const int kTestWindowHeight = 600; -std::vector<WebContentsDelegateQt*> WebContentsDelegateQt::m_windows; - WebContentsDelegateQt::WebContentsDelegateQt(content::WebContents* web_contents) : m_webContents(web_contents) { m_webContents->SetDelegate(this); - // const CommandLine& command_line = *CommandLine::ForCurrentProcess(); - // registrar_.Add(this, NOTIFICATION_WEB_CONTENTS_TITLE_UPDATED, - // Source<WebContents>(web_contents)); - m_windows.push_back(this); - - // if (!shell_created_callback_.is_null()) { - // shell_created_callback_.Run(this); - // shell_created_callback_.Reset(); - // } } -WebContentsDelegateQt* WebContentsDelegateQt::CreateNewWindow(content::BrowserContext* browser_context, const GURL& url, content::SiteInstance* site_instance, int routing_id, const gfx::Size& initial_size) +WebContentsDelegateQt* WebContentsDelegateQt::CreateNewWindow(content::BrowserContext* browser_context, content::SiteInstance* site_instance, int routing_id, const gfx::Size& initial_size) { content::WebContents::CreateParams create_params(browser_context, site_instance); create_params.routing_id = routing_id; @@ -95,8 +76,6 @@ WebContentsDelegateQt* WebContentsDelegateQt::CreateNewWindow(content::BrowserCo rendererPrefs->caret_blink_interval = 0.5 * static_cast<double>(qtCursorFlashTime) / 1000; delegate->m_webContents->GetRenderViewHost()->SyncRendererPrefs(); - if (!url.is_empty()) - delegate->LoadURL(url); return delegate; } @@ -105,35 +84,6 @@ content::WebContents* WebContentsDelegateQt::web_contents() return m_webContents.get(); } - -void WebContentsDelegateQt::GoBackOrForward(int offset) { - m_webContents->GetController().GoToOffset(offset); - m_webContents->GetView()->Focus(); -} - -void WebContentsDelegateQt::Reload() { - m_webContents->GetController().Reload(false); - m_webContents->GetView()->Focus(); -} - -void WebContentsDelegateQt::Stop() { - m_webContents->Stop(); - m_webContents->GetView()->Focus(); -} - -void WebContentsDelegateQt::LoadURL(const GURL& url) -{ - LoadURLForFrame(url, std::string()); -} - -void WebContentsDelegateQt::LoadURLForFrame(const GURL& url, const std::string& frame_name) { - content::NavigationController::LoadURLParams params(url); - params.transition_type = content::PageTransitionFromInt(content::PAGE_TRANSITION_TYPED | content::PAGE_TRANSITION_FROM_ADDRESS_BAR); - params.frame_name = frame_name; - m_webContents->GetController().LoadURLWithParams(params); - m_webContents->GetView()->Focus(); -} - void WebContentsDelegateQt::Observe(int, const content::NotificationSource&, const content::NotificationDetails&) { // IMPLEMENT THIS!!!! diff --git a/lib/web_contents_delegate_qt.h b/lib/web_contents_delegate_qt.h index 4f289269ebcdec34ee01454153324c23eef96166..6e4a16ff4cafb8fcdff5243ba4749306b807ea33 100644 --- a/lib/web_contents_delegate_qt.h +++ b/lib/web_contents_delegate_qt.h @@ -51,20 +51,12 @@ namespace content { class SiteInstance; } -class QWebContentsView; -class QQuickWebContentsView; - class WebContentsDelegateQt : public content::WebContentsDelegate , public content::NotificationObserver { public: - static WebContentsDelegateQt* CreateNewWindow(content::BrowserContext*, const GURL&, content::SiteInstance*, int routing_id, const gfx::Size& initial_size); + static WebContentsDelegateQt* CreateNewWindow(content::BrowserContext*, content::SiteInstance*, int routing_id, const gfx::Size& initial_size); content::WebContents* web_contents(); - void LoadURL(const GURL&); - void LoadURLForFrame(const GURL&, const std::string& frame_name); - void GoBackOrForward(int offset); - void Reload(); - void Stop(); virtual void Observe(int, const content::NotificationSource&, const content::NotificationDetails&); @@ -72,8 +64,6 @@ private: WebContentsDelegateQt(content::WebContents*); scoped_ptr<content::WebContents> m_webContents; - - static std::vector<WebContentsDelegateQt*> m_windows; }; #endif diff --git a/lib/web_engine_context.cpp b/lib/web_engine_context.cpp index 2f34c24b4324fe68d68ad9202fa3775e81f0f72b..03cbae051c77a11fda2e94c7d1761661a2e6af0d 100644 --- a/lib/web_engine_context.cpp +++ b/lib/web_engine_context.cpp @@ -118,7 +118,7 @@ int GetTimeIntervalMilliseconds(const base::TimeTicks& from) { } class MessagePumpForUIQt : public QObject, - public base::MessagePump + public base::MessagePump { public: MessagePumpForUIQt() @@ -245,10 +245,7 @@ WebEngineContext::WebEngineContext() static content::BrowserMainRunner *browserRunner = 0; if (!browserRunner) { - //CommandLine::Init(0, 0); - browserRunner = content::BrowserMainRunner::Create(); - browserRunner->Initialize(content::MainFunctionParams(*CommandLine::ForCurrentProcess())); } diff --git a/shared/render_widget_host_view_qt.cpp b/shared/render_widget_host_view_qt.cpp index 4fcdcbf0012f8597353b46bbe4cf16845d282703..46a71059166ccb2306f59f2024632b3c94f206d3 100644 --- a/shared/render_widget_host_view_qt.cpp +++ b/shared/render_widget_host_view_qt.cpp @@ -133,11 +133,6 @@ content::BackingStore *RenderWidgetHostViewQt::AllocBackingStore(const gfx::Size return 0; } -RenderWidgetHostView* RenderWidgetHostViewQt::CreateViewForWidget(content::RenderWidgetHost* widget) -{ - return new RenderWidgetHostViewQt(widget); -} - void RenderWidgetHostViewQt::InitAsChild(gfx::NativeView parent_view) { NativeViewContainerQt* container = reinterpret_cast<NativeViewContainerQt*>(parent_view); @@ -194,11 +189,6 @@ gfx::NativeView RenderWidgetHostViewQt::GetNativeView() const return gfx::NativeView(); } -NativeViewQt* RenderWidgetHostViewQt::GetNativeViewQt() const -{ - return m_view; -} - gfx::NativeViewId RenderWidgetHostViewQt::GetNativeViewId() const { QT_NOT_YET_IMPLEMENTED diff --git a/shared/render_widget_host_view_qt.h b/shared/render_widget_host_view_qt.h index d21cbf051f2553e72915243f94981ee294e1f4d4..493d89b922f731196c1c382d95c5a0c90a9b38a6 100644 --- a/shared/render_widget_host_view_qt.h +++ b/shared/render_widget_host_view_qt.h @@ -65,7 +65,6 @@ public: bool handleEvent(QEvent* event); virtual content::BackingStore *AllocBackingStore(const gfx::Size &size); - static RenderWidgetHostView* CreateViewForWidget(content::RenderWidgetHost* widget); virtual void InitAsChild(gfx::NativeView parent_view); virtual void InitAsPopup(content::RenderWidgetHostView*, const gfx::Rect&); @@ -74,7 +73,6 @@ public: virtual void SetSize(const gfx::Size& size); virtual void SetBounds(const gfx::Rect& rect); virtual gfx::NativeView GetNativeView() const; - virtual NativeViewQt* GetNativeViewQt() const OVERRIDE; virtual gfx::NativeViewId GetNativeViewId() const; virtual gfx::NativeViewAccessible GetNativeViewAccessible(); virtual void Focus();