Torne (Richard Coles) | b2df76e | 2013-05-13 16:52:09 +0100 | [diff] [blame^] | 1 | // Copyright (c) 2013 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. |
| 4 | |
| 5 | #ifndef CONTENT_BROWSER_RENDERER_HOST_FRAME_TREE_NODE_H_ |
| 6 | #define CONTENT_BROWSER_RENDERER_HOST_FRAME_TREE_NODE_H_ |
| 7 | |
| 8 | #include <string> |
| 9 | #include <vector> |
| 10 | |
| 11 | #include "base/basictypes.h" |
| 12 | #include "content/common/content_export.h" |
| 13 | |
| 14 | namespace content { |
| 15 | |
| 16 | // Any page that contains iframes has a tree structure of the frames in the |
| 17 | // renderer process. We are mirroring this tree in the browser process. This |
| 18 | // class represents a node in this tree and is a wrapper for all objects that |
| 19 | // are frame-specific (as opposed to page-specific). |
| 20 | class CONTENT_EXPORT FrameTreeNode { |
| 21 | public: |
| 22 | FrameTreeNode(int64 frame_id, const std::string& name); |
| 23 | ~FrameTreeNode(); |
| 24 | |
| 25 | // This method takes ownership of the child pointer. |
| 26 | void AddChild(FrameTreeNode* child); |
| 27 | void RemoveChild(int64 child_id); |
| 28 | |
| 29 | int64 frame_id() const { |
| 30 | return frame_id_; |
| 31 | } |
| 32 | |
| 33 | const std::string& frame_name() const { |
| 34 | return frame_name_; |
| 35 | } |
| 36 | |
| 37 | size_t child_count() const { |
| 38 | return children_.size(); |
| 39 | } |
| 40 | |
| 41 | FrameTreeNode* child_at(size_t index) const { |
| 42 | return children_[index]; |
| 43 | } |
| 44 | |
| 45 | private: |
| 46 | // The unique identifier for the frame in the page. |
| 47 | int64 frame_id_; |
| 48 | |
| 49 | // The assigned name of the frame. This name can be empty, unlike the unique |
| 50 | // name generated internally in the DOM tree. |
| 51 | std::string frame_name_; |
| 52 | |
| 53 | // The immediate children of this specific frame. |
| 54 | std::vector<FrameTreeNode*> children_; |
| 55 | |
| 56 | DISALLOW_COPY_AND_ASSIGN(FrameTreeNode); |
| 57 | }; |
| 58 | |
| 59 | } // namespace content |
| 60 | |
| 61 | #endif // CONTENT_BROWSER_RENDERER_HOST_FRAME_TREE_NODE_H_ |