Roll src/third_party/WebKit eac3800:0237a66 (svn 202606:202607)
[chromium-blink-merge.git] / components / web_view / frame_tree.h
bloba3f50d3ed2d77d9f5ccc938ae4e294a9d6671516
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 COMPONENTS_WEB_VIEW_FRAME_TREE_H_
6 #define COMPONENTS_WEB_VIEW_FRAME_TREE_H_
8 #include "components/mus/public/interfaces/view_tree.mojom.h"
9 #include "components/web_view/frame.h"
10 #include "third_party/mojo/src/mojo/public/cpp/bindings/array.h"
12 namespace mojo {
13 class String;
16 namespace web_view {
18 class FrameTreeDelegate;
19 class FrameUserData;
21 namespace mojom {
22 class FrameClient;
25 // FrameTree manages the set of Frames that comprise a single url. FrameTree
26 // owns the root Frame and each Frame owns its children. Frames are
27 // automatically deleted and removed from the tree if the corresponding view is
28 // deleted. This happens if the creator of the view deletes it (say an iframe is
29 // destroyed).
30 class FrameTree {
31 public:
32 // |view| is the view to do the initial embedding in. It is assumed |view|
33 // outlives FrameTree.
34 // |client_properties| is the client properties for the root frame.
35 // |root_app_id| is a unique identifier of the app providing |root_client|.
36 // See Frame for details on app id's.
37 FrameTree(uint32_t root_app_id,
38 mus::View* view,
39 mojo::ViewTreeClientPtr view_tree_client,
40 FrameTreeDelegate* delegate,
41 mojom::FrameClient* root_client,
42 scoped_ptr<FrameUserData> user_data,
43 const Frame::ClientPropertyMap& client_properties);
44 ~FrameTree();
46 const Frame* root() const { return root_; }
47 Frame* root() { return root_; }
48 uint32_t change_id() const { return change_id_; }
50 private:
51 friend class Frame;
53 // Creates a new Frame parented to |parent|. The Frame is considered shared in
54 // that it is sharing the FrameClient/Frame of |parent|. There may or may not
55 // be a View identified by |frame_id| yet. See Frame for details.
56 Frame* CreateChildFrame(Frame* parent,
57 mojo::InterfaceRequest<mojom::Frame> frame_request,
58 mojom::FrameClientPtr client,
59 uint32_t frame_id,
60 uint32_t app_id,
61 const Frame::ClientPropertyMap& client_properties);
63 // Increments the change id, returning the new value.
64 uint32_t AdvanceChangeID();
66 void LoadingStateChanged();
67 void TitleChanged(const mojo::String& title);
68 void DidCommitProvisionalLoad(Frame* source);
69 void ClientPropertyChanged(const Frame* source,
70 const mojo::String& name,
71 const mojo::Array<uint8_t>& value);
73 mus::View* view_;
75 FrameTreeDelegate* delegate_;
77 // |root_| is owned by this, but a raw pointer as during destruction we still
78 // want access to it.
79 Frame* root_;
81 double progress_;
83 uint32_t change_id_;
85 DISALLOW_COPY_AND_ASSIGN(FrameTree);
88 } // namespace web_view
90 #endif // COMPONENTS_WEB_VIEW_FRAME_TREE_H_