| 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 "base/logging.h" | 5 #include "base/logging.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/interstitial_page_impl.h" | 8 #include "content/browser/frame_host/interstitial_page_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/media/audio_stream_monitor.h" | 10 #include "content/browser/media/audio_stream_monitor.h" |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 } | 152 } |
| 153 | 153 |
| 154 void TestDomOperationResponse(const std::string& json_string) { | 154 void TestDomOperationResponse(const std::string& json_string) { |
| 155 if (enabled()) | 155 if (enabled()) |
| 156 CommandReceived(); | 156 CommandReceived(); |
| 157 } | 157 } |
| 158 | 158 |
| 159 void TestDidNavigate(int page_id, const GURL& url) { | 159 void TestDidNavigate(int page_id, const GURL& url) { |
| 160 FrameHostMsg_DidCommitProvisionalLoad_Params params; | 160 FrameHostMsg_DidCommitProvisionalLoad_Params params; |
| 161 InitNavigateParams(¶ms, page_id, url, ui::PAGE_TRANSITION_TYPED); | 161 InitNavigateParams(¶ms, page_id, url, ui::PAGE_TRANSITION_TYPED); |
| 162 DidNavigate(GetRenderViewHostForTesting(), params); | 162 DidNavigate(GetMainFrame()->GetRenderViewHost(), params); |
| 163 } | 163 } |
| 164 | 164 |
| 165 void TestRenderViewTerminated(base::TerminationStatus status, | 165 void TestRenderViewTerminated(base::TerminationStatus status, |
| 166 int error_code) { | 166 int error_code) { |
| 167 RenderViewTerminated(GetRenderViewHostForTesting(), status, error_code); | 167 RenderViewTerminated(GetMainFrame()->GetRenderViewHost(), status, |
| 168 error_code); |
| 168 } | 169 } |
| 169 | 170 |
| 170 bool is_showing() const { | 171 bool is_showing() const { |
| 171 return static_cast<TestRenderWidgetHostView*>( | 172 return static_cast<TestRenderWidgetHostView*>( |
| 172 GetRenderViewHostForTesting()->GetView())->is_showing(); | 173 GetMainFrame()->GetRenderViewHost()->GetView())->is_showing(); |
| 173 } | 174 } |
| 174 | 175 |
| 175 void ClearStates() { | 176 void ClearStates() { |
| 176 state_ = NULL; | 177 state_ = NULL; |
| 177 deleted_ = NULL; | 178 deleted_ = NULL; |
| 178 delegate_ = NULL; | 179 delegate_ = NULL; |
| 179 } | 180 } |
| 180 | 181 |
| 181 void CommandReceived() { | 182 void CommandReceived() { |
| 182 command_received_count_++; | 183 command_received_count_++; |
| (...skipping 1714 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1897 TestInterstitialPage::InterstitialState state = | 1898 TestInterstitialPage::InterstitialState state = |
| 1898 TestInterstitialPage::INVALID; | 1899 TestInterstitialPage::INVALID; |
| 1899 bool deleted = false; | 1900 bool deleted = false; |
| 1900 GURL url("http://interstitial"); | 1901 GURL url("http://interstitial"); |
| 1901 TestInterstitialPage* interstitial = | 1902 TestInterstitialPage* interstitial = |
| 1902 new TestInterstitialPage(contents(), true, url, &state, &deleted); | 1903 new TestInterstitialPage(contents(), true, url, &state, &deleted); |
| 1903 TestInterstitialPageStateGuard state_guard(interstitial); | 1904 TestInterstitialPageStateGuard state_guard(interstitial); |
| 1904 interstitial->Show(); | 1905 interstitial->Show(); |
| 1905 interstitial->TestDidNavigate(1, url); | 1906 interstitial->TestDidNavigate(1, url); |
| 1906 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( | 1907 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( |
| 1907 interstitial->GetRenderViewHostForTesting()); | 1908 interstitial->GetMainFrame()->GetRenderViewHost()); |
| 1908 | 1909 |
| 1909 // Now close the contents. | 1910 // Now close the contents. |
| 1910 DeleteContents(); | 1911 DeleteContents(); |
| 1911 EXPECT_EQ(TestInterstitialPage::CANCELED, state); | 1912 EXPECT_EQ(TestInterstitialPage::CANCELED, state); |
| 1912 | 1913 |
| 1913 // Before the interstitial has a chance to process its shutdown task, | 1914 // Before the interstitial has a chance to process its shutdown task, |
| 1914 // simulate quitting the browser. This goes through all processes and | 1915 // simulate quitting the browser. This goes through all processes and |
| 1915 // tells them to destruct. | 1916 // tells them to destruct. |
| 1916 rvh->OnMessageReceived( | 1917 rvh->OnMessageReceived( |
| 1917 ViewHostMsg_RenderProcessGone(0, 0, 0)); | 1918 ViewHostMsg_RenderProcessGone(0, 0, 0)); |
| (...skipping 867 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2785 | 2786 |
| 2786 // Destroy the remote player. No power save blockers should remain. | 2787 // Destroy the remote player. No power save blockers should remain. |
| 2787 rfh->OnMessageReceived( | 2788 rfh->OnMessageReceived( |
| 2788 FrameHostMsg_MediaPausedNotification(0, kPlayerRemoteId)); | 2789 FrameHostMsg_MediaPausedNotification(0, kPlayerRemoteId)); |
| 2789 EXPECT_FALSE(contents()->has_video_power_save_blocker_for_testing()); | 2790 EXPECT_FALSE(contents()->has_video_power_save_blocker_for_testing()); |
| 2790 EXPECT_FALSE(contents()->has_audio_power_save_blocker_for_testing()); | 2791 EXPECT_FALSE(contents()->has_audio_power_save_blocker_for_testing()); |
| 2791 } | 2792 } |
| 2792 #endif | 2793 #endif |
| 2793 | 2794 |
| 2794 } // namespace content | 2795 } // namespace content |
| OLD | NEW |