Share sky::PlatformImpl bettween sky_viewer and SkyShell

This should let SkyShell load images.

R=eseidel@chromium.org
BUG=https://github.com/domokit/mojo/issues/52

Review URL: https://codereview.chromium.org/959773005
This commit is contained in:
Adam Barth 2015-02-25 14:26:53 -08:00
parent f5c662cbbd
commit 24c33e48dc
5 changed files with 11 additions and 78 deletions

View File

@ -47,8 +47,6 @@ shared_library("sky_shell") {
"ui/engine.h", "ui/engine.h",
"ui/input_event_converter.cc", "ui/input_event_converter.cc",
"ui/input_event_converter.h", "ui/input_event_converter.h",
"ui/platform_impl.cc",
"ui/platform_impl.h",
"ui_delegate.cc", "ui_delegate.cc",
"ui_delegate.h", "ui_delegate.h",
] ]
@ -65,6 +63,7 @@ shared_library("sky_shell") {
"//mojo/services/network/public/interfaces", "//mojo/services/network/public/interfaces",
"//skia", "//skia",
"//sky/engine", "//sky/engine",
"//sky/services/platform",
"//sky/services/viewport", "//sky/services/viewport",
"//ui/gfx/geometry", "//ui/gfx/geometry",
"//ui/gl", "//ui/gl",

View File

@ -5,14 +5,15 @@
#include "sky/shell/ui/engine.h" #include "sky/shell/ui/engine.h"
#include "base/bind.h" #include "base/bind.h"
#include "mojo/public/cpp/application/connect.h"
#include "sky/engine/public/platform/WebInputEvent.h" #include "sky/engine/public/platform/WebInputEvent.h"
#include "sky/engine/public/web/Sky.h" #include "sky/engine/public/web/Sky.h"
#include "sky/engine/public/web/WebLocalFrame.h" #include "sky/engine/public/web/WebLocalFrame.h"
#include "sky/engine/public/web/WebSettings.h" #include "sky/engine/public/web/WebSettings.h"
#include "sky/engine/public/web/WebView.h" #include "sky/engine/public/web/WebView.h"
#include "sky/services/platform/platform_impl.h"
#include "sky/shell/ui/animator.h" #include "sky/shell/ui/animator.h"
#include "sky/shell/ui/input_event_converter.h" #include "sky/shell/ui/input_event_converter.h"
#include "sky/shell/ui/platform_impl.h"
#include "third_party/skia/include/core/SkCanvas.h" #include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/core/SkPictureRecorder.h" #include "third_party/skia/include/core/SkPictureRecorder.h"
@ -46,9 +47,13 @@ base::WeakPtr<Engine> Engine::GetWeakPtr() {
return weak_factory_.GetWeakPtr(); return weak_factory_.GetWeakPtr();
} }
void Engine::Init(mojo::ScopedMessagePipeHandle service_provider) { void Engine::Init(mojo::ScopedMessagePipeHandle service_provider_handle) {
platform_impl_.reset(new PlatformImpl( mojo::ServiceProviderPtr service_provider =
mojo::MakeProxy<mojo::ServiceProvider>(service_provider.Pass()))); mojo::MakeProxy<mojo::ServiceProvider>(service_provider_handle.Pass());
mojo::NetworkServicePtr network_service;
mojo::ConnectToService(service_provider.get(), &network_service);
platform_impl_.reset(new PlatformImpl(network_service.Pass()));
blink::initialize(platform_impl_.get()); blink::initialize(platform_impl_.get());
} }

View File

@ -20,9 +20,9 @@
#include "ui/gfx/geometry/size.h" #include "ui/gfx/geometry/size.h"
namespace sky { namespace sky {
class PlatformImpl;
namespace shell { namespace shell {
class Animator; class Animator;
class PlatformImpl;
class Engine : public UIDelegate, class Engine : public UIDelegate,
public ViewportObserver, public ViewportObserver,

View File

@ -1,34 +0,0 @@
// 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"
#include "mojo/public/cpp/application/connect.h"
namespace sky {
namespace shell {
PlatformImpl::PlatformImpl(mojo::ServiceProviderPtr service_provider)
: main_thread_task_runner_(base::MessageLoop::current()->task_runner()),
service_provider_(service_provider.Pass()) {
mojo::ConnectToService(service_provider_.get(), &network_service_);
}
PlatformImpl::~PlatformImpl() {
}
blink::WebString PlatformImpl::defaultLocale() {
return blink::WebString::fromUTF8("en-US");
}
base::SingleThreadTaskRunner* PlatformImpl::mainThreadTaskRunner() {
return main_thread_task_runner_.get();
}
mojo::NetworkService* PlatformImpl::networkService() {
return network_service_.get();
}
} // namespace shell
} // namespace sky

View File

@ -1,37 +0,0 @@
// 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 "mojo/public/interfaces/application/service_provider.mojom.h"
#include "mojo/services/network/public/interfaces/network_service.mojom.h"
#include "sky/engine/public/platform/Platform.h"
namespace sky {
namespace shell {
class PlatformImpl : public blink::Platform {
public:
explicit PlatformImpl(mojo::ServiceProviderPtr service_provider);
~PlatformImpl() override;
// blink::Platform:
blink::WebString defaultLocale() override;
base::SingleThreadTaskRunner* mainThreadTaskRunner() override;
mojo::NetworkService* networkService() override;
private:
scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_;
mojo::ServiceProviderPtr service_provider_;
mojo::NetworkServicePtr network_service_;
DISALLOW_COPY_AND_ASSIGN(PlatformImpl);
};
} // namespace shell
} // namespace sky
#endif // SKY_SHELL_UI_PLATFORM_IMPL_H_