Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef SERVICES_UI_VIEW_MANAGER_VIEW_TREE_STATE_H_ | |
| 6 #define SERVICES_UI_VIEW_MANAGER_VIEW_TREE_STATE_H_ | |
| 7 | |
| 8 #include <memory> | |
| 9 #include <set> | |
| 10 #include <unordered_map> | |
| 11 | |
| 12 #include "base/callback.h" | |
| 13 #include "base/macros.h" | |
| 14 #include "base/memory/weak_ptr.h" | |
| 15 #include "mojo/public/cpp/bindings/binding.h" | |
| 16 #include "mojo/services/ui/views/interfaces/view_trees.mojom.h" | |
| 17 #include "services/ui/view_manager/view_state.h" | |
| 18 | |
| 19 namespace view_manager { | |
| 20 | |
| 21 // Describes the state of a particular view tree. | |
| 22 // This object is owned by the ViewRegistry that created it. | |
| 23 class ViewTreeState : public base::SupportsWeakPtr<ViewTreeState> { | |
|
jamesr
2015/10/27 23:13:11
ditto re SupportsWeak
jeffbrown
2015/10/28 01:37:29
Done.
| |
| 24 public: | |
| 25 ViewTreeState(mojo::ui::ViewTreePtr view_tree); | |
|
jamesr
2015/10/27 23:13:11
explicit
jeffbrown
2015/10/28 01:37:29
Done.
| |
| 26 ~ViewTreeState(); | |
| 27 | |
| 28 // Gets the view tree interface, never null. | |
| 29 // Caller does not obtain ownership of the view. | |
| 30 mojo::ui::ViewTree* view_tree() const { return view_tree_.get(); } | |
| 31 | |
| 32 // Sets the associated host implementation and takes ownership of it. | |
| 33 void set_view_tree_host(mojo::ui::ViewTreeHost* host) { | |
| 34 view_tree_host_.reset(host); | |
| 35 } | |
| 36 | |
| 37 // Sets the connection error handler for the view. | |
| 38 void set_view_tree_connection_error_handler(const base::Closure& handler) { | |
| 39 view_tree_.set_connection_error_handler(handler); | |
| 40 } | |
| 41 | |
| 42 // Gets the root of the view tree, or null if it is unavailable. | |
| 43 ViewState* root() const { return root_; } | |
| 44 | |
| 45 // Sets the root of the view tree. Must not be null. | |
| 46 // The view specified as the new root must not have any parents. | |
| 47 void SetRoot(ViewState* root, uint32_t key); | |
| 48 | |
| 49 // Resets the root view to null. | |
| 50 void ResetRoot(); | |
| 51 | |
| 52 // True if the client previously set but has not yet explicitly unset | |
| 53 // the root, independent of whether it is currently available. | |
| 54 bool root_was_set; | |
|
jamesr
2015/10/27 23:13:11
public member
jeffbrown
2015/10/28 01:37:29
Done.
| |
| 55 | |
| 56 // True if there is a pending layout request. | |
| 57 bool layout_request_pending; | |
| 58 | |
| 59 // True if a layout request has been issued. | |
| 60 bool layout_request_issued; | |
| 61 | |
| 62 private: | |
| 63 mojo::ui::ViewTreePtr view_tree_; | |
| 64 std::unique_ptr<mojo::ui::ViewTreeHost> view_tree_host_; | |
| 65 | |
| 66 ViewState* root_; | |
| 67 | |
| 68 DISALLOW_COPY_AND_ASSIGN(ViewTreeState); | |
| 69 }; | |
| 70 | |
| 71 } // namespace view_manager | |
| 72 | |
| 73 #endif // SERVICES_UI_VIEW_MANAGER_VIEW_TREE_STATE_H_ | |
| OLD | NEW |