blob: 025b1c03ff95694bd438cbc02eb556cc53448f69 [file] [log] [blame]
James Robinson646469d2014-10-03 15:33:28 -07001// 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 Goodger96d72852014-10-27 15:05:15 -07005#ifndef EXAMPLES_WM_FLOW_WM_FRAME_CONTROLLER_H_
6#define EXAMPLES_WM_FLOW_WM_FRAME_CONTROLLER_H_
James Robinson646469d2014-10-03 15:33:28 -07007
8#include "base/memory/scoped_ptr.h"
Eric Seidel72d6a212015-01-06 14:40:41 -08009#include "examples/wm_flow/wm/window_frame_host.mojom.h"
10#include "mojo/public/cpp/application/interface_factory.h"
James Robinson3b679672015-01-21 18:36:01 -080011#include "mojo/public/cpp/application/service_provider_impl.h"
Colin Blundellc4edbc72014-12-10 14:16:27 +010012#include "mojo/services/view_manager/public/cpp/view_observer.h"
James Robinson1581cd62014-12-02 10:52:00 -080013#include "services/window_manager/focus_controller.h"
James Robinson646469d2014-10-03 15:33:28 -070014#include "ui/gfx/geometry/rect.h"
15
Eric Seidel72d6a212015-01-06 14:40:41 -080016class GURL;
17
James Robinson646469d2014-10-03 15:33:28 -070018namespace mojo {
19class NativeWidgetViewManager;
20class View;
James Robinson646469d2014-10-03 15:33:28 -070021}
22
James Robinson489c8f12014-12-08 12:08:55 -080023namespace window_manager {
24class WindowManagerApp;
25}
26
James Robinson646469d2014-10-03 15:33:28 -070027// 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 Seidel72d6a212015-01-06 14:40:41 -080030class FrameController
31 : public examples::WindowFrameHost,
32 public mojo::ViewObserver,
33 public mojo::InterfaceFactory<examples::WindowFrameHost> {
James Robinson646469d2014-10-03 15:33:28 -070034 public:
Eric Seidel72d6a212015-01-06 14:40:41 -080035 FrameController(const GURL& frame_app_url,
James Robinsonbaf71d32014-10-08 13:00:20 -070036 mojo::View* view,
James Robinson646469d2014-10-03 15:33:28 -070037 mojo::View** app_view,
James Robinson489c8f12014-12-08 12:08:55 -080038 window_manager::WindowManagerApp* window_manager_app);
Dave Moorecc0e4f92015-03-10 15:23:04 -070039 ~FrameController() override;
James Robinson646469d2014-10-03 15:33:28 -070040
Eric Seidel72d6a212015-01-06 14:40:41 -080041 // mojo::InterfaceFactory<examples::WindowFrameHost> implementation.
42 void Create(
43 mojo::ApplicationConnection* connection,
44 mojo::InterfaceRequest<examples::WindowFrameHost> request) override;
James Robinson646469d2014-10-03 15:33:28 -070045
Eric Seidel72d6a212015-01-06 14:40:41 -080046 // examples::WindowFrameHost
47 void CloseWindow() override;
48 void ToggleMaximize() override;
49 void ActivateWindow() override;
50 void SetCapture(bool frame_has_capture) override;
Elliot Glaysherf88a2fb2014-12-16 11:09:36 -080051
James Robinson646469d2014-10-03 15:33:28 -070052 private:
Eric Seidel72d6a212015-01-06 14:40:41 -080053 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 Robinson646469d2014-10-03 15:33:28 -070057
58 mojo::View* view_;
59 mojo::View* app_view_;
James Robinson646469d2014-10-03 15:33:28 -070060 bool maximized_;
61 gfx::Rect restored_bounds_;
James Robinson489c8f12014-12-08 12:08:55 -080062 window_manager::WindowManagerApp* window_manager_app_;
James Robinson3b679672015-01-21 18:36:01 -080063 mojo::ServiceProviderImpl viewer_services_impl_;
Eric Seidel72d6a212015-01-06 14:40:41 -080064
65 mojo::Binding<examples::WindowFrameHost> binding_;
James Robinson646469d2014-10-03 15:33:28 -070066
67 DISALLOW_COPY_AND_ASSIGN(FrameController);
68};
69
Ben Goodger96d72852014-10-27 15:05:15 -070070#endif // EXAMPLES_WM_FLOW_WM_FRAME_CONTROLLER_H_