Updating XTBs based on .GRDs from branch master
[chromium-blink-merge.git] / mandoline / tab / frame_tree.h
blobb4bd59062cd772eb000e9ea47e760b7374fb2e5c
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.
5 #ifndef MANDOLINE_TAB_FRAME_TREE_H_
6 #define MANDOLINE_TAB_FRAME_TREE_H_
8 #include "mandoline/tab/frame.h"
9 #include "third_party/mojo/src/mojo/public/cpp/bindings/array.h"
11 namespace mojo {
12 class String;
15 namespace mandoline {
17 class FrameTreeClient;
18 class FrameTreeDelegate;
19 class FrameUserData;
21 // FrameTree manages the set of Frames that comprise a single url. FrameTree
22 // owns the root Frame and each Frame owns its children. Frames are
23 // automatically deleted and removed from the tree if the corresponding view is
24 // deleted. This happens if the creator of the view deletes it (say an iframe is
25 // destroyed).
26 class FrameTree {
27 public:
28 // |view| is the view to do the initial embedding in. It is assumed |view|
29 // outlives FrameTree.
30 FrameTree(mojo::View* view,
31 FrameTreeDelegate* delegate,
32 FrameTreeClient* root_client,
33 scoped_ptr<FrameUserData> user_data);
34 ~FrameTree();
36 Frame* root() { return &root_; }
38 Frame* CreateAndAddFrame(mojo::View* view,
39 Frame* parent,
40 FrameTreeClient* client,
41 scoped_ptr<FrameUserData> user_data);
43 // If frame->view() == |view|, then all of |frame|'s children are destroyed
44 // and |frame| is reused. Otherwise a new Frame is created as a child of
45 // |frame|. It is expected this is called from
46 // ViewManagerDelegate::OnEmbedForDescendant().
47 Frame* CreateOrReplaceFrame(Frame* frame,
48 mojo::View* view,
49 FrameTreeClient* frame_tree_client,
50 scoped_ptr<FrameUserData> user_data);
52 // Creates a new Frame parented to |parent|. The Frame is considered shared in
53 // that it is sharing the FrameTreeClient/FrameTreeServer of |parent|. There
54 // may or may not be a View identified by |frame_id| yet. See Frame for
55 // details.
56 void CreateSharedFrame(Frame* parent,
57 uint32_t frame_id,
58 const Frame::ClientPropertyMap& client_properties);
60 private:
61 friend class Frame;
63 Frame* CreateAndAddFrameImpl(
64 mojo::View* view,
65 uint32_t frame_id,
66 Frame* parent,
67 FrameTreeClient* client,
68 scoped_ptr<FrameUserData> user_data,
69 const Frame::ClientPropertyMap& client_properties);
71 void LoadingStateChanged();
72 void ProgressChanged();
73 void ClientPropertyChanged(const Frame* source,
74 const mojo::String& name,
75 const mojo::Array<uint8_t>& value);
77 mojo::View* view_;
79 FrameTreeDelegate* delegate_;
81 Frame root_;
83 double progress_;
85 DISALLOW_COPY_AND_ASSIGN(FrameTree);
88 } // namespace mandoline
90 #endif // MANDOLINE_TAB_FRAME_TREE_H_