| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/view_manager/public/cpp/view_manager_context.h" | 5 #include "components/view_manager/public/cpp/view_manager_context.h" |
| 6 | 6 |
| 7 #include "mojo/application/public/cpp/application_impl.h" | 7 #include "mojo/application/public/cpp/application_impl.h" |
| 8 #include "third_party/mojo/src/mojo/public/cpp/bindings/interface_request.h" | 8 #include "third_party/mojo/src/mojo/public/cpp/bindings/interface_request.h" |
| 9 | 9 |
| 10 namespace mojo { | 10 namespace mojo { |
| 11 class ApplicationImpl; | 11 class ApplicationImpl; |
| 12 | 12 |
| 13 class ViewManagerContext::InternalState { | 13 class ViewManagerContext::InternalState { |
| 14 public: | 14 public: |
| 15 explicit InternalState(ApplicationImpl* application_impl) { | 15 explicit InternalState(ApplicationImpl* application_impl) { |
| 16 application_impl->ConnectToService("mojo:window_manager", &wm_); | 16 mojo::URLRequestPtr request(mojo::URLRequest::New()); |
| 17 request->url = mojo::String::From("mojo:window_manager"); |
| 18 application_impl->ConnectToService(request.Pass(), &wm_); |
| 17 } | 19 } |
| 18 ~InternalState() {} | 20 ~InternalState() {} |
| 19 | 21 |
| 20 WindowManager* wm() { return wm_.get(); } | 22 WindowManager* wm() { return wm_.get(); } |
| 21 | 23 |
| 22 private: | 24 private: |
| 23 WindowManagerPtr wm_; | 25 WindowManagerPtr wm_; |
| 24 | 26 |
| 25 MOJO_DISALLOW_COPY_AND_ASSIGN(InternalState); | 27 MOJO_DISALLOW_COPY_AND_ASSIGN(InternalState); |
| 26 }; | 28 }; |
| 27 | 29 |
| 28 ViewManagerContext::ViewManagerContext(ApplicationImpl* application_impl) | 30 ViewManagerContext::ViewManagerContext(ApplicationImpl* application_impl) |
| 29 : state_(new InternalState(application_impl)) {} | 31 : state_(new InternalState(application_impl)) {} |
| 30 ViewManagerContext::~ViewManagerContext() { | 32 ViewManagerContext::~ViewManagerContext() { |
| 31 delete state_; | 33 delete state_; |
| 32 } | 34 } |
| 33 | 35 |
| 34 void ViewManagerContext::Embed(const String& url) { | 36 void ViewManagerContext::Embed(const String& url) { |
| 35 Embed(url, nullptr, nullptr); | 37 mojo::URLRequestPtr request(mojo::URLRequest::New()); |
| 38 request->url = mojo::String::From(url); |
| 39 Embed(request.Pass(), nullptr, nullptr); |
| 36 } | 40 } |
| 37 | 41 |
| 38 void ViewManagerContext::Embed(const String& url, | 42 void ViewManagerContext::Embed(mojo::URLRequestPtr request, |
| 39 InterfaceRequest<ServiceProvider> services, | 43 InterfaceRequest<ServiceProvider> services, |
| 40 ServiceProviderPtr exposed_services) { | 44 ServiceProviderPtr exposed_services) { |
| 41 state_->wm()->Embed(url, services.Pass(), exposed_services.Pass()); | 45 state_->wm()->Embed(request.Pass(), services.Pass(), exposed_services.Pass()); |
| 42 } | 46 } |
| 43 | 47 |
| 44 } // namespace mojo | 48 } // namespace mojo |
| OLD | NEW |