| 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 <queue> | 7 #include <queue> |
| 8 | 8 |
| 9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 void NavigationEntryImpl::SetTitle(const base::string16& title) { | 148 void NavigationEntryImpl::SetTitle(const base::string16& title) { |
| 149 title_ = title; | 149 title_ = title; |
| 150 cached_display_title_.clear(); | 150 cached_display_title_.clear(); |
| 151 } | 151 } |
| 152 | 152 |
| 153 const base::string16& NavigationEntryImpl::GetTitle() const { | 153 const base::string16& NavigationEntryImpl::GetTitle() const { |
| 154 return title_; | 154 return title_; |
| 155 } | 155 } |
| 156 | 156 |
| 157 void NavigationEntryImpl::SetPageState(const PageState& state) { | 157 void NavigationEntryImpl::SetPageState(const PageState& state) { |
| 158 page_state_ = state; | 158 frame_tree_->frame_entry->set_page_state(state); |
| 159 } | 159 } |
| 160 | 160 |
| 161 const PageState& NavigationEntryImpl::GetPageState() const { | 161 const PageState& NavigationEntryImpl::GetPageState() const { |
| 162 return page_state_; | 162 return frame_tree_->frame_entry->page_state(); |
| 163 } | 163 } |
| 164 | 164 |
| 165 void NavigationEntryImpl::SetPageID(int page_id) { | 165 void NavigationEntryImpl::SetPageID(int page_id) { |
| 166 page_id_ = page_id; | 166 page_id_ = page_id; |
| 167 } | 167 } |
| 168 | 168 |
| 169 int32 NavigationEntryImpl::GetPageID() const { | 169 int32 NavigationEntryImpl::GetPageID() const { |
| 170 return page_id_; | 170 return page_id_; |
| 171 } | 171 } |
| 172 | 172 |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 copy->frame_tree_.reset(frame_tree_->Clone()); | 358 copy->frame_tree_.reset(frame_tree_->Clone()); |
| 359 | 359 |
| 360 // Copy most state over, unless cleared in ResetForCommit. | 360 // Copy most state over, unless cleared in ResetForCommit. |
| 361 // Don't copy unique_id_, otherwise it won't be unique. | 361 // Don't copy unique_id_, otherwise it won't be unique. |
| 362 copy->bindings_ = bindings_; | 362 copy->bindings_ = bindings_; |
| 363 copy->page_type_ = page_type_; | 363 copy->page_type_ = page_type_; |
| 364 copy->virtual_url_ = virtual_url_; | 364 copy->virtual_url_ = virtual_url_; |
| 365 copy->update_virtual_url_with_url_ = update_virtual_url_with_url_; | 365 copy->update_virtual_url_with_url_ = update_virtual_url_with_url_; |
| 366 copy->title_ = title_; | 366 copy->title_ = title_; |
| 367 copy->favicon_ = favicon_; | 367 copy->favicon_ = favicon_; |
| 368 copy->page_state_ = page_state_; | |
| 369 copy->page_id_ = page_id_; | 368 copy->page_id_ = page_id_; |
| 370 copy->ssl_ = ssl_; | 369 copy->ssl_ = ssl_; |
| 371 copy->transition_type_ = transition_type_; | 370 copy->transition_type_ = transition_type_; |
| 372 copy->user_typed_url_ = user_typed_url_; | 371 copy->user_typed_url_ = user_typed_url_; |
| 373 copy->has_post_data_ = has_post_data_; | 372 copy->has_post_data_ = has_post_data_; |
| 374 copy->post_id_ = post_id_; | 373 copy->post_id_ = post_id_; |
| 375 copy->restore_type_ = restore_type_; | 374 copy->restore_type_ = restore_type_; |
| 376 copy->original_request_url_ = original_request_url_; | 375 copy->original_request_url_ = original_request_url_; |
| 377 copy->is_overriding_user_agent_ = is_overriding_user_agent_; | 376 copy->is_overriding_user_agent_ = is_overriding_user_agent_; |
| 378 copy->timestamp_ = timestamp_; | 377 copy->timestamp_ = timestamp_; |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 478 #if defined(OS_ANDROID) | 477 #if defined(OS_ANDROID) |
| 479 // Reset the time stamp so that the metrics are not reported if this entry is | 478 // Reset the time stamp so that the metrics are not reported if this entry is |
| 480 // loaded again in the future. | 479 // loaded again in the future. |
| 481 set_intent_received_timestamp(base::TimeTicks()); | 480 set_intent_received_timestamp(base::TimeTicks()); |
| 482 #endif | 481 #endif |
| 483 } | 482 } |
| 484 | 483 |
| 485 void NavigationEntryImpl::AddOrUpdateFrameEntry(FrameTreeNode* frame_tree_node, | 484 void NavigationEntryImpl::AddOrUpdateFrameEntry(FrameTreeNode* frame_tree_node, |
| 486 SiteInstanceImpl* site_instance, | 485 SiteInstanceImpl* site_instance, |
| 487 const GURL& url, | 486 const GURL& url, |
| 488 const Referrer& referrer) { | 487 const Referrer& referrer, |
| 488 const PageState& page_state) { |
| 489 // We should already have a TreeNode for the parent node by the time this node | 489 // We should already have a TreeNode for the parent node by the time this node |
| 490 // commits. Find it first. | 490 // commits. Find it first. |
| 491 DCHECK(frame_tree_node->parent()); | 491 DCHECK(frame_tree_node->parent()); |
| 492 NavigationEntryImpl::TreeNode* parent_node = | 492 NavigationEntryImpl::TreeNode* parent_node = |
| 493 FindFrameEntry(frame_tree_node->parent()); | 493 FindFrameEntry(frame_tree_node->parent()); |
| 494 if (!parent_node) { | 494 if (!parent_node) { |
| 495 // The renderer should not send a commit for a subframe before its parent. | 495 // The renderer should not send a commit for a subframe before its parent. |
| 496 // TODO(creis): This can currently happen because we don't yet clone the | 496 // TODO(creis): This can currently happen because we don't yet clone the |
| 497 // FrameNavigationEntry tree on manual subframe navigations. Once that's | 497 // FrameNavigationEntry tree on manual subframe navigations. Once that's |
| 498 // added, we should kill the renderer if we get here. | 498 // added, we should kill the renderer if we get here. |
| 499 return; | 499 return; |
| 500 } | 500 } |
| 501 | 501 |
| 502 // Now check whether we have a TreeNode for the node itself. | 502 // Now check whether we have a TreeNode for the node itself. |
| 503 int frame_tree_node_id = frame_tree_node->frame_tree_node_id(); | 503 int frame_tree_node_id = frame_tree_node->frame_tree_node_id(); |
| 504 for (TreeNode* child : parent_node->children) { | 504 for (TreeNode* child : parent_node->children) { |
| 505 if (child->frame_entry->frame_tree_node_id() == frame_tree_node_id) { | 505 if (child->frame_entry->frame_tree_node_id() == frame_tree_node_id) { |
| 506 // Update the existing FrameNavigationEntry. | 506 // Update the existing FrameNavigationEntry. |
| 507 child->frame_entry->UpdateEntry(site_instance, url, referrer); | 507 child->frame_entry->UpdateEntry(site_instance, url, referrer, page_state); |
| 508 return; | 508 return; |
| 509 } | 509 } |
| 510 } | 510 } |
| 511 | 511 |
| 512 // No entry exists yet, so create a new one unless it's for about:blank. | 512 // No entry exists yet, so create a new one unless it's for about:blank. |
| 513 // Unordered list, since we expect to look up entries by frame sequence number | 513 // Unordered list, since we expect to look up entries by frame sequence number |
| 514 // or unique name. | 514 // or unique name. |
| 515 if (url == GURL(url::kAboutBlankURL)) | 515 if (url == GURL(url::kAboutBlankURL)) |
| 516 return; | 516 return; |
| 517 FrameNavigationEntry* frame_entry = new FrameNavigationEntry( | 517 FrameNavigationEntry* frame_entry = new FrameNavigationEntry( |
| 518 frame_tree_node_id, site_instance, url, referrer); | 518 frame_tree_node_id, site_instance, url, referrer); |
| 519 frame_entry->set_page_state(page_state); |
| 519 parent_node->children.push_back( | 520 parent_node->children.push_back( |
| 520 new NavigationEntryImpl::TreeNode(frame_entry)); | 521 new NavigationEntryImpl::TreeNode(frame_entry)); |
| 521 } | 522 } |
| 522 | 523 |
| 523 bool NavigationEntryImpl::HasFrameEntry(FrameTreeNode* frame_tree_node) const { | 524 bool NavigationEntryImpl::HasFrameEntry(FrameTreeNode* frame_tree_node) const { |
| 524 return FindFrameEntry(frame_tree_node) != nullptr; | 525 return FindFrameEntry(frame_tree_node) != nullptr; |
| 525 } | 526 } |
| 526 | 527 |
| 527 void NavigationEntryImpl::SetScreenshotPNGData( | 528 void NavigationEntryImpl::SetScreenshotPNGData( |
| 528 scoped_refptr<base::RefCountedBytes> png_data) { | 529 scoped_refptr<base::RefCountedBytes> png_data) { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 550 return node; | 551 return node; |
| 551 } | 552 } |
| 552 // Enqueue any children and keep looking. | 553 // Enqueue any children and keep looking. |
| 553 for (auto& child : node->children) | 554 for (auto& child : node->children) |
| 554 work_queue.push(child); | 555 work_queue.push(child); |
| 555 } | 556 } |
| 556 return nullptr; | 557 return nullptr; |
| 557 } | 558 } |
| 558 | 559 |
| 559 } // namespace content | 560 } // namespace content |
| OLD | NEW |