| 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 "examples/wm_flow/wm/frame_controller.h" | 5 #include "examples/wm_flow/wm/frame_controller.h" |
| 6 | 6 |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "mojo/converters/geometry/geometry_type_converters.h" | 9 #include "mojo/converters/geometry/geometry_type_converters.h" |
| 10 #include "mojo/public/cpp/application/service_provider_impl.h" | 10 #include "mojo/public/interfaces/application/service_provider.mojom.h" |
| 11 #include "mojo/services/view_manager/public/cpp/view.h" | 11 #include "mojo/services/view_manager/public/cpp/view.h" |
| 12 #include "mojo/services/view_manager/public/cpp/view_manager.h" | 12 #include "mojo/services/view_manager/public/cpp/view_manager.h" |
| 13 #include "services/window_manager/capture_controller.h" | 13 #include "services/window_manager/capture_controller.h" |
| 14 #include "services/window_manager/window_manager_app.h" | 14 #include "services/window_manager/window_manager_app.h" |
| 15 #include "url/gurl.h" | 15 #include "url/gurl.h" |
| 16 | 16 |
| 17 //////////////////////////////////////////////////////////////////////////////// | 17 //////////////////////////////////////////////////////////////////////////////// |
| 18 // FrameController, public: | 18 // FrameController, public: |
| 19 | 19 |
| 20 FrameController::FrameController( | 20 FrameController::FrameController( |
| 21 const GURL& frame_app_url, | 21 const GURL& frame_app_url, |
| 22 mojo::View* view, | 22 mojo::View* view, |
| 23 mojo::View** app_view, | 23 mojo::View** app_view, |
| 24 window_manager::WindowManagerApp* window_manager_app) | 24 window_manager::WindowManagerApp* window_manager_app) |
| 25 : view_(view), | 25 : view_(view), |
| 26 app_view_(view->view_manager()->CreateView()), | 26 app_view_(view->view_manager()->CreateView()), |
| 27 maximized_(false), | 27 maximized_(false), |
| 28 window_manager_app_(window_manager_app), | 28 window_manager_app_(window_manager_app), |
| 29 binding_(this) { | 29 binding_(this) { |
| 30 view_->AddObserver(this); | 30 view_->AddObserver(this); |
| 31 view_->SetVisible(true); // FIXME: This should not be our responsibility? | 31 view_->SetVisible(true); // FIXME: This should not be our responsibility? |
| 32 *app_view = app_view_; | 32 *app_view = app_view_; |
| 33 | 33 |
| 34 scoped_ptr<mojo::ServiceProviderImpl> exported_services( | 34 viewer_services_impl_.AddService(this); |
| 35 new mojo::ServiceProviderImpl()); | 35 mojo::ServiceProviderPtr viewer_services; |
| 36 exported_services->AddService(this); | 36 viewer_services_impl_.Bind(GetProxy(&viewer_services)); |
| 37 | 37 |
| 38 viewer_services_ = | 38 view_->Embed(frame_app_url.spec(), nullptr, viewer_services.Pass()); |
| 39 view_->Embed(frame_app_url.spec(), exported_services.Pass()); | |
| 40 | 39 |
| 41 // We weren't observing when our initial bounds was set: | 40 // We weren't observing when our initial bounds was set: |
| 42 OnViewBoundsChanged(view, view->bounds(), view->bounds()); | 41 OnViewBoundsChanged(view, view->bounds(), view->bounds()); |
| 43 | 42 |
| 44 // Add the child view after embedding sky, since embed clears children. | 43 // Add the child view after embedding sky, since embed clears children. |
| 45 view_->AddChild(app_view_); | 44 view_->AddChild(app_view_); |
| 46 app_view_->SetVisible(true); | 45 app_view_->SetVisible(true); |
| 47 } | 46 } |
| 48 | 47 |
| 49 FrameController::~FrameController() {} | 48 FrameController::~FrameController() {} |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 const int kTopControlsAdditionalInset = 15; | 96 const int kTopControlsAdditionalInset = 15; |
| 98 const int kDefaultInset = 25; | 97 const int kDefaultInset = 25; |
| 99 mojo::Rect bounds; | 98 mojo::Rect bounds; |
| 100 bounds.x = bounds.y = kDefaultInset; | 99 bounds.x = bounds.y = kDefaultInset; |
| 101 bounds.y += kTopControlsAdditionalInset; | 100 bounds.y += kTopControlsAdditionalInset; |
| 102 bounds.width = view_->bounds().width - kDefaultInset * 2; | 101 bounds.width = view_->bounds().width - kDefaultInset * 2; |
| 103 bounds.height = | 102 bounds.height = |
| 104 view_->bounds().height - kDefaultInset * 2 - kTopControlsAdditionalInset; | 103 view_->bounds().height - kDefaultInset * 2 - kTopControlsAdditionalInset; |
| 105 app_view_->SetBounds(bounds); | 104 app_view_->SetBounds(bounds); |
| 106 } | 105 } |
| OLD | NEW |