| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/mus/example/client/client_application_delegate.h" | 5 #include "components/mus/example/client/client_application_delegate.h" |
| 6 | 6 |
| 7 #include "components/mus/example/wm/wm.mojom.h" | 7 #include "components/mus/example/common/mus_views_init.h" |
| 8 #include "components/mus/public/cpp/view_tree_connection.h" | |
| 9 #include "components/mus/public/cpp/view_tree_host_factory.h" | |
| 10 #include "mandoline/ui/aura/aura_init.h" | |
| 11 #include "mandoline/ui/aura/native_widget_view_manager.h" | |
| 12 #include "mojo/application/public/cpp/application_connection.h" | 8 #include "mojo/application/public/cpp/application_connection.h" |
| 13 #include "mojo/application/public/cpp/application_impl.h" | 9 #include "mojo/application/public/cpp/application_impl.h" |
| 14 #include "mojo/converters/geometry/geometry_type_converters.h" | |
| 15 #include "ui/views/background.h" | 10 #include "ui/views/background.h" |
| 16 #include "ui/views/widget/widget.h" | 11 #include "ui/views/widget/widget.h" |
| 17 #include "ui/views/widget/widget_delegate.h" | 12 #include "ui/views/widget/widget_delegate.h" |
| 18 | 13 |
| 19 ClientApplicationDelegate::ClientApplicationDelegate() : app_(nullptr) {} | 14 ClientApplicationDelegate::ClientApplicationDelegate() : app_(nullptr) {} |
| 20 | 15 |
| 21 ClientApplicationDelegate::~ClientApplicationDelegate() {} | 16 ClientApplicationDelegate::~ClientApplicationDelegate() {} |
| 22 | 17 |
| 23 void ClientApplicationDelegate::Initialize(mojo::ApplicationImpl* app) { | 18 void ClientApplicationDelegate::Initialize(mojo::ApplicationImpl* app) { |
| 24 app_ = app; | 19 app_ = app; |
| 25 | 20 |
| 26 mojom::WMPtr wm; | 21 mus_views_init_.reset(new MUSViewsInit(app)); |
| 27 mojo::URLRequestPtr request(mojo::URLRequest::New()); | |
| 28 request->url = "mojo:example_wm"; | |
| 29 app->ConnectToService(request.Pass(), &wm); | |
| 30 | 22 |
| 31 for (int i = 0; i < 3; ++i) { | 23 for (int i = 0; i < 3; ++i) { |
| 32 mojo::ViewTreeClientPtr view_tree_client; | 24 views::WidgetDelegateView* widget_delegate = new views::WidgetDelegateView; |
| 33 mus::ViewTreeConnection::Create(this, GetProxy(&view_tree_client).Pass()); | 25 widget_delegate->GetContentsView()->set_background( |
| 34 wm->OpenWindow(view_tree_client.Pass()); | 26 views::Background::CreateSolidBackground(0xFFDDDDDD)); |
| 27 |
| 28 views::Widget* widget = views::Widget::CreateWindow(widget_delegate); |
| 29 widget->Show(); |
| 35 } | 30 } |
| 36 } | 31 } |
| 37 | 32 |
| 38 bool ClientApplicationDelegate::ConfigureIncomingConnection( | 33 bool ClientApplicationDelegate::ConfigureIncomingConnection( |
| 39 mojo::ApplicationConnection* connection) { | 34 mojo::ApplicationConnection* connection) { |
| 40 return false; | 35 return false; |
| 41 } | 36 } |
| 42 | |
| 43 void ClientApplicationDelegate::OnEmbed(mus::View* root) { | |
| 44 if (!aura_init_) { | |
| 45 aura_init_.reset( | |
| 46 new mandoline::AuraInit(root, app_->shell(), "example_resources.pak")); | |
| 47 } | |
| 48 | |
| 49 views::WidgetDelegateView* widget_delegate = new views::WidgetDelegateView; | |
| 50 widget_delegate->GetContentsView()->set_background( | |
| 51 views::Background::CreateSolidBackground(0xFFDDDDDD)); | |
| 52 | |
| 53 views::Widget* widget = new views::Widget; | |
| 54 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); | |
| 55 params.delegate = widget_delegate; | |
| 56 params.native_widget = | |
| 57 new mandoline::NativeWidgetViewManager(widget, app_->shell(), root); | |
| 58 params.bounds = root->bounds().To<gfx::Rect>(); | |
| 59 params.bounds.set_x(0); | |
| 60 params.bounds.set_y(0); | |
| 61 widget->Init(params); | |
| 62 widget->Show(); | |
| 63 } | |
| 64 | |
| 65 void ClientApplicationDelegate::OnConnectionLost( | |
| 66 mus::ViewTreeConnection* connection) {} | |
| OLD | NEW |