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"
17 class FrameTreeClient
;
18 class FrameTreeDelegate
;
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
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
);
36 Frame
* root() { return &root_
; }
38 Frame
* CreateAndAddFrame(mojo::View
* view
,
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
,
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
56 void CreateSharedFrame(Frame
* parent
,
58 const Frame::ClientPropertyMap
& client_properties
);
63 Frame
* CreateAndAddFrameImpl(
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
);
79 FrameTreeDelegate
* delegate_
;
85 DISALLOW_COPY_AND_ASSIGN(FrameTree
);
88 } // namespace mandoline
90 #endif // MANDOLINE_TAB_FRAME_TREE_H_