| 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 "base/files/file_path.h" | 5 #include "base/files/file_path.h" |
| 6 #include "base/strings/utf_string_conversions.h" | 6 #include "base/strings/utf_string_conversions.h" |
| 7 #include "content/browser/frame_host/cross_site_transferring_request.h" | 7 #include "content/browser/frame_host/cross_site_transferring_request.h" |
| 8 #include "content/browser/frame_host/navigation_controller_impl.h" | 8 #include "content/browser/frame_host/navigation_controller_impl.h" |
| 9 #include "content/browser/frame_host/navigation_entry_impl.h" | 9 #include "content/browser/frame_host/navigation_entry_impl.h" |
| 10 #include "content/browser/frame_host/navigator.h" | 10 #include "content/browser/frame_host/navigator.h" |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 : WebContentsObserver(web_contents), | 167 : WebContentsObserver(web_contents), |
| 168 plugin_crashed_(false), | 168 plugin_crashed_(false), |
| 169 favicon_received_(false) { } | 169 favicon_received_(false) { } |
| 170 | 170 |
| 171 virtual void PluginCrashed(const base::FilePath& plugin_path, | 171 virtual void PluginCrashed(const base::FilePath& plugin_path, |
| 172 base::ProcessId plugin_pid) OVERRIDE { | 172 base::ProcessId plugin_pid) OVERRIDE { |
| 173 plugin_crashed_ = true; | 173 plugin_crashed_ = true; |
| 174 } | 174 } |
| 175 | 175 |
| 176 virtual void DidUpdateFaviconURL( | 176 virtual void DidUpdateFaviconURL( |
| 177 int32 page_id, | |
| 178 const std::vector<FaviconURL>& candidates) OVERRIDE { | 177 const std::vector<FaviconURL>& candidates) OVERRIDE { |
| 179 favicon_received_ = true; | 178 favicon_received_ = true; |
| 180 } | 179 } |
| 181 | 180 |
| 182 bool plugin_crashed() { | 181 bool plugin_crashed() { |
| 183 return plugin_crashed_; | 182 return plugin_crashed_; |
| 184 } | 183 } |
| 185 | 184 |
| 186 bool favicon_received() { | 185 bool favicon_received() { |
| 187 return favicon_received_; | 186 return favicon_received_; |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 392 NavigateActiveAndCommit(kChromeURL); | 391 NavigateActiveAndCommit(kChromeURL); |
| 393 TestRenderViewHost* ntp_rvh = static_cast<TestRenderViewHost*>( | 392 TestRenderViewHost* ntp_rvh = static_cast<TestRenderViewHost*>( |
| 394 contents()->GetRenderManagerForTesting()->current_host()); | 393 contents()->GetRenderManagerForTesting()->current_host()); |
| 395 | 394 |
| 396 // Send an update favicon message and make sure it works. | 395 // Send an update favicon message and make sure it works. |
| 397 const base::string16 ntp_title = base::ASCIIToUTF16("NTP Title"); | 396 const base::string16 ntp_title = base::ASCIIToUTF16("NTP Title"); |
| 398 { | 397 { |
| 399 PluginFaviconMessageObserver observer(contents()); | 398 PluginFaviconMessageObserver observer(contents()); |
| 400 EXPECT_TRUE(ntp_rvh->OnMessageReceived( | 399 EXPECT_TRUE(ntp_rvh->OnMessageReceived( |
| 401 ViewHostMsg_UpdateFaviconURL( | 400 ViewHostMsg_UpdateFaviconURL( |
| 402 rvh()->GetRoutingID(), 0, icons))); | 401 rvh()->GetRoutingID(), icons))); |
| 403 EXPECT_TRUE(observer.favicon_received()); | 402 EXPECT_TRUE(observer.favicon_received()); |
| 404 } | 403 } |
| 405 // Create one more view in the same SiteInstance where ntp_rvh | 404 // Create one more view in the same SiteInstance where ntp_rvh |
| 406 // exists so that it doesn't get deleted on navigation to another | 405 // exists so that it doesn't get deleted on navigation to another |
| 407 // site. | 406 // site. |
| 408 static_cast<SiteInstanceImpl*>(ntp_rvh->GetSiteInstance())-> | 407 static_cast<SiteInstanceImpl*>(ntp_rvh->GetSiteInstance())-> |
| 409 increment_active_view_count(); | 408 increment_active_view_count(); |
| 410 | 409 |
| 411 | 410 |
| 412 // Navigate to a cross-site URL. | 411 // Navigate to a cross-site URL. |
| 413 NavigateActiveAndCommit(kDestUrl); | 412 NavigateActiveAndCommit(kDestUrl); |
| 414 TestRenderViewHost* dest_rvh = static_cast<TestRenderViewHost*>( | 413 TestRenderViewHost* dest_rvh = static_cast<TestRenderViewHost*>( |
| 415 contents()->GetRenderViewHost()); | 414 contents()->GetRenderViewHost()); |
| 416 ASSERT_TRUE(dest_rvh); | 415 ASSERT_TRUE(dest_rvh); |
| 417 EXPECT_NE(ntp_rvh, dest_rvh); | 416 EXPECT_NE(ntp_rvh, dest_rvh); |
| 418 | 417 |
| 419 // The new RVH should be able to update its favicon. | 418 // The new RVH should be able to update its favicon. |
| 420 const base::string16 dest_title = base::ASCIIToUTF16("Google"); | 419 const base::string16 dest_title = base::ASCIIToUTF16("Google"); |
| 421 { | 420 { |
| 422 PluginFaviconMessageObserver observer(contents()); | 421 PluginFaviconMessageObserver observer(contents()); |
| 423 EXPECT_TRUE( | 422 EXPECT_TRUE( |
| 424 dest_rvh->OnMessageReceived( | 423 dest_rvh->OnMessageReceived( |
| 425 ViewHostMsg_UpdateFaviconURL(rvh()->GetRoutingID(), 101, icons))); | 424 ViewHostMsg_UpdateFaviconURL(rvh()->GetRoutingID(), icons))); |
| 426 EXPECT_TRUE(observer.favicon_received()); | 425 EXPECT_TRUE(observer.favicon_received()); |
| 427 } | 426 } |
| 428 | 427 |
| 429 // The old renderer, being slow, now updates the favicon. It should be | 428 // The old renderer, being slow, now updates the favicon. It should be |
| 430 // filtered out and not take effect. | 429 // filtered out and not take effect. |
| 431 EXPECT_TRUE(ntp_rvh->IsSwappedOut()); | 430 EXPECT_TRUE(ntp_rvh->IsSwappedOut()); |
| 432 { | 431 { |
| 433 PluginFaviconMessageObserver observer(contents()); | 432 PluginFaviconMessageObserver observer(contents()); |
| 434 EXPECT_TRUE( | 433 EXPECT_TRUE( |
| 435 ntp_rvh->OnMessageReceived( | 434 ntp_rvh->OnMessageReceived( |
| 436 ViewHostMsg_UpdateFaviconURL(rvh()->GetRoutingID(), 101, icons))); | 435 ViewHostMsg_UpdateFaviconURL(rvh()->GetRoutingID(), icons))); |
| 437 EXPECT_FALSE(observer.favicon_received()); | 436 EXPECT_FALSE(observer.favicon_received()); |
| 438 } | 437 } |
| 439 | 438 |
| 440 // The same logic should apply to RenderFrameHosts as well and routing through | 439 // The same logic should apply to RenderFrameHosts as well and routing through |
| 441 // swapped out RFH shouldn't be allowed. Use a PluginCrashObserver to check | 440 // swapped out RFH shouldn't be allowed. Use a PluginCrashObserver to check |
| 442 // if the IPC message is allowed through or not. | 441 // if the IPC message is allowed through or not. |
| 443 { | 442 { |
| 444 PluginFaviconMessageObserver observer(contents()); | 443 PluginFaviconMessageObserver observer(contents()); |
| 445 // TODO(nasko): Check that the RFH is in swapped out when the state moves | 444 // TODO(nasko): Check that the RFH is in swapped out when the state moves |
| 446 // from RVH to RFH. | 445 // from RVH to RFH. |
| (...skipping 1394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1841 pending_rfh->GetSiteInstance())->increment_active_view_count(); | 1840 pending_rfh->GetSiteInstance())->increment_active_view_count(); |
| 1842 | 1841 |
| 1843 main_test_rfh()->OnMessageReceived( | 1842 main_test_rfh()->OnMessageReceived( |
| 1844 FrameHostMsg_BeforeUnload_ACK(0, false, now, now)); | 1843 FrameHostMsg_BeforeUnload_ACK(0, false, now, now)); |
| 1845 EXPECT_FALSE(contents()->cross_navigation_pending()); | 1844 EXPECT_FALSE(contents()->cross_navigation_pending()); |
| 1846 EXPECT_FALSE(rvh_deleted_observer.deleted()); | 1845 EXPECT_FALSE(rvh_deleted_observer.deleted()); |
| 1847 } | 1846 } |
| 1848 } | 1847 } |
| 1849 | 1848 |
| 1850 } // namespace content | 1849 } // namespace content |
| OLD | NEW |