OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /* | 5 /* |
6 * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. | 6 * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. |
7 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) | 7 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) |
8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. | 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. |
9 * (http://www.torchmobile.com/) | 9 * (http://www.torchmobile.com/) |
10 * | 10 * |
(...skipping 17 matching lines...) Expand all Loading... | |
28 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 28 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
29 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 29 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
30 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 30 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
31 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 31 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
33 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 33 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
34 */ | 34 */ |
35 | 35 |
36 #include "content/renderer/history_entry.h" | 36 #include "content/renderer/history_entry.h" |
37 | 37 |
38 #include <deque> | |
39 | |
40 #include "content/renderer/render_frame_impl.h" | 38 #include "content/renderer/render_frame_impl.h" |
41 #include "content/renderer/render_view_impl.h" | 39 #include "content/renderer/render_view_impl.h" |
42 #include "third_party/WebKit/public/web/WebFrame.h" | 40 #include "third_party/WebKit/public/web/WebFrame.h" |
43 | 41 |
44 using blink::WebFrame; | 42 using blink::WebFrame; |
45 using blink::WebHistoryItem; | 43 using blink::WebHistoryItem; |
46 | 44 |
47 namespace content { | 45 namespace content { |
48 | 46 |
49 HistoryEntry::HistoryNode* HistoryEntry::HistoryNode::AddChild( | 47 HistoryEntry::HistoryNode* HistoryEntry::HistoryNode::AddChild( |
50 const WebHistoryItem& item, | 48 const WebHistoryItem& item, |
51 int64_t frame_id) { | 49 int64_t frame_id) { |
52 children_->push_back(new HistoryNode(entry_, item, frame_id)); | 50 children_->push_back(new HistoryNode(entry_, item, frame_id)); |
53 return children_->back(); | 51 return children_->back(); |
54 } | 52 } |
55 | 53 |
54 HistoryEntry::HistoryNode* HistoryEntry::HistoryNode::AddChild() { | |
55 return AddChild(WebHistoryItem(), kInvalidFrameRoutingID); | |
56 } | |
57 | |
56 HistoryEntry::HistoryNode* HistoryEntry::HistoryNode::CloneAndReplace( | 58 HistoryEntry::HistoryNode* HistoryEntry::HistoryNode::CloneAndReplace( |
57 HistoryEntry* new_entry, | 59 HistoryEntry* new_entry, |
58 const WebHistoryItem& new_item, | 60 const WebHistoryItem& new_item, |
59 bool clone_children_of_target, | 61 bool clone_children_of_target, |
60 RenderFrameImpl* target_frame, | 62 RenderFrameImpl* target_frame, |
61 RenderFrameImpl* current_frame) { | 63 RenderFrameImpl* current_frame) { |
62 bool is_target_frame = target_frame == current_frame; | 64 bool is_target_frame = target_frame == current_frame; |
63 const WebHistoryItem& item_for_create = is_target_frame ? new_item : item_; | 65 const WebHistoryItem& item_for_create = is_target_frame ? new_item : item_; |
64 HistoryNode* new_history_node = new HistoryNode( | 66 HistoryNode* new_history_node = new HistoryNode( |
65 new_entry, item_for_create, current_frame->GetRoutingID()); | 67 new_entry, item_for_create, current_frame->GetRoutingID()); |
(...skipping 17 matching lines...) Expand all Loading... | |
83 new_item, | 85 new_item, |
84 clone_children_of_target, | 86 clone_children_of_target, |
85 target_frame, | 87 target_frame, |
86 child_render_frame); | 88 child_render_frame); |
87 new_history_node->children_->push_back(new_child_node); | 89 new_history_node->children_->push_back(new_child_node); |
88 } | 90 } |
89 } | 91 } |
90 return new_history_node; | 92 return new_history_node; |
91 } | 93 } |
92 | 94 |
95 void HistoryEntry::HistoryNode::set_item(const WebHistoryItem& item) { | |
96 // The previous HistoryItem might not have ahad a target set, or it might be | |
Charlie Reis
2014/04/29 00:24:37
nit: ahad -> had
Nate Chapin
2014/04/29 19:31:53
Done.
| |
97 // different than the current one. | |
98 entry_->unique_names_to_items_[item.target().utf8()] = this; | |
99 item_ = item; | |
100 } | |
101 | |
93 HistoryEntry::HistoryNode::HistoryNode(HistoryEntry* entry, | 102 HistoryEntry::HistoryNode::HistoryNode(HistoryEntry* entry, |
94 const WebHistoryItem& item, | 103 const WebHistoryItem& item, |
95 int64_t frame_id) | 104 int64_t frame_id) |
96 : entry_(entry), item_(item) { | 105 : entry_(entry), item_(item) { |
97 if (frame_id != kInvalidFrameRoutingID) | 106 if (frame_id != kInvalidFrameRoutingID) |
98 entry_->frames_to_items_[frame_id] = this; | 107 entry_->frames_to_items_[frame_id] = this; |
99 entry_->unique_names_to_items_[item.target().utf8()] = this; | 108 if (!item.isNull()) |
109 entry_->unique_names_to_items_[item.target().utf8()] = this; | |
100 children_.reset(new ScopedVector<HistoryNode>); | 110 children_.reset(new ScopedVector<HistoryNode>); |
101 } | 111 } |
102 | 112 |
103 HistoryEntry::HistoryNode::~HistoryNode() { | 113 HistoryEntry::HistoryNode::~HistoryNode() { |
104 } | 114 } |
105 | 115 |
106 void HistoryEntry::HistoryNode::RemoveChildren() { | 116 void HistoryEntry::HistoryNode::RemoveChildren() { |
107 // TODO(japhet): This is inefficient. Figure out a cleaner way to ensure | 117 // TODO(japhet): This is inefficient. Figure out a cleaner way to ensure |
108 // this HistoryNode isn't cached anywhere. | 118 // this HistoryNode isn't cached anywhere. |
109 std::vector<uint64_t> frames_to_remove; | 119 std::vector<uint64_t> frames_to_remove; |
(...skipping 21 matching lines...) Expand all Loading... | |
131 } | 141 } |
132 } | 142 } |
133 for (unsigned i = 0; i < frames_to_remove.size(); i++) | 143 for (unsigned i = 0; i < frames_to_remove.size(); i++) |
134 entry_->frames_to_items_.erase(frames_to_remove[i]); | 144 entry_->frames_to_items_.erase(frames_to_remove[i]); |
135 for (unsigned i = 0; i < unique_names_to_remove.size(); i++) | 145 for (unsigned i = 0; i < unique_names_to_remove.size(); i++) |
136 entry_->unique_names_to_items_.erase(unique_names_to_remove[i]); | 146 entry_->unique_names_to_items_.erase(unique_names_to_remove[i]); |
137 children_.reset(new ScopedVector<HistoryNode>); | 147 children_.reset(new ScopedVector<HistoryNode>); |
138 } | 148 } |
139 | 149 |
140 HistoryEntry::HistoryEntry() { | 150 HistoryEntry::HistoryEntry() { |
151 root_.reset(new HistoryNode(this, WebHistoryItem(), kInvalidFrameRoutingID)); | |
141 } | 152 } |
142 | 153 |
143 HistoryEntry::~HistoryEntry() { | 154 HistoryEntry::~HistoryEntry() { |
144 } | 155 } |
145 | 156 |
146 HistoryEntry::HistoryEntry(const WebHistoryItem& root, int64_t frame_id) { | 157 HistoryEntry::HistoryEntry(const WebHistoryItem& root, int64_t frame_id) { |
147 root_.reset(new HistoryNode(this, root, frame_id)); | 158 root_.reset(new HistoryNode(this, root, frame_id)); |
148 } | 159 } |
149 | 160 |
150 HistoryEntry* HistoryEntry::CloneAndReplace(const WebHistoryItem& new_item, | 161 HistoryEntry* HistoryEntry::CloneAndReplace(const WebHistoryItem& new_item, |
(...skipping 17 matching lines...) Expand all Loading... | |
168 return unique_names_to_items_[frame->GetWebFrame()->uniqueName().utf8()]; | 179 return unique_names_to_items_[frame->GetWebFrame()->uniqueName().utf8()]; |
169 } | 180 } |
170 | 181 |
171 WebHistoryItem HistoryEntry::GetItemForFrame(RenderFrameImpl* frame) { | 182 WebHistoryItem HistoryEntry::GetItemForFrame(RenderFrameImpl* frame) { |
172 if (HistoryNode* history_node = GetHistoryNodeForFrame(frame)) | 183 if (HistoryNode* history_node = GetHistoryNodeForFrame(frame)) |
173 return history_node->item(); | 184 return history_node->item(); |
174 return WebHistoryItem(); | 185 return WebHistoryItem(); |
175 } | 186 } |
176 | 187 |
177 } // namespace content | 188 } // namespace content |
OLD | NEW |