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 #include "content/browser/frame_host/navigation_controller_impl.h" |
| 6 |
5 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <utility> |
6 | 9 |
7 #include "base/bind.h" | 10 #include "base/bind.h" |
8 #include "base/command_line.h" | 11 #include "base/command_line.h" |
9 #include "base/macros.h" | 12 #include "base/macros.h" |
10 #include "base/strings/stringprintf.h" | 13 #include "base/strings/stringprintf.h" |
11 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
12 #include "content/browser/frame_host/frame_navigation_entry.h" | 15 #include "content/browser/frame_host/frame_navigation_entry.h" |
13 #include "content/browser/frame_host/frame_tree.h" | 16 #include "content/browser/frame_host/frame_tree.h" |
14 #include "content/browser/frame_host/navigation_controller_impl.h" | |
15 #include "content/browser/frame_host/navigation_entry_impl.h" | 17 #include "content/browser/frame_host/navigation_entry_impl.h" |
16 #include "content/browser/web_contents/web_contents_impl.h" | 18 #include "content/browser/web_contents/web_contents_impl.h" |
17 #include "content/common/site_isolation_policy.h" | 19 #include "content/common/site_isolation_policy.h" |
18 #include "content/public/browser/render_view_host.h" | 20 #include "content/public/browser/render_view_host.h" |
19 #include "content/public/browser/resource_controller.h" | 21 #include "content/public/browser/resource_controller.h" |
20 #include "content/public/browser/resource_dispatcher_host.h" | 22 #include "content/public/browser/resource_dispatcher_host.h" |
21 #include "content/public/browser/resource_dispatcher_host_delegate.h" | 23 #include "content/public/browser/resource_dispatcher_host_delegate.h" |
22 #include "content/public/browser/resource_throttle.h" | 24 #include "content/public/browser/resource_throttle.h" |
23 #include "content/public/browser/web_contents.h" | 25 #include "content/public/browser/web_contents.h" |
24 #include "content/public/browser/web_contents_observer.h" | 26 #include "content/public/browser/web_contents_observer.h" |
(...skipping 2449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2474 ASSERT_EQ(1U, restored_entry->root_node()->children.size()); | 2476 ASSERT_EQ(1U, restored_entry->root_node()->children.size()); |
2475 EXPECT_EQ(frame_url_b, | 2477 EXPECT_EQ(frame_url_b, |
2476 restored_entry->root_node()->children[0]->frame_entry->url()); | 2478 restored_entry->root_node()->children[0]->frame_entry->url()); |
2477 } else { | 2479 } else { |
2478 // There are no subframe FrameNavigationEntries by default. | 2480 // There are no subframe FrameNavigationEntries by default. |
2479 EXPECT_EQ(0U, restored_entry->root_node()->children.size()); | 2481 EXPECT_EQ(0U, restored_entry->root_node()->children.size()); |
2480 } | 2482 } |
2481 | 2483 |
2482 // 5. Restore the new entry in a new tab and verify the correct URLs load. | 2484 // 5. Restore the new entry in a new tab and verify the correct URLs load. |
2483 std::vector<scoped_ptr<NavigationEntry>> entries; | 2485 std::vector<scoped_ptr<NavigationEntry>> entries; |
2484 entries.push_back(restored_entry.Pass()); | 2486 entries.push_back(std::move(restored_entry)); |
2485 Shell* new_shell = Shell::CreateNewWindow( | 2487 Shell* new_shell = Shell::CreateNewWindow( |
2486 controller.GetBrowserContext(), GURL::EmptyGURL(), nullptr, gfx::Size()); | 2488 controller.GetBrowserContext(), GURL::EmptyGURL(), nullptr, gfx::Size()); |
2487 FrameTreeNode* new_root = | 2489 FrameTreeNode* new_root = |
2488 static_cast<WebContentsImpl*>(new_shell->web_contents()) | 2490 static_cast<WebContentsImpl*>(new_shell->web_contents()) |
2489 ->GetFrameTree() | 2491 ->GetFrameTree() |
2490 ->root(); | 2492 ->root(); |
2491 NavigationControllerImpl& new_controller = | 2493 NavigationControllerImpl& new_controller = |
2492 static_cast<NavigationControllerImpl&>( | 2494 static_cast<NavigationControllerImpl&>( |
2493 new_shell->web_contents()->GetController()); | 2495 new_shell->web_contents()->GetController()); |
2494 new_controller.Restore( | 2496 new_controller.Restore( |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2743 EXPECT_EQ(0U, restored_entry->root_node()->children.size()); | 2745 EXPECT_EQ(0U, restored_entry->root_node()->children.size()); |
2744 restored_entry->SetPageState(entry2->GetPageState()); | 2746 restored_entry->SetPageState(entry2->GetPageState()); |
2745 | 2747 |
2746 // The entry should have no SiteInstance in the FrameNavigationEntry for the | 2748 // The entry should have no SiteInstance in the FrameNavigationEntry for the |
2747 // b.com subframe. | 2749 // b.com subframe. |
2748 EXPECT_FALSE( | 2750 EXPECT_FALSE( |
2749 restored_entry->root_node()->children[0]->frame_entry->site_instance()); | 2751 restored_entry->root_node()->children[0]->frame_entry->site_instance()); |
2750 | 2752 |
2751 // 4. Restore the new entry in a new tab and verify the correct URLs load. | 2753 // 4. Restore the new entry in a new tab and verify the correct URLs load. |
2752 std::vector<scoped_ptr<NavigationEntry>> entries; | 2754 std::vector<scoped_ptr<NavigationEntry>> entries; |
2753 entries.push_back(restored_entry.Pass()); | 2755 entries.push_back(std::move(restored_entry)); |
2754 Shell* new_shell = Shell::CreateNewWindow( | 2756 Shell* new_shell = Shell::CreateNewWindow( |
2755 controller.GetBrowserContext(), GURL::EmptyGURL(), nullptr, gfx::Size()); | 2757 controller.GetBrowserContext(), GURL::EmptyGURL(), nullptr, gfx::Size()); |
2756 FrameTreeNode* new_root = | 2758 FrameTreeNode* new_root = |
2757 static_cast<WebContentsImpl*>(new_shell->web_contents()) | 2759 static_cast<WebContentsImpl*>(new_shell->web_contents()) |
2758 ->GetFrameTree() | 2760 ->GetFrameTree() |
2759 ->root(); | 2761 ->root(); |
2760 NavigationControllerImpl& new_controller = | 2762 NavigationControllerImpl& new_controller = |
2761 static_cast<NavigationControllerImpl&>( | 2763 static_cast<NavigationControllerImpl&>( |
2762 new_shell->web_contents()->GetController()); | 2764 new_shell->web_contents()->GetController()); |
2763 new_controller.Restore( | 2765 new_controller.Restore( |
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3185 EXPECT_EQ(original_url, capturer.all_params()[1].url); | 3187 EXPECT_EQ(original_url, capturer.all_params()[1].url); |
3186 EXPECT_EQ(original_url, shell()->web_contents()->GetLastCommittedURL()); | 3188 EXPECT_EQ(original_url, shell()->web_contents()->GetLastCommittedURL()); |
3187 } | 3189 } |
3188 | 3190 |
3189 // Make sure the renderer is still alive. | 3191 // Make sure the renderer is still alive. |
3190 EXPECT_TRUE( | 3192 EXPECT_TRUE( |
3191 ExecuteScript(shell()->web_contents(), "console.log('Success');")); | 3193 ExecuteScript(shell()->web_contents(), "console.log('Success');")); |
3192 } | 3194 } |
3193 | 3195 |
3194 } // namespace content | 3196 } // namespace content |
OLD | NEW |