Battery Status API: add UMA logging for Linux.
[chromium-blink-merge.git] / mojo / services / view_manager / server_view.h
blob1895ee9a595c58571860eab73f70fb89ce0d6a04
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.
5 #ifndef MOJO_SERVICES_VIEW_MANAGER_SERVER_VIEW_H_
6 #define MOJO_SERVICES_VIEW_MANAGER_SERVER_VIEW_H_
8 #include <vector>
10 #include "base/logging.h"
11 #include "mojo/services/public/interfaces/view_manager/view_manager.mojom.h"
12 #include "mojo/services/view_manager/ids.h"
13 #include "mojo/services/view_manager/view_manager_export.h"
14 #include "third_party/skia/include/core/SkBitmap.h"
15 #include "ui/gfx/geometry/rect.h"
17 namespace mojo {
18 namespace service {
20 class ServerViewDelegate;
22 // Server side representation of a view. Delegate is informed of interesting
23 // events.
25 // It is assumed that all functions that mutate the tree have validated the
26 // mutation is possible before hand. For example, Reorder() assumes the supplied
27 // view is a child and not already in position.
28 class MOJO_VIEW_MANAGER_EXPORT ServerView {
29 public:
30 ServerView(ServerViewDelegate* delegate, const ViewId& id);
31 virtual ~ServerView();
33 const ViewId& id() const { return id_; }
35 void Add(ServerView* child);
36 void Remove(ServerView* child);
37 void Reorder(ServerView* child,
38 ServerView* relative,
39 OrderDirection direction);
41 const gfx::Rect& bounds() const { return bounds_; }
42 void SetBounds(const gfx::Rect& bounds);
44 const ServerView* parent() const { return parent_; }
45 ServerView* parent() { return parent_; }
47 const ServerView* GetRoot() const;
48 ServerView* GetRoot() {
49 return const_cast<ServerView*>(
50 const_cast<const ServerView*>(this)->GetRoot());
53 std::vector<const ServerView*> GetChildren() const;
54 std::vector<ServerView*> GetChildren();
56 bool Contains(const ServerView* view) const;
58 // Returns true if the window is visible. This does not consider visibility
59 // of any ancestors.
60 bool visible() const { return visible_; }
61 void SetVisible(bool value);
63 void SetBitmap(const SkBitmap& contents);
64 const SkBitmap& bitmap() const { return bitmap_; }
66 private:
67 typedef std::vector<ServerView*> Views;
69 // Implementation of removing a view. Doesn't send any notification.
70 void RemoveImpl(ServerView* view);
72 ServerViewDelegate* delegate_;
73 const ViewId id_;
74 ServerView* parent_;
75 Views children_;
76 bool visible_;
77 gfx::Rect bounds_;
78 SkBitmap bitmap_;
80 DISALLOW_COPY_AND_ASSIGN(ServerView);
83 } // namespace service
84 } // namespace mojo
86 #endif // MOJO_SERVICES_VIEW_MANAGER_SERVER_VIEW_H_