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 // |client_properties| is the client properties for the root frame.
31 FrameTree(mojo::View
* view
,
32 FrameTreeDelegate
* delegate
,
33 FrameTreeClient
* root_client
,
34 scoped_ptr
<FrameUserData
> user_data
,
35 const Frame::ClientPropertyMap
& client_properties
);
38 Frame
* root() { return &root_
; }
40 uint32_t change_id() const { return change_id_
; }
42 Frame
* CreateAndAddFrame(mojo::View
* view
,
44 FrameTreeClient
* client
,
45 scoped_ptr
<FrameUserData
> user_data
);
47 // Creates a new Frame parented to |parent|. The Frame is considered shared in
48 // that it is sharing the FrameTreeClient/FrameTreeServer of |parent|. There
49 // may or may not be a View identified by |frame_id| yet. See Frame for
51 void CreateSharedFrame(Frame
* parent
,
53 const Frame::ClientPropertyMap
& client_properties
);
58 // Increments the change id, returning the new value.
59 uint32_t AdvanceChangeID();
61 Frame
* CreateAndAddFrameImpl(
65 FrameTreeClient
* client
,
66 scoped_ptr
<FrameUserData
> user_data
,
67 const Frame::ClientPropertyMap
& client_properties
);
69 void LoadingStateChanged();
70 void ProgressChanged();
71 void ClientPropertyChanged(const Frame
* source
,
72 const mojo::String
& name
,
73 const mojo::Array
<uint8_t>& value
);
77 FrameTreeDelegate
* delegate_
;
85 DISALLOW_COPY_AND_ASSIGN(FrameTree
);
88 } // namespace mandoline
90 #endif // MANDOLINE_TAB_FRAME_TREE_H_