| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <stdint.h> |
| 6 |
| 5 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 6 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/macros.h" |
| 7 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| 11 #include "build/build_config.h" |
| 8 #include "content/browser/frame_host/cross_site_transferring_request.h" | 12 #include "content/browser/frame_host/cross_site_transferring_request.h" |
| 9 #include "content/browser/frame_host/interstitial_page_impl.h" | 13 #include "content/browser/frame_host/interstitial_page_impl.h" |
| 10 #include "content/browser/frame_host/navigation_entry_impl.h" | 14 #include "content/browser/frame_host/navigation_entry_impl.h" |
| 11 #include "content/browser/frame_host/render_frame_host_impl.h" | 15 #include "content/browser/frame_host/render_frame_host_impl.h" |
| 12 #include "content/browser/frame_host/render_frame_proxy_host.h" | 16 #include "content/browser/frame_host/render_frame_proxy_host.h" |
| 13 #include "content/browser/media/audio_stream_monitor.h" | 17 #include "content/browser/media/audio_stream_monitor.h" |
| 14 #include "content/browser/media/media_web_contents_observer.h" | 18 #include "content/browser/media/media_web_contents_observer.h" |
| 15 #include "content/browser/renderer_host/render_view_host_impl.h" | 19 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 16 #include "content/browser/site_instance_impl.h" | 20 #include "content/browser/site_instance_impl.h" |
| 17 #include "content/browser/webui/content_web_ui_controller_factory.h" | 21 #include "content/browser/webui/content_web_ui_controller_factory.h" |
| (...skipping 1465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1483 ui::PAGE_TRANSITION_TYPED); | 1487 ui::PAGE_TRANSITION_TYPED); |
| 1484 | 1488 |
| 1485 // Should have a page state here. | 1489 // Should have a page state here. |
| 1486 NavigationEntry* entry = controller().GetLastCommittedEntry(); | 1490 NavigationEntry* entry = controller().GetLastCommittedEntry(); |
| 1487 EXPECT_TRUE(entry->GetPageState().IsValid()); | 1491 EXPECT_TRUE(entry->GetPageState().IsValid()); |
| 1488 | 1492 |
| 1489 // The SiteInstance should be available for other navigations to use. | 1493 // The SiteInstance should be available for other navigations to use. |
| 1490 NavigationEntryImpl* entry_impl = | 1494 NavigationEntryImpl* entry_impl = |
| 1491 NavigationEntryImpl::FromNavigationEntry(entry); | 1495 NavigationEntryImpl::FromNavigationEntry(entry); |
| 1492 EXPECT_FALSE(entry_impl->site_instance()->HasSite()); | 1496 EXPECT_FALSE(entry_impl->site_instance()->HasSite()); |
| 1493 int32 site_instance_id = entry_impl->site_instance()->GetId(); | 1497 int32_t site_instance_id = entry_impl->site_instance()->GetId(); |
| 1494 | 1498 |
| 1495 // Navigating to a normal page should not cause a process swap. | 1499 // Navigating to a normal page should not cause a process swap. |
| 1496 const GURL new_url("http://www.google.com"); | 1500 const GURL new_url("http://www.google.com"); |
| 1497 controller().LoadURL(new_url, Referrer(), | 1501 controller().LoadURL(new_url, Referrer(), |
| 1498 ui::PAGE_TRANSITION_TYPED, std::string()); | 1502 ui::PAGE_TRANSITION_TYPED, std::string()); |
| 1499 entry = controller().GetPendingEntry(); | 1503 entry = controller().GetPendingEntry(); |
| 1500 EXPECT_FALSE(contents()->CrossProcessNavigationPending()); | 1504 EXPECT_FALSE(contents()->CrossProcessNavigationPending()); |
| 1501 EXPECT_EQ(orig_rfh, contents()->GetMainFrame()); | 1505 EXPECT_EQ(orig_rfh, contents()->GetMainFrame()); |
| 1502 orig_rfh->PrepareForCommit(); | 1506 orig_rfh->PrepareForCommit(); |
| 1503 contents()->TestDidNavigate(orig_rfh, 2, entry->GetUniqueID(), true, new_url, | 1507 contents()->TestDidNavigate(orig_rfh, 2, entry->GetUniqueID(), true, new_url, |
| (...skipping 1678 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3182 | 3186 |
| 3183 // Simulate the new current RenderFrameHost DidStopLoading. The WebContents | 3187 // Simulate the new current RenderFrameHost DidStopLoading. The WebContents |
| 3184 // should now have stopped loading. | 3188 // should now have stopped loading. |
| 3185 new_current_rfh->OnMessageReceived( | 3189 new_current_rfh->OnMessageReceived( |
| 3186 FrameHostMsg_DidStopLoading(new_current_rfh->GetRoutingID())); | 3190 FrameHostMsg_DidStopLoading(new_current_rfh->GetRoutingID())); |
| 3187 EXPECT_EQ(contents()->GetMainFrame(), new_current_rfh); | 3191 EXPECT_EQ(contents()->GetMainFrame(), new_current_rfh); |
| 3188 EXPECT_FALSE(contents()->IsLoading()); | 3192 EXPECT_FALSE(contents()->IsLoading()); |
| 3189 } | 3193 } |
| 3190 | 3194 |
| 3191 TEST_F(WebContentsImplTest, MediaPowerSaveBlocking) { | 3195 TEST_F(WebContentsImplTest, MediaPowerSaveBlocking) { |
| 3192 // PlayerIDs are actually pointers cast to int64, so verify that both negative | 3196 // PlayerIDs are actually pointers cast to int64_t, so verify that both |
| 3197 // negative |
| 3193 // and positive player ids don't blow up. | 3198 // and positive player ids don't blow up. |
| 3194 const int kPlayerAudioVideoId = 15; | 3199 const int kPlayerAudioVideoId = 15; |
| 3195 const int kPlayerAudioOnlyId = -15; | 3200 const int kPlayerAudioOnlyId = -15; |
| 3196 const int kPlayerVideoOnlyId = 30; | 3201 const int kPlayerVideoOnlyId = 30; |
| 3197 const int kPlayerRemoteId = -30; | 3202 const int kPlayerRemoteId = -30; |
| 3198 | 3203 |
| 3199 EXPECT_FALSE(has_audio_power_save_blocker()); | 3204 EXPECT_FALSE(has_audio_power_save_blocker()); |
| 3200 EXPECT_FALSE(has_video_power_save_blocker()); | 3205 EXPECT_FALSE(has_video_power_save_blocker()); |
| 3201 | 3206 |
| 3202 TestRenderFrameHost* rfh = contents()->GetMainFrame(); | 3207 TestRenderFrameHost* rfh = contents()->GetMainFrame(); |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3367 backend->AllowCertForHost(*cert, test_url.host(), 1); | 3372 backend->AllowCertForHost(*cert, test_url.host(), 1); |
| 3368 EXPECT_TRUE(backend->HasAllowException(test_url.host())); | 3373 EXPECT_TRUE(backend->HasAllowException(test_url.host())); |
| 3369 | 3374 |
| 3370 contents()->OnDidLoadResourceFromMemoryCache(test_url, "", "GET", "mime type", | 3375 contents()->OnDidLoadResourceFromMemoryCache(test_url, "", "GET", "mime type", |
| 3371 RESOURCE_TYPE_MAIN_FRAME); | 3376 RESOURCE_TYPE_MAIN_FRAME); |
| 3372 | 3377 |
| 3373 EXPECT_TRUE(backend->HasAllowException(test_url.host())); | 3378 EXPECT_TRUE(backend->HasAllowException(test_url.host())); |
| 3374 } | 3379 } |
| 3375 | 3380 |
| 3376 } // namespace content | 3381 } // namespace content |
| OLD | NEW |