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/navigator_impl.h" | 5 #include "content/browser/frame_host/navigator_impl.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "content/browser/frame_host/frame_tree.h" | 8 #include "content/browser/frame_host/frame_tree.h" |
9 #include "content/browser/frame_host/frame_tree_node.h" | 9 #include "content/browser/frame_host/frame_tree_node.h" |
10 #include "content/browser/frame_host/navigation_controller_impl.h" | 10 #include "content/browser/frame_host/navigation_controller_impl.h" |
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 } | 419 } |
420 | 420 |
421 if (PageTransitionIsMainFrame(params.transition)) { | 421 if (PageTransitionIsMainFrame(params.transition)) { |
422 if (delegate_) { | 422 if (delegate_) { |
423 // When overscroll navigation gesture is enabled, a screenshot of the page | 423 // When overscroll navigation gesture is enabled, a screenshot of the page |
424 // in its current state is taken so that it can be used during the | 424 // in its current state is taken so that it can be used during the |
425 // nav-gesture. It is necessary to take the screenshot here, before | 425 // nav-gesture. It is necessary to take the screenshot here, before |
426 // calling RenderFrameHostManager::DidNavigateMainFrame, because that can | 426 // calling RenderFrameHostManager::DidNavigateMainFrame, because that can |
427 // change WebContents::GetRenderViewHost to return the new host, instead | 427 // change WebContents::GetRenderViewHost to return the new host, instead |
428 // of the one that may have just been swapped out. | 428 // of the one that may have just been swapped out. |
429 if (delegate_->CanOverscrollContent()) | 429 if (delegate_->CanOverscrollContent()) { |
430 controller_->TakeScreenshot(); | 430 bool page_id_changed; |
| 431 bool url_changed; |
| 432 NavigationEntry* current_entry = controller_->GetLastCommittedEntry(); |
| 433 if (current_entry) { |
| 434 page_id_changed = params.page_id > 0 && |
| 435 params.page_id != current_entry->GetPageID(); |
| 436 url_changed = params.url != current_entry->GetURL(); |
| 437 } else { |
| 438 page_id_changed = params.page_id > 0; |
| 439 url_changed = params.url != GURL::EmptyGURL(); |
| 440 } |
| 441 |
| 442 // We only want to take the screenshot if the are navigating to a |
| 443 // different history entry than the current one. So if neither the |
| 444 // page id nor the url changed - don't take the screenshot. |
| 445 if (page_id_changed || url_changed) |
| 446 controller_->TakeScreenshot(); |
| 447 } |
431 | 448 |
432 // Run tasks that must execute just before the commit. | 449 // Run tasks that must execute just before the commit. |
433 delegate_->DidNavigateMainFramePreCommit(params); | 450 delegate_->DidNavigateMainFramePreCommit(params); |
434 } | 451 } |
435 | 452 |
436 if (!use_site_per_process) | 453 if (!use_site_per_process) |
437 frame_tree->root()->render_manager()->DidNavigateFrame(render_frame_host); | 454 frame_tree->root()->render_manager()->DidNavigateFrame(render_frame_host); |
438 } | 455 } |
439 | 456 |
440 // When using --site-per-process, we notify the RFHM for all navigations, | 457 // When using --site-per-process, we notify the RFHM for all navigations, |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
614 | 631 |
615 // Navigations in Web UI pages count as browser-initiated navigations. | 632 // Navigations in Web UI pages count as browser-initiated navigations. |
616 params.is_renderer_initiated = false; | 633 params.is_renderer_initiated = false; |
617 } | 634 } |
618 | 635 |
619 if (delegate_) | 636 if (delegate_) |
620 delegate_->RequestOpenURL(render_frame_host, params); | 637 delegate_->RequestOpenURL(render_frame_host, params); |
621 } | 638 } |
622 | 639 |
623 } // namespace content | 640 } // namespace content |
OLD | NEW |