James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 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 |
| 3 | // found in the LICENSE file. |
| 4 | |
Ben Goodger | 96d7285 | 2014-10-27 15:05:15 -0700 | [diff] [blame] | 5 | #ifndef EXAMPLES_WM_FLOW_WM_FRAME_CONTROLLER_H_ |
| 6 | #define EXAMPLES_WM_FLOW_WM_FRAME_CONTROLLER_H_ |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 7 | |
| 8 | #include "base/memory/scoped_ptr.h" |
Eric Seidel | 72d6a21 | 2015-01-06 14:40:41 -0800 | [diff] [blame] | 9 | #include "examples/wm_flow/wm/window_frame_host.mojom.h" |
| 10 | #include "mojo/public/cpp/application/interface_factory.h" |
James Robinson | 3b67967 | 2015-01-21 18:36:01 -0800 | [diff] [blame] | 11 | #include "mojo/public/cpp/application/service_provider_impl.h" |
Colin Blundell | c4edbc7 | 2014-12-10 14:16:27 +0100 | [diff] [blame] | 12 | #include "mojo/services/view_manager/public/cpp/view_observer.h" |
James Robinson | 1581cd6 | 2014-12-02 10:52:00 -0800 | [diff] [blame] | 13 | #include "services/window_manager/focus_controller.h" |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 14 | #include "ui/gfx/geometry/rect.h" |
| 15 | |
Eric Seidel | 72d6a21 | 2015-01-06 14:40:41 -0800 | [diff] [blame] | 16 | class GURL; |
| 17 | |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 18 | namespace mojo { |
| 19 | class NativeWidgetViewManager; |
| 20 | class View; |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 21 | } |
| 22 | |
James Robinson | 489c8f1 | 2014-12-08 12:08:55 -0800 | [diff] [blame] | 23 | namespace window_manager { |
| 24 | class WindowManagerApp; |
| 25 | } |
| 26 | |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 27 | // FrameController encapsulates the window manager's frame additions to a window |
| 28 | // created by an application. It renders the content of the frame and responds |
| 29 | // to any events targeted at it. |
Eric Seidel | 72d6a21 | 2015-01-06 14:40:41 -0800 | [diff] [blame] | 30 | class FrameController |
| 31 | : public examples::WindowFrameHost, |
| 32 | public mojo::ViewObserver, |
| 33 | public mojo::InterfaceFactory<examples::WindowFrameHost> { |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 34 | public: |
Eric Seidel | 72d6a21 | 2015-01-06 14:40:41 -0800 | [diff] [blame] | 35 | FrameController(const GURL& frame_app_url, |
James Robinson | baf71d3 | 2014-10-08 13:00:20 -0700 | [diff] [blame] | 36 | mojo::View* view, |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 37 | mojo::View** app_view, |
James Robinson | 489c8f1 | 2014-12-08 12:08:55 -0800 | [diff] [blame] | 38 | window_manager::WindowManagerApp* window_manager_app); |
Dave Moore | cc0e4f9 | 2015-03-10 15:23:04 -0700 | [diff] [blame^] | 39 | ~FrameController() override; |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 40 | |
Eric Seidel | 72d6a21 | 2015-01-06 14:40:41 -0800 | [diff] [blame] | 41 | // mojo::InterfaceFactory<examples::WindowFrameHost> implementation. |
| 42 | void Create( |
| 43 | mojo::ApplicationConnection* connection, |
| 44 | mojo::InterfaceRequest<examples::WindowFrameHost> request) override; |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 45 | |
Eric Seidel | 72d6a21 | 2015-01-06 14:40:41 -0800 | [diff] [blame] | 46 | // examples::WindowFrameHost |
| 47 | void CloseWindow() override; |
| 48 | void ToggleMaximize() override; |
| 49 | void ActivateWindow() override; |
| 50 | void SetCapture(bool frame_has_capture) override; |
Elliot Glaysher | f88a2fb | 2014-12-16 11:09:36 -0800 | [diff] [blame] | 51 | |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 52 | private: |
Eric Seidel | 72d6a21 | 2015-01-06 14:40:41 -0800 | [diff] [blame] | 53 | void OnViewDestroyed(mojo::View* view) override; |
| 54 | void OnViewBoundsChanged(mojo::View* view, |
| 55 | const mojo::Rect& old_bounds, |
| 56 | const mojo::Rect& new_bounds) override; |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 57 | |
| 58 | mojo::View* view_; |
| 59 | mojo::View* app_view_; |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 60 | bool maximized_; |
| 61 | gfx::Rect restored_bounds_; |
James Robinson | 489c8f1 | 2014-12-08 12:08:55 -0800 | [diff] [blame] | 62 | window_manager::WindowManagerApp* window_manager_app_; |
James Robinson | 3b67967 | 2015-01-21 18:36:01 -0800 | [diff] [blame] | 63 | mojo::ServiceProviderImpl viewer_services_impl_; |
Eric Seidel | 72d6a21 | 2015-01-06 14:40:41 -0800 | [diff] [blame] | 64 | |
| 65 | mojo::Binding<examples::WindowFrameHost> binding_; |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 66 | |
| 67 | DISALLOW_COPY_AND_ASSIGN(FrameController); |
| 68 | }; |
| 69 | |
Ben Goodger | 96d7285 | 2014-10-27 15:05:15 -0700 | [diff] [blame] | 70 | #endif // EXAMPLES_WM_FLOW_WM_FRAME_CONTROLLER_H_ |