Chromium Code Reviews| Index: services/ui/view_manager/view_tree_state.h |
| diff --git a/services/ui/view_manager/view_tree_state.h b/services/ui/view_manager/view_tree_state.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..1eee0b22924ca71355780c8a01cc8c7c6ee6b9cf |
| --- /dev/null |
| +++ b/services/ui/view_manager/view_tree_state.h |
| @@ -0,0 +1,73 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef SERVICES_UI_VIEW_MANAGER_VIEW_TREE_STATE_H_ |
| +#define SERVICES_UI_VIEW_MANAGER_VIEW_TREE_STATE_H_ |
| + |
| +#include <memory> |
| +#include <set> |
| +#include <unordered_map> |
| + |
| +#include "base/callback.h" |
| +#include "base/macros.h" |
| +#include "base/memory/weak_ptr.h" |
| +#include "mojo/public/cpp/bindings/binding.h" |
| +#include "mojo/services/ui/views/interfaces/view_trees.mojom.h" |
| +#include "services/ui/view_manager/view_state.h" |
| + |
| +namespace view_manager { |
| + |
| +// Describes the state of a particular view tree. |
| +// This object is owned by the ViewRegistry that created it. |
| +class ViewTreeState : public base::SupportsWeakPtr<ViewTreeState> { |
|
jamesr
2015/10/27 23:13:11
ditto re SupportsWeak
jeffbrown
2015/10/28 01:37:29
Done.
|
| + public: |
| + ViewTreeState(mojo::ui::ViewTreePtr view_tree); |
|
jamesr
2015/10/27 23:13:11
explicit
jeffbrown
2015/10/28 01:37:29
Done.
|
| + ~ViewTreeState(); |
| + |
| + // Gets the view tree interface, never null. |
| + // Caller does not obtain ownership of the view. |
| + mojo::ui::ViewTree* view_tree() const { return view_tree_.get(); } |
| + |
| + // Sets the associated host implementation and takes ownership of it. |
| + void set_view_tree_host(mojo::ui::ViewTreeHost* host) { |
| + view_tree_host_.reset(host); |
| + } |
| + |
| + // Sets the connection error handler for the view. |
| + void set_view_tree_connection_error_handler(const base::Closure& handler) { |
| + view_tree_.set_connection_error_handler(handler); |
| + } |
| + |
| + // Gets the root of the view tree, or null if it is unavailable. |
| + ViewState* root() const { return root_; } |
| + |
| + // Sets the root of the view tree. Must not be null. |
| + // The view specified as the new root must not have any parents. |
| + void SetRoot(ViewState* root, uint32_t key); |
| + |
| + // Resets the root view to null. |
| + void ResetRoot(); |
| + |
| + // True if the client previously set but has not yet explicitly unset |
| + // the root, independent of whether it is currently available. |
| + bool root_was_set; |
|
jamesr
2015/10/27 23:13:11
public member
jeffbrown
2015/10/28 01:37:29
Done.
|
| + |
| + // True if there is a pending layout request. |
| + bool layout_request_pending; |
| + |
| + // True if a layout request has been issued. |
| + bool layout_request_issued; |
| + |
| + private: |
| + mojo::ui::ViewTreePtr view_tree_; |
| + std::unique_ptr<mojo::ui::ViewTreeHost> view_tree_host_; |
| + |
| + ViewState* root_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(ViewTreeState); |
| +}; |
| + |
| +} // namespace view_manager |
| + |
| +#endif // SERVICES_UI_VIEW_MANAGER_VIEW_TREE_STATE_H_ |