提交 e55e0605 编写于 作者: A Adam Barth

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
上级 78691e3c
# 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.
source_set("platform") {
sources = [
"net_constants.h",
"platform_impl.cc",
"platform_impl.h",
"url_request_types.cc",
"url_request_types.h",
"weburlloader_impl.cc",
"weburlloader_impl.h",
]
deps = [
"//base",
"//mojo/common",
"//mojo/public/cpp/bindings",
"//mojo/public/cpp/system",
"//mojo/public/cpp/utility",
"//mojo/services/network/public/interfaces",
"//sky/engine",
"//url",
]
}
......@@ -2,17 +2,16 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "sky/viewer/platform/platform_impl.h"
#include "sky/services/platform/platform_impl.h"
#include "mojo/public/cpp/application/application_impl.h"
#include "sky/viewer/platform/net_constants.h"
#include "sky/viewer/platform/weburlloader_impl.h"
#include "sky/services/platform/net_constants.h"
#include "sky/services/platform/weburlloader_impl.h"
namespace sky {
PlatformImpl::PlatformImpl(mojo::ApplicationImpl* app)
PlatformImpl::PlatformImpl(mojo::NetworkServicePtr network_service)
: main_thread_task_runner_(base::MessageLoop::current()->task_runner()) {
app->ConnectToService("mojo:network_service", &network_service_);
network_service_ = network_service.Pass();
}
PlatformImpl::~PlatformImpl() {
......
......@@ -17,7 +17,7 @@ namespace sky {
class PlatformImpl : public blink::Platform {
public:
explicit PlatformImpl(mojo::ApplicationImpl* app);
explicit PlatformImpl(mojo::NetworkServicePtr network_service);
~PlatformImpl() override;
// blink::Platform methods:
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "sky/viewer/converters/url_request_types.h"
#include "sky/services/platform/url_request_types.h"
#include "base/strings/string_util.h"
#include "mojo/public/cpp/system/data_pipe.h"
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "sky/viewer/platform/weburlloader_impl.h"
#include "sky/services/platform/weburlloader_impl.h"
#include "base/bind.h"
#include "base/logging.h"
......@@ -14,8 +14,8 @@
#include "sky/engine/public/platform/WebURLLoadTiming.h"
#include "sky/engine/public/platform/WebURLLoaderClient.h"
#include "sky/engine/public/platform/WebURLResponse.h"
#include "sky/viewer/converters/url_request_types.h"
#include "sky/viewer/platform/net_constants.h"
#include "sky/services/platform/net_constants.h"
#include "sky/services/platform/url_request_types.h"
namespace sky {
namespace {
......
......@@ -47,8 +47,6 @@ shared_library("sky_shell") {
"ui/engine.h",
"ui/input_event_converter.cc",
"ui/input_event_converter.h",
"ui/platform_impl.cc",
"ui/platform_impl.h",
"ui_delegate.cc",
"ui_delegate.h",
]
......@@ -65,6 +63,7 @@ shared_library("sky_shell") {
"//mojo/services/network/public/interfaces",
"//skia",
"//sky/engine",
"//sky/services/platform",
"//sky/services/viewport",
"//ui/gfx/geometry",
"//ui/gl",
......
......@@ -5,14 +5,15 @@
#include "sky/shell/ui/engine.h"
#include "base/bind.h"
#include "mojo/public/cpp/application/connect.h"
#include "sky/engine/public/platform/WebInputEvent.h"
#include "sky/engine/public/web/Sky.h"
#include "sky/engine/public/web/WebLocalFrame.h"
#include "sky/engine/public/web/WebSettings.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/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/SkPictureRecorder.h"
......@@ -46,9 +47,13 @@ base::WeakPtr<Engine> Engine::GetWeakPtr() {
return weak_factory_.GetWeakPtr();
}
void Engine::Init(mojo::ScopedMessagePipeHandle service_provider) {
platform_impl_.reset(new PlatformImpl(
mojo::MakeProxy<mojo::ServiceProvider>(service_provider.Pass())));
void Engine::Init(mojo::ScopedMessagePipeHandle service_provider_handle) {
mojo::ServiceProviderPtr service_provider =
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());
}
......
......@@ -20,9 +20,9 @@
#include "ui/gfx/geometry/size.h"
namespace sky {
class PlatformImpl;
namespace shell {
class Animator;
class PlatformImpl;
class Engine : public UIDelegate,
public ViewportObserver,
......
// 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
// 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_
......@@ -15,17 +15,10 @@ mojo_native_application("viewer") {
"converters/basic_types.h",
"converters/input_event_types.cc",
"converters/input_event_types.h",
"converters/url_request_types.cc",
"converters/url_request_types.h",
"document_view.cc",
"document_view.h",
"internals.cc",
"internals.h",
"platform/net_constants.h",
"platform/platform_impl.cc",
"platform/platform_impl.h",
"platform/weburlloader_impl.cc",
"platform/weburlloader_impl.h",
"runtime_flags.cc",
"runtime_flags.h",
"viewer.cc",
......@@ -58,6 +51,7 @@ mojo_native_application("viewer") {
"//sky/engine",
"//sky/engine/tonic",
"//sky/services/inspector:bindings",
"//sky/services/platform",
"//sky/services/testing:bindings",
"//third_party/icu",
"//ui/events",
......
......@@ -34,10 +34,9 @@
#include "sky/engine/public/web/WebScriptSource.h"
#include "sky/engine/public/web/WebSettings.h"
#include "sky/engine/public/web/WebView.h"
#include "sky/services/platform/url_request_types.h"
#include "sky/viewer/converters/input_event_types.h"
#include "sky/viewer/converters/url_request_types.h"
#include "sky/viewer/internals.h"
#include "sky/viewer/platform/weburlloader_impl.h"
#include "sky/viewer/runtime_flags.h"
#include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/core/SkColor.h"
......
......@@ -15,9 +15,9 @@
#include "mojo/public/cpp/application/interface_factory_impl.h"
#include "mojo/services/content_handler/public/interfaces/content_handler.mojom.h"
#include "sky/engine/public/web/Sky.h"
#include "sky/services/platform/platform_impl.h"
#include "sky/viewer/content_handler_impl.h"
#include "sky/viewer/document_view.h"
#include "sky/viewer/platform/platform_impl.h"
#include "sky/viewer/runtime_flags.h"
namespace sky {
......@@ -34,7 +34,9 @@ class Viewer : public mojo::ApplicationDelegate,
virtual void Initialize(mojo::ApplicationImpl* app) override {
RuntimeFlags::Initialize(app);
platform_impl_.reset(new PlatformImpl(app));
mojo::NetworkServicePtr network_service;
app->ConnectToService("mojo:network_service", &network_service);
platform_impl_.reset(new PlatformImpl(network_service.Pass()));
blink::initialize(platform_impl_.get());
mojo::icu::Initialize(app);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册