Chromium Code Reviews| 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 #ifndef ASH_MUS_NON_CLIENT_FRAME_CONTROLLER_H_ | 5 #ifndef ASH_MUS_NON_CLIENT_FRAME_CONTROLLER_H_ |
| 6 #define ASH_MUS_NON_CLIENT_FRAME_CONTROLLER_H_ | 6 #define ASH_MUS_NON_CLIENT_FRAME_CONTROLLER_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <map> | |
| 11 #include <string> | |
| 12 #include <vector> | |
| 13 | |
| 10 #include "ash/mus/frame/detached_title_area_renderer_host.h" | 14 #include "ash/mus/frame/detached_title_area_renderer_host.h" |
| 11 #include "base/macros.h" | 15 #include "base/macros.h" |
| 12 #include "base/strings/string16.h" | 16 #include "base/strings/string16.h" |
| 13 #include "services/ui/public/cpp/window_observer.h" | 17 #include "ui/aura/window_observer.h" |
| 18 #include "ui/gfx/geometry/insets.h" | |
| 19 #include "ui/gfx/geometry/rect.h" | |
| 14 #include "ui/views/widget/widget_delegate.h" | 20 #include "ui/views/widget/widget_delegate.h" |
| 15 | 21 |
| 22 namespace aura { | |
| 23 class Window; | |
| 24 class WindowManagerClient; | |
| 25 } | |
| 26 | |
| 16 namespace gfx { | 27 namespace gfx { |
| 17 class Insets; | 28 class Insets; |
| 18 } | 29 } |
| 19 | 30 |
| 20 namespace ui { | 31 namespace ui { |
| 21 class Window; | 32 namespace mojom { |
| 22 class WindowManagerClient; | 33 enum class WindowType; |
| 34 } | |
| 23 } | 35 } |
| 24 | 36 |
| 25 namespace ash { | 37 namespace ash { |
| 26 namespace mus { | 38 namespace mus { |
| 27 | 39 |
| 40 class WindowManager; | |
| 41 | |
| 28 // Provides the non-client frame for mus Windows. | 42 // Provides the non-client frame for mus Windows. |
| 29 class NonClientFrameController : public views::WidgetDelegateView, | 43 class NonClientFrameController : public views::WidgetDelegateView, |
| 30 public ui::WindowObserver, | 44 public aura::WindowObserver, |
| 31 public DetachedTitleAreaRendererHost { | 45 public DetachedTitleAreaRendererHost { |
| 32 public: | 46 public: |
| 33 // NonClientFrameController deletes itself when |window| is destroyed. | 47 // Creates a new NonClientFrameController and window to render the non-client |
| 34 static void Create(ui::Window* parent, | 48 // frame decorations. This eletes itself when |window| is destroyed. |
|
James Cook
2016/12/05 19:21:44
eletes -> deletes
sky
2016/12/05 21:39:19
Done.
| |
| 35 ui::Window* window, | 49 // |parent| is the parent to place the newly created window in. |
|
James Cook
2016/12/05 19:21:44
Comment whether parent, context or both can be nul
sky
2016/12/05 21:39:19
Done.
| |
| 36 ui::WindowManagerClient* window_manager_client); | 50 NonClientFrameController( |
| 51 aura::Window* parent, | |
| 52 aura::Window* context, | |
| 53 const gfx::Rect& bounds, | |
| 54 ui::mojom::WindowType window_type, | |
| 55 std::map<std::string, std::vector<uint8_t>>* properties, | |
| 56 WindowManager* window_manager); | |
| 57 | |
| 58 // Returns the NonClientFrameController for the specified window, null if | |
| 59 // one was not created. | |
| 60 static NonClientFrameController* Get(aura::Window* window); | |
| 37 | 61 |
| 38 // Returns the preferred client area insets. | 62 // Returns the preferred client area insets. |
| 39 static gfx::Insets GetPreferredClientAreaInsets(); | 63 static gfx::Insets GetPreferredClientAreaInsets(); |
| 40 | 64 |
| 41 // Returns the width needed to display the standard set of buttons on the | 65 // Returns the width needed to display the standard set of buttons on the |
| 42 // title bar. | 66 // title bar. |
| 43 static int GetMaxTitleBarButtonWidth(); | 67 static int GetMaxTitleBarButtonWidth(); |
| 44 | 68 |
| 45 ui::Window* window() { return window_; } | 69 aura::Window* window() { return window_; } |
| 70 | |
| 71 aura::WindowManagerClient* window_manager_client() { | |
| 72 return window_manager_client_; | |
| 73 } | |
| 74 | |
| 75 void SetClientArea(const gfx::Insets& insets, | |
| 76 const std::vector<gfx::Rect>& additional_client_areas); | |
| 46 | 77 |
| 47 private: | 78 private: |
| 48 NonClientFrameController(ui::Window* parent, | |
| 49 ui::Window* window, | |
| 50 ui::WindowManagerClient* window_manager_client); | |
| 51 ~NonClientFrameController() override; | 79 ~NonClientFrameController() override; |
| 52 | 80 |
| 53 // DetachedTitleAreaRendererHost: | 81 // DetachedTitleAreaRendererHost: |
| 54 void OnDetachedTitleAreaRendererDestroyed( | 82 void OnDetachedTitleAreaRendererDestroyed( |
| 55 DetachedTitleAreaRenderer* renderer) override; | 83 DetachedTitleAreaRenderer* renderer) override; |
| 56 | 84 |
| 57 // views::WidgetDelegateView: | 85 // views::WidgetDelegateView: |
| 58 base::string16 GetWindowTitle() const override; | 86 base::string16 GetWindowTitle() const override; |
| 59 bool CanResize() const override; | 87 bool CanResize() const override; |
| 60 bool CanMaximize() const override; | 88 bool CanMaximize() const override; |
| 61 bool CanMinimize() const override; | 89 bool CanMinimize() const override; |
| 62 bool ShouldShowWindowTitle() const override; | 90 bool ShouldShowWindowTitle() const override; |
| 63 views::ClientView* CreateClientView(views::Widget* widget) override; | 91 views::ClientView* CreateClientView(views::Widget* widget) override; |
| 64 | 92 |
| 65 // ui::WindowObserver: | 93 // aura::WindowObserver: |
| 66 void OnTreeChanged(const TreeChangeParams& params) override; | 94 void OnWindowHierarchyChanged(const HierarchyChangeParams& params) override; |
| 67 void OnWindowSharedPropertyChanged( | 95 void OnWindowPropertyChanged(aura::Window* window, |
| 68 ui::Window* window, | 96 const void* key, |
| 69 const std::string& name, | 97 intptr_t old) override; |
| 70 const std::vector<uint8_t>* old_data, | 98 void OnWindowDestroyed(aura::Window* window) override; |
| 71 const std::vector<uint8_t>* new_data) override; | 99 |
| 72 void OnWindowLocalPropertyChanged(ui::Window* window, | 100 aura::WindowManagerClient* window_manager_client_; |
| 73 const void* key, | |
| 74 intptr_t old) override; | |
| 75 void OnWindowDestroyed(ui::Window* window) override; | |
| 76 | 101 |
| 77 views::Widget* widget_; | 102 views::Widget* widget_; |
| 78 | 103 |
| 79 // WARNING: as widget delays destruction there is a portion of time when this | 104 // WARNING: as widget delays destruction there is a portion of time when this |
| 80 // is null. | 105 // is null. |
| 81 ui::Window* window_; | 106 aura::Window* window_; |
| 82 | 107 |
| 83 // Used if a child window is added that has the | 108 // Used if a child window is added that has the |
| 84 // kRendererParentTitleArea_Property set. | 109 // kRendererParentTitleArea_Property set. |
| 85 DetachedTitleAreaRenderer* detached_title_area_renderer_ = nullptr; | 110 DetachedTitleAreaRenderer* detached_title_area_renderer_ = nullptr; |
| 86 | 111 |
| 112 bool did_init_native_widget_ = false; | |
| 113 | |
| 114 gfx::Insets client_area_insets_; | |
| 115 std::vector<gfx::Rect> additional_client_areas_; | |
| 116 | |
| 87 DISALLOW_COPY_AND_ASSIGN(NonClientFrameController); | 117 DISALLOW_COPY_AND_ASSIGN(NonClientFrameController); |
| 88 }; | 118 }; |
| 89 | 119 |
| 90 } // namespace mus | 120 } // namespace mus |
| 91 } // namespace ash | 121 } // namespace ash |
| 92 | 122 |
| 93 #endif // ASH_MUS_NON_CLIENT_FRAME_CONTROLLER_H_ | 123 #endif // ASH_MUS_NON_CLIENT_FRAME_CONTROLLER_H_ |
| OLD | NEW |