提交 1f8dd823 编写于 作者: A Adam Barth

sky/shell should link with sky/engine

This CL causes sky/shell to create a blink::WebView to show that sky/shell
links with sky/engine. In the process, I've made it easier to be a trivial
embedder of sky/engine by removing the requirement to implement
blink::ServiceProvider.

This CL also causes sky/shell to link with mojo/edk/system to resolve link
errors with Mojo fabric (e.g., MojoClose, MojoWriteMessage, etc). To make this
work properly, we'll need to initialize the EDK in a future CL.

R=eseidel@chromium.org

Review URL: https://codereview.chromium.org/873923003
上级 089066f2
......@@ -35,12 +35,12 @@
namespace blink {
PassOwnPtr<FrameHost> FrameHost::create(Page& page, ServiceProvider& services)
PassOwnPtr<FrameHost> FrameHost::create(Page& page, ServiceProvider* services)
{
return adoptPtr(new FrameHost(page, services));
}
FrameHost::FrameHost(Page& page, ServiceProvider& services)
FrameHost::FrameHost(Page& page, ServiceProvider* services)
: m_page(&page)
, m_services(services)
{
......
......@@ -55,14 +55,14 @@ class Settings;
class FrameHost final {
WTF_MAKE_NONCOPYABLE(FrameHost); WTF_MAKE_FAST_ALLOCATED;
public:
static PassOwnPtr<FrameHost> create(Page&, ServiceProvider&);
static PassOwnPtr<FrameHost> create(Page&, ServiceProvider*);
~FrameHost();
// Careful: This function will eventually be removed.
Page& page() const { return *m_page; }
Settings& settings() const;
ServiceProvider& services() const { return m_services; }
ServiceProvider* services() const { return m_services; }
// Corresponds to pixel density of the device where this Page is
// being displayed. In multi-monitor setups this can vary between pages.
......@@ -70,10 +70,10 @@ public:
float deviceScaleFactor() const;
private:
FrameHost(Page&, ServiceProvider&);
FrameHost(Page&, ServiceProvider*);
Page* m_page;
ServiceProvider& m_services;
ServiceProvider* m_services;
};
}
......
......@@ -117,7 +117,7 @@ void HTMLAnchorElement::handleClick(Event* event)
return;
mojo::URLRequestPtr request = mojo::URLRequest::New();
request->url = href().string().toUTF8();
host->services().NavigatorHost()->RequestNavigate(
host->services()->NavigatorHost()->RequestNavigate(
mojo::TARGET_SOURCE_NODE, request.Pass());
event->setDefaultHandled();
}
......
......@@ -62,7 +62,7 @@ float deviceScaleFactor(LocalFrame* frame)
return page->deviceScaleFactor();
}
Page::Page(PageClients& pageClients, ServiceProvider& services)
Page::Page(PageClients& pageClients, ServiceProvider* services)
: SettingsDelegate(Settings::create())
, m_animator(this)
, m_chromeClient(pageClients.chromeClient)
......
......@@ -84,7 +84,7 @@ public:
SpellCheckerClient* spellCheckerClient;
};
Page(PageClients&, ServiceProvider&);
Page(PageClients&, ServiceProvider*);
virtual ~Page();
FrameHost& frameHost() const { return *m_frameHost; }
......
......@@ -7,7 +7,6 @@
namespace mojo {
class NavigatorHost;
class Shell;
}
namespace blink {
......@@ -15,7 +14,6 @@ namespace blink {
class ServiceProvider {
public:
virtual mojo::NavigatorHost* NavigatorHost() = 0;
virtual mojo::Shell* Shell() = 0;
protected:
virtual ~ServiceProvider();
......
......@@ -62,7 +62,7 @@ struct WebSize;
class WebViewClient {
public:
virtual ServiceProvider& services() = 0;
virtual ServiceProvider* services() { return nullptr; }
// Initialize compositing for this widget.
virtual void initializeLayerTreeView() { BLINK_ASSERT_NOT_REACHED(); };
......
......@@ -29,6 +29,10 @@ shared_library("sky_shell") {
"gpu/ganesh_surface.h",
"gpu/rasterizer.cc",
"gpu/rasterizer.h",
"ui/engine.cc",
"ui/engine.h",
"ui/platform_impl.cc",
"ui/platform_impl.h",
"library_loader.cc",
"shell.cc",
"shell.h",
......@@ -38,12 +42,13 @@ shared_library("sky_shell") {
"sky_view.h",
]
configs += [ "//third_party/khronos:khronos_headers" ]
deps = [
"//base",
"//base:i18n",
"//build/config/sanitizers:deps",
"//mojo/edk/system",
"//skia",
"//sky/engine",
"//ui/gfx/geometry",
"//ui/gl",
":jni_headers",
......
......@@ -24,6 +24,13 @@ void Shell::Init() {
gpu_thread_->Start();
rasterizer_.reset(new Rasterizer());
ui_thread_.reset(new base::Thread("ui_thread"));
ui_thread_->Start();
engine_.reset(new Engine());
ui_thread_->message_loop()->PostTask(
FROM_HERE, base::Bind(&Engine::Init, engine_->GetWeakPtr()));
view_.reset(new SkyView(this));
view_->Init();
}
......
......@@ -10,6 +10,7 @@
#include "base/memory/scoped_ptr.h"
#include "sky/shell/gpu/rasterizer.h"
#include "sky/shell/sky_view.h"
#include "sky/shell/ui/engine.h"
namespace base {
class Thread;
......@@ -33,9 +34,11 @@ class Shell : public SkyView::Delegate {
scoped_refptr<base::SingleThreadTaskRunner> java_task_runner_;
scoped_ptr<base::Thread> gpu_thread_;
scoped_ptr<base::Thread> ui_thread_;
scoped_ptr<SkyView> view_;
scoped_ptr<Rasterizer> rasterizer_;
scoped_ptr<Engine> engine_;
DISALLOW_COPY_AND_ASSIGN(Shell);
};
......
......@@ -10,6 +10,7 @@
#include "base/at_exit.h"
#include "base/bind.h"
#include "base/command_line.h"
#include "base/i18n/icu_util.h"
#include "base/lazy_instance.h"
#include "base/logging.h"
#include "base/macros.h"
......@@ -63,6 +64,7 @@ static void Init(JNIEnv* env,
g_java_message_loop.Get().reset(new base::MessageLoopForUI);
base::MessageLoopForUI::current()->Start();
base::i18n::InitializeICU();
gfx::GLSurface::InitializeOneOff();
g_shell.Get().reset(new Shell(g_java_message_loop.Get()->task_runner()));
......
// Copyright 2015 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 "sky/shell/ui/engine.h"
#include "sky/engine/public/web/Sky.h"
#include "sky/engine/public/web/WebLocalFrame.h"
#include "sky/engine/public/web/WebView.h"
#include "sky/shell/ui/platform_impl.h"
namespace sky {
namespace shell {
Engine::Engine() : web_view_(nullptr), weak_factory_(this) {
}
Engine::~Engine() {
if (web_view_)
web_view_->close();
}
base::WeakPtr<Engine> Engine::GetWeakPtr() {
return weak_factory_.GetWeakPtr();
}
void Engine::Init() {
platform_impl_.reset(new PlatformImpl);
blink::initialize(platform_impl_.get());
web_view_ = blink::WebView::create(this);
web_view_->setMainFrame(blink::WebLocalFrame::create(this));
}
} // namespace shell
} // namespace sky
// Copyright 2015 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.
#ifndef SKY_SHELL_UI_ENGINE_H_
#define SKY_SHELL_UI_ENGINE_H_
#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "sky/engine/public/web/WebFrameClient.h"
#include "sky/engine/public/web/WebViewClient.h"
namespace sky {
namespace shell {
class PlatformImpl;
class Engine : public blink::WebFrameClient,
public blink::WebViewClient {
public:
Engine();
~Engine() override;
base::WeakPtr<Engine> GetWeakPtr();
void Init();
private:
scoped_ptr<PlatformImpl> platform_impl_;
blink::WebView* web_view_;
base::WeakPtrFactory<Engine> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(Engine);
};
} // namespace shell
} // namespace sky
#endif // SKY_SHELL_UI_ENGINE_H_
// Copyright 2015 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 "sky/shell/ui/platform_impl.h"
namespace sky {
namespace shell {
PlatformImpl::PlatformImpl()
: main_thread_task_runner_(base::MessageLoop::current()->task_runner()) {
}
PlatformImpl::~PlatformImpl() {
}
blink::WebString PlatformImpl::defaultLocale() {
return blink::WebString::fromUTF8("en-US");
}
base::SingleThreadTaskRunner* PlatformImpl::mainThreadTaskRunner() {
return main_thread_task_runner_.get();
}
} // namespace shell
} // namespace sky
// Copyright 2015 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.
#ifndef SKY_SHELL_UI_PLATFORM_IMPL_H_
#define SKY_SHELL_UI_PLATFORM_IMPL_H_
#include "base/message_loop/message_loop.h"
#include "sky/engine/public/platform/Platform.h"
namespace sky {
namespace shell {
class PlatformImpl : public blink::Platform {
public:
PlatformImpl();
~PlatformImpl() override;
// blink::Platform:
blink::WebString defaultLocale() override;
base::SingleThreadTaskRunner* mainThreadTaskRunner() override;
private:
scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_;
DISALLOW_COPY_AND_ASSIGN(PlatformImpl);
};
} // namespace shell
} // namespace sky
#endif // SKY_SHELL_UI_PLATFORM_IMPL_H_
......@@ -279,18 +279,14 @@ void DocumentView::didCreateScriptContext(blink::WebLocalFrame* frame,
gin::ConvertToV8(isolate, internals));
}
blink::ServiceProvider& DocumentView::services() {
return *this;
blink::ServiceProvider* DocumentView::services() {
return this;
}
mojo::NavigatorHost* DocumentView::NavigatorHost() {
return navigator_host_.get();
}
mojo::Shell* DocumentView::Shell() {
return shell_;
}
void DocumentView::OnViewBoundsChanged(mojo::View* view,
const mojo::Rect& old_bounds,
const mojo::Rect& new_bounds) {
......
......@@ -98,11 +98,10 @@ class DocumentView : public blink::ServiceProvider,
v8::Handle<v8::Context>) override;
// WebViewClient methods:
blink::ServiceProvider& services() override;
blink::ServiceProvider* services() override;
// Services methods:
mojo::NavigatorHost* NavigatorHost() override;
mojo::Shell* Shell() override;
// ViewManagerDelegate methods:
void OnEmbed(mojo::View* root,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册