OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include "content/browser/frame_host/navigation_entry_impl.h" | 5 #include "content/browser/frame_host/navigation_entry_impl.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <queue> | 9 #include <queue> |
10 #include <utility> | 10 #include <utility> |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 // Set a single-frame PageState on the entry. | 52 // Set a single-frame PageState on the entry. |
53 ExplodedPageState page_state; | 53 ExplodedPageState page_state; |
54 page_state.top = state; | 54 page_state.top = state; |
55 std::string data; | 55 std::string data; |
56 EncodePageState(page_state, &data); | 56 EncodePageState(page_state, &data); |
57 if (data.empty()) { | 57 if (data.empty()) { |
58 // Temporarily generate a minidump to diagnose https://crbug.com/568703. | 58 // Temporarily generate a minidump to diagnose https://crbug.com/568703. |
59 base::debug::DumpWithoutCrashing(); | 59 base::debug::DumpWithoutCrashing(); |
60 NOTREACHED() << "Shouldn't generate an empty PageState."; | 60 NOTREACHED() << "Shouldn't generate an empty PageState."; |
61 } | 61 } |
62 node->frame_entry->set_page_state(PageState::CreateFromEncodedData(data)); | 62 node->frame_entry->SetPageState(PageState::CreateFromEncodedData(data)); |
63 | 63 |
64 for (const ExplodedFrameState& child_state : state.children) { | 64 for (const ExplodedFrameState& child_state : state.children) { |
65 NavigationEntryImpl::TreeNode* child_node = | 65 NavigationEntryImpl::TreeNode* child_node = |
66 new NavigationEntryImpl::TreeNode(node, nullptr); | 66 new NavigationEntryImpl::TreeNode(node, nullptr); |
67 node->children.push_back(child_node); | 67 node->children.push_back(child_node); |
68 RecursivelyGenerateFrameEntries(child_state, child_node); | 68 RecursivelyGenerateFrameEntries(child_state, child_node); |
69 } | 69 } |
70 } | 70 } |
71 | 71 |
72 void RecursivelyGenerateFrameState( | 72 void RecursivelyGenerateFrameState( |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 title_ = title; | 331 title_ = title; |
332 cached_display_title_.clear(); | 332 cached_display_title_.clear(); |
333 } | 333 } |
334 | 334 |
335 const base::string16& NavigationEntryImpl::GetTitle() const { | 335 const base::string16& NavigationEntryImpl::GetTitle() const { |
336 return title_; | 336 return title_; |
337 } | 337 } |
338 | 338 |
339 void NavigationEntryImpl::SetPageState(const PageState& state) { | 339 void NavigationEntryImpl::SetPageState(const PageState& state) { |
340 if (!SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 340 if (!SiteIsolationPolicy::UseSubframeNavigationEntries()) { |
341 frame_tree_->frame_entry->set_page_state(state); | 341 frame_tree_->frame_entry->SetPageState(state); |
342 return; | 342 return; |
343 } | 343 } |
344 | 344 |
345 // SetPageState should only be called before the NavigationEntry has been | 345 // SetPageState should only be called before the NavigationEntry has been |
346 // loaded, such as for restore (when there are no subframe | 346 // loaded, such as for restore (when there are no subframe |
347 // FrameNavigationEntries yet). However, some callers expect to call this | 347 // FrameNavigationEntries yet). However, some callers expect to call this |
348 // after a Clone but before loading the page. Clone will copy over the | 348 // after a Clone but before loading the page. Clone will copy over the |
349 // subframe entries, and we should reset them before setting the state again. | 349 // subframe entries, and we should reset them before setting the state again. |
350 // | 350 // |
351 // TODO(creis): It would be good to verify that this NavigationEntry hasn't | 351 // TODO(creis): It would be good to verify that this NavigationEntry hasn't |
352 // been loaded yet in cases that SetPageState is called while subframe | 352 // been loaded yet in cases that SetPageState is called while subframe |
353 // entries exist, but there's currently no way to check that. | 353 // entries exist, but there's currently no way to check that. |
354 if (!frame_tree_->children.empty()) | 354 if (!frame_tree_->children.empty()) |
355 frame_tree_->children.clear(); | 355 frame_tree_->children.clear(); |
356 | 356 |
357 // If the PageState can't be parsed or has no children, just store it on the | 357 // If the PageState can't be parsed or has no children, just store it on the |
358 // main frame's FrameNavigationEntry without recursively creating subframe | 358 // main frame's FrameNavigationEntry without recursively creating subframe |
359 // entries. | 359 // entries. |
360 ExplodedPageState exploded_state; | 360 ExplodedPageState exploded_state; |
361 if (!DecodePageState(state.ToEncodedData(), &exploded_state) || | 361 if (!DecodePageState(state.ToEncodedData(), &exploded_state) || |
362 exploded_state.top.children.size() == 0U) { | 362 exploded_state.top.children.size() == 0U) { |
363 frame_tree_->frame_entry->set_page_state(state); | 363 frame_tree_->frame_entry->SetPageState(state); |
364 return; | 364 return; |
365 } | 365 } |
366 | 366 |
367 RecursivelyGenerateFrameEntries(exploded_state.top, frame_tree_.get()); | 367 RecursivelyGenerateFrameEntries(exploded_state.top, frame_tree_.get()); |
368 } | 368 } |
369 | 369 |
370 PageState NavigationEntryImpl::GetPageState() const { | 370 PageState NavigationEntryImpl::GetPageState() const { |
371 // Just return the main frame's PageState in default Chrome, or if there are | 371 // Just return the main frame's PageState in default Chrome, or if there are |
372 // no subframe FrameNavigationEntries. | 372 // no subframe FrameNavigationEntries. |
373 if (!SiteIsolationPolicy::UseSubframeNavigationEntries() || | 373 if (!SiteIsolationPolicy::UseSubframeNavigationEntries() || |
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
828 } | 828 } |
829 } | 829 } |
830 | 830 |
831 // No entry exists yet, so create a new one. | 831 // No entry exists yet, so create a new one. |
832 // Unordered list, since we expect to look up entries by frame sequence number | 832 // Unordered list, since we expect to look up entries by frame sequence number |
833 // or unique name. | 833 // or unique name. |
834 FrameNavigationEntry* frame_entry = new FrameNavigationEntry( | 834 FrameNavigationEntry* frame_entry = new FrameNavigationEntry( |
835 unique_name, item_sequence_number, document_sequence_number, | 835 unique_name, item_sequence_number, document_sequence_number, |
836 site_instance, std::move(source_site_instance), url, referrer, method, | 836 site_instance, std::move(source_site_instance), url, referrer, method, |
837 post_id); | 837 post_id); |
838 frame_entry->set_page_state(page_state); | 838 frame_entry->SetPageState(page_state); |
839 parent_node->children.push_back( | 839 parent_node->children.push_back( |
840 new NavigationEntryImpl::TreeNode(parent_node, frame_entry)); | 840 new NavigationEntryImpl::TreeNode(parent_node, frame_entry)); |
841 } | 841 } |
842 | 842 |
843 FrameNavigationEntry* NavigationEntryImpl::GetFrameEntry( | 843 FrameNavigationEntry* NavigationEntryImpl::GetFrameEntry( |
844 FrameTreeNode* frame_tree_node) const { | 844 FrameTreeNode* frame_tree_node) const { |
845 NavigationEntryImpl::TreeNode* tree_node = FindFrameEntry(frame_tree_node); | 845 NavigationEntryImpl::TreeNode* tree_node = FindFrameEntry(frame_tree_node); |
846 return tree_node ? tree_node->frame_entry.get() : nullptr; | 846 return tree_node ? tree_node->frame_entry.get() : nullptr; |
847 } | 847 } |
848 | 848 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
906 return node; | 906 return node; |
907 | 907 |
908 // Enqueue any children and keep looking. | 908 // Enqueue any children and keep looking. |
909 for (auto* child : node->children) | 909 for (auto* child : node->children) |
910 work_queue.push(child); | 910 work_queue.push(child); |
911 } | 911 } |
912 return nullptr; | 912 return nullptr; |
913 } | 913 } |
914 | 914 |
915 } // namespace content | 915 } // namespace content |
OLD | NEW |