提交 35d410ab 编写于 作者: B Benjamin Lerman

mojo: Update content handler API

WIP

R=aa@chromium.org, abarth@chromium.org, hansmuller@chromium.org

Review URL: https://codereview.chromium.org/687273002
上级 67a3adff
......@@ -9,21 +9,16 @@
namespace sky {
ContentHandlerImpl::ContentHandlerImpl(
mojo::Shell* shell,
scoped_refptr<base::MessageLoopProxy> compositor_thread)
: shell_(shell),
compositor_thread_(compositor_thread) {
: compositor_thread_(compositor_thread) {
}
ContentHandlerImpl::~ContentHandlerImpl() {
}
void ContentHandlerImpl::OnConnect(
const mojo::String& url,
mojo::URLResponsePtr response,
mojo::InterfaceRequest<mojo::ServiceProvider> service_provider_request) {
new DocumentView(response.Pass(), service_provider_request.Pass(),
shell_, compositor_thread_);
void ContentHandlerImpl::StartApplication(mojo::ShellPtr shell,
mojo::URLResponsePtr response) {
new DocumentView(response.Pass(), shell.Pass(), compositor_thread_);
}
} // namespace sky
......@@ -14,19 +14,14 @@ class DocumentView;
class ContentHandlerImpl : public mojo::InterfaceImpl<mojo::ContentHandler> {
public:
ContentHandlerImpl(mojo::Shell* shell,
scoped_refptr<base::MessageLoopProxy> compositor_thread);
ContentHandlerImpl(scoped_refptr<base::MessageLoopProxy> compositor_thread);
virtual ~ContentHandlerImpl();
private:
// Overridden from ContentHandler:
virtual void OnConnect(
const mojo::String& url,
mojo::URLResponsePtr response,
mojo::InterfaceRequest<mojo::ServiceProvider>
servive_provider_request) override;
virtual void StartApplication(mojo::ShellPtr shell,
mojo::URLResponsePtr response) override;
mojo::Shell* shell_;
scoped_refptr<base::MessageLoopProxy> compositor_thread_;
DISALLOW_COPY_AND_ASSIGN(ContentHandlerImpl);
......
......@@ -12,7 +12,6 @@
#include "base/thread_task_runner_handle.h"
#include "mojo/converters/geometry/geometry_type_converters.h"
#include "mojo/public/cpp/application/connect.h"
#include "mojo/public/cpp/application/service_provider_impl.h"
#include "mojo/public/cpp/system/data_pipe.h"
#include "mojo/public/interfaces/application/shell.mojom.h"
#include "mojo/services/public/cpp/view_manager/view.h"
......@@ -67,20 +66,17 @@ mojo::Target WebNavigationPolicyToNavigationTarget(
DocumentView::DocumentView(
mojo::URLResponsePtr response,
mojo::InterfaceRequest<mojo::ServiceProvider> service_provider_request,
mojo::Shell* shell,
mojo::ShellPtr shell,
scoped_refptr<base::MessageLoopProxy> compositor_thread)
: response_(response.Pass()),
shell_(shell),
shell_(shell.Pass()),
web_view_(NULL),
root_(NULL),
view_manager_client_factory_(shell, this),
view_manager_client_factory_(shell_.get(), this),
inspector_service_factory_(this),
compositor_thread_(compositor_thread),
weak_factory_(this) {
mojo::ServiceProviderImpl* exported_services = new mojo::ServiceProviderImpl();
exported_services->AddService(&view_manager_client_factory_);
BindToRequest(exported_services, &service_provider_request);
shell_.set_client(this);
}
DocumentView::~DocumentView() {
......@@ -94,6 +90,15 @@ base::WeakPtr<DocumentView> DocumentView::GetWeakPtr() {
return weak_factory_.GetWeakPtr();
}
void DocumentView::AcceptConnection(const mojo::String& requestor_url,
mojo::ServiceProviderPtr provider) {
exported_services_.AddService(&view_manager_client_factory_);
mojo::WeakBindToPipe(&exported_services_, provider.PassMessagePipe());
}
void DocumentView::Initialize(mojo::Array<mojo::String> args) {
}
void DocumentView::OnEmbed(
mojo::ViewManager* view_manager,
mojo::View* root,
......
......@@ -8,6 +8,9 @@
#include "base/compiler_specific.h"
#include "base/memory/weak_ptr.h"
#include "mojo/public/cpp/application/lazy_interface_ptr.h"
#include "mojo/public/cpp/application/service_provider_impl.h"
#include "mojo/public/cpp/bindings/interface_impl.h"
#include "mojo/public/interfaces/application/application.mojom.h"
#include "mojo/services/public/cpp/view_manager/view_manager_client_factory.h"
#include "mojo/services/public/cpp/view_manager/view_manager_delegate.h"
#include "mojo/services/public/cpp/view_manager/view_observer.h"
......@@ -31,22 +34,17 @@ namespace sky {
class ScriptRunner;
class WebLayerTreeViewImpl;
class DocumentView : public blink::WebViewClient,
class DocumentView : public mojo::InterfaceImpl<mojo::Application>,
public blink::WebViewClient,
public blink::WebFrameClient,
public mojo::ViewManagerDelegate,
public mojo::ViewObserver {
public:
// Load a new HTMLDocument with |response|.
//
// |sp_request| should be used to implement a
// ServiceProvider which exposes services to the connecting application.
// Commonly, the connecting application is the ViewManager and it will
// request ViewManagerClient.
//
// |shell| is the Shell connection for this mojo::Application.
DocumentView(mojo::URLResponsePtr response,
mojo::InterfaceRequest<mojo::ServiceProvider> sp_request,
mojo::Shell* shell,
mojo::ShellPtr shell,
scoped_refptr<base::MessageLoopProxy> compositor_thread);
virtual ~DocumentView();
......@@ -57,9 +55,14 @@ class DocumentView : public blink::WebViewClient,
return imported_services_.get();
}
mojo::Shell* shell() const { return shell_; }
mojo::Shell* shell() const { return shell_.get(); }
private:
// Application methods:
void AcceptConnection(const mojo::String& requestor_url,
mojo::ServiceProviderPtr provider) override;
void Initialize(mojo::Array<mojo::String> args) override;
// WebWidgetClient methods:
virtual blink::WebLayerTreeView* initializeLayerTreeView();
......@@ -93,8 +96,9 @@ class DocumentView : public blink::WebViewClient,
void Load(mojo::URLResponsePtr response);
mojo::URLResponsePtr response_;
mojo::ServiceProviderImpl exported_services_;
scoped_ptr<mojo::ServiceProvider> imported_services_;
mojo::Shell* shell_;
mojo::ShellPtr shell_;
mojo::LazyInterfacePtr<mojo::NavigatorHost> navigator_host_;
blink::WebView* web_view_;
mojo::View* root_;
......
......@@ -33,7 +33,6 @@ class Viewer : public mojo::ApplicationDelegate,
private:
// Overridden from ApplicationDelegate:
virtual void Initialize(mojo::ApplicationImpl* app) override {
shell_ = app->shell();
platform_impl_.reset(new PlatformImpl(app));
blink::initialize(platform_impl_.get());
// FIXME: Why not in the component build?
......@@ -54,12 +53,11 @@ class Viewer : public mojo::ApplicationDelegate,
virtual void Create(mojo::ApplicationConnection* connection,
mojo::InterfaceRequest<mojo::ContentHandler> request) override {
mojo::BindToRequest(
new ContentHandlerImpl(shell_, compositor_thread_.message_loop_proxy()),
new ContentHandlerImpl(compositor_thread_.message_loop_proxy()),
&request);
}
scoped_ptr<PlatformImpl> platform_impl_;
mojo::Shell* shell_;
base::Thread compositor_thread_;
TracingFactory tracing_;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册