Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(66)

Side by Side Diff: content/browser/frame_host/render_frame_host_manager_unittest.cc

Issue 688343003: Add some missing ENABLE_PLUGINS ifdefs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/command_line.h" 5 #include "base/command_line.h"
6 #include "base/files/file_path.h" 6 #include "base/files/file_path.h"
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "base/test/histogram_tester.h" 8 #include "base/test/histogram_tester.h"
9 #include "base/time/time.h" 9 #include "base/time/time.h"
10 #include "content/browser/frame_host/cross_site_transferring_request.h" 10 #include "content/browser/frame_host/cross_site_transferring_request.h"
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 203
204 // This observer is used to check whether IPC messages are being filtered for 204 // This observer is used to check whether IPC messages are being filtered for
205 // swapped out RenderFrameHost objects. It observes the plugin crash and favicon 205 // swapped out RenderFrameHost objects. It observes the plugin crash and favicon
206 // update events, which the FilterMessagesWhileSwappedOut test simulates being 206 // update events, which the FilterMessagesWhileSwappedOut test simulates being
207 // sent. The test is successful if the event is not observed. 207 // sent. The test is successful if the event is not observed.
208 // See http://crbug.com/351815 208 // See http://crbug.com/351815
209 class PluginFaviconMessageObserver : public WebContentsObserver { 209 class PluginFaviconMessageObserver : public WebContentsObserver {
210 public: 210 public:
211 PluginFaviconMessageObserver(WebContents* web_contents) 211 PluginFaviconMessageObserver(WebContents* web_contents)
212 : WebContentsObserver(web_contents), 212 : WebContentsObserver(web_contents),
213 #if defined(ENABLE_PLUGINS)
Lei Zhang 2014/10/30 21:48:54 I think you can get away without the ifdefs in Plu
tommycli 2014/10/30 22:37:21 Done.
213 plugin_crashed_(false), 214 plugin_crashed_(false),
214 favicon_received_(false) { } 215 #endif
216 favicon_received_(false) {
217 }
215 218
219 #if defined(ENABLE_PLUGINS)
216 void PluginCrashed(const base::FilePath& plugin_path, 220 void PluginCrashed(const base::FilePath& plugin_path,
217 base::ProcessId plugin_pid) override { 221 base::ProcessId plugin_pid) override {
218 plugin_crashed_ = true; 222 plugin_crashed_ = true;
219 } 223 }
220 224
225 bool plugin_crashed() {
226 return plugin_crashed_;
227 }
228 #endif
229
221 void DidUpdateFaviconURL(const std::vector<FaviconURL>& candidates) override { 230 void DidUpdateFaviconURL(const std::vector<FaviconURL>& candidates) override {
222 favicon_received_ = true; 231 favicon_received_ = true;
223 } 232 }
224 233
225 bool plugin_crashed() {
226 return plugin_crashed_;
227 }
228
229 bool favicon_received() { 234 bool favicon_received() {
230 return favicon_received_; 235 return favicon_received_;
231 } 236 }
232 237
233 private: 238 private:
239 #if defined(ENABLE_PLUGINS)
234 bool plugin_crashed_; 240 bool plugin_crashed_;
241 #endif
235 bool favicon_received_; 242 bool favicon_received_;
236 243
237 DISALLOW_COPY_AND_ASSIGN(PluginFaviconMessageObserver); 244 DISALLOW_COPY_AND_ASSIGN(PluginFaviconMessageObserver);
238 }; 245 };
239 246
240 // Ensures that RenderFrameDeleted and RenderFrameCreated are called in a 247 // Ensures that RenderFrameDeleted and RenderFrameCreated are called in a
241 // consistent manner. 248 // consistent manner.
242 class FrameLifetimeConsistencyChecker : public WebContentsObserver { 249 class FrameLifetimeConsistencyChecker : public WebContentsObserver {
243 public: 250 public:
244 explicit FrameLifetimeConsistencyChecker(WebContentsImpl* web_contents) 251 explicit FrameLifetimeConsistencyChecker(WebContentsImpl* web_contents)
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 EXPECT_TRUE(ntp_rfh->is_swapped_out()); 550 EXPECT_TRUE(ntp_rfh->is_swapped_out());
544 { 551 {
545 PluginFaviconMessageObserver observer(contents()); 552 PluginFaviconMessageObserver observer(contents());
546 EXPECT_TRUE( 553 EXPECT_TRUE(
547 ntp_rfh->GetRenderViewHost()->OnMessageReceived( 554 ntp_rfh->GetRenderViewHost()->OnMessageReceived(
548 ViewHostMsg_UpdateFaviconURL( 555 ViewHostMsg_UpdateFaviconURL(
549 dest_rfh->GetRenderViewHost()->GetRoutingID(), icons))); 556 dest_rfh->GetRenderViewHost()->GetRoutingID(), icons)));
550 EXPECT_FALSE(observer.favicon_received()); 557 EXPECT_FALSE(observer.favicon_received());
551 } 558 }
552 559
560 #if defined(ENABLE_PLUGINS)
553 // The same logic should apply to RenderFrameHosts as well and routing through 561 // The same logic should apply to RenderFrameHosts as well and routing through
554 // swapped out RFH shouldn't be allowed. Use a PluginCrashObserver to check 562 // swapped out RFH shouldn't be allowed. Use a PluginCrashObserver to check
555 // if the IPC message is allowed through or not. 563 // if the IPC message is allowed through or not.
556 { 564 {
557 PluginFaviconMessageObserver observer(contents()); 565 PluginFaviconMessageObserver observer(contents());
558 EXPECT_TRUE(ntp_rfh->OnMessageReceived( 566 EXPECT_TRUE(ntp_rfh->OnMessageReceived(
559 FrameHostMsg_PluginCrashed( 567 FrameHostMsg_PluginCrashed(
560 ntp_rfh->GetRoutingID(), base::FilePath(), 0))); 568 ntp_rfh->GetRoutingID(), base::FilePath(), 0)));
561 EXPECT_FALSE(observer.plugin_crashed()); 569 EXPECT_FALSE(observer.plugin_crashed());
562 } 570 }
571 #endif
563 572
564 // We cannot filter out synchronous IPC messages, because the renderer would 573 // We cannot filter out synchronous IPC messages, because the renderer would
565 // be left waiting for a reply. We pick RunBeforeUnloadConfirm as an example 574 // be left waiting for a reply. We pick RunBeforeUnloadConfirm as an example
566 // that can run easily within a unit test, and that needs to receive a reply 575 // that can run easily within a unit test, and that needs to receive a reply
567 // without showing an actual dialog. 576 // without showing an actual dialog.
568 MockRenderProcessHost* ntp_process_host = 577 MockRenderProcessHost* ntp_process_host =
569 static_cast<MockRenderProcessHost*>(ntp_rfh->GetProcess()); 578 static_cast<MockRenderProcessHost*>(ntp_rfh->GetProcess());
570 ntp_process_host->sink().ClearMessages(); 579 ntp_process_host->sink().ClearMessages();
571 const base::string16 msg = base::ASCIIToUTF16("Message"); 580 const base::string16 msg = base::ASCIIToUTF16("Message");
572 bool result = false; 581 bool result = false;
(...skipping 1223 matching lines...) Expand 10 before | Expand all | Expand 10 after
1796 pending_rfh->GetSiteInstance()->increment_active_frame_count(); 1805 pending_rfh->GetSiteInstance()->increment_active_frame_count();
1797 1806
1798 contents()->GetMainFrame()->OnMessageReceived( 1807 contents()->GetMainFrame()->OnMessageReceived(
1799 FrameHostMsg_BeforeUnload_ACK(0, false, now, now)); 1808 FrameHostMsg_BeforeUnload_ACK(0, false, now, now));
1800 EXPECT_FALSE(contents()->cross_navigation_pending()); 1809 EXPECT_FALSE(contents()->cross_navigation_pending());
1801 EXPECT_FALSE(rfh_deleted_observer.deleted()); 1810 EXPECT_FALSE(rfh_deleted_observer.deleted());
1802 } 1811 }
1803 } 1812 }
1804 1813
1805 } // namespace content 1814 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698