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

Side by Side Diff: chrome/browser/content_settings/content_settings_browsertest.cc

Issue 12086077: Only permit plug-in loads in the browser if the plug-in isn't blocked or the (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 10 months 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 | Annotate | Revision Log
OLDNEW
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/command_line.h" 5 #include "base/command_line.h"
6 #include "base/path_service.h" 6 #include "base/path_service.h"
7 #include "base/stringprintf.h" 7 #include "base/stringprintf.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/content_settings/cookie_settings.h" 9 #include "chrome/browser/content_settings/cookie_settings.h"
10 #include "chrome/browser/content_settings/host_content_settings_map.h" 10 #include "chrome/browser/content_settings/host_content_settings_map.h"
11 #include "chrome/browser/content_settings/tab_specific_content_settings.h" 11 #include "chrome/browser/content_settings/tab_specific_content_settings.h"
12 #include "chrome/browser/net/url_request_mock_util.h" 12 #include "chrome/browser/net/url_request_mock_util.h"
13 #include "chrome/browser/plugins/chrome_plugin_service_filter.h"
13 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/browser/ui/browser.h" 15 #include "chrome/browser/ui/browser.h"
15 #include "chrome/browser/ui/browser_commands.h" 16 #include "chrome/browser/ui/browser_commands.h"
16 #include "chrome/browser/ui/tabs/tab_strip_model.h" 17 #include "chrome/browser/ui/tabs/tab_strip_model.h"
17 #include "chrome/common/chrome_notification_types.h" 18 #include "chrome/common/chrome_notification_types.h"
18 #include "chrome/common/render_messages.h" 19 #include "chrome/common/render_messages.h"
19 #include "chrome/test/base/in_process_browser_test.h" 20 #include "chrome/test/base/in_process_browser_test.h"
20 #include "chrome/test/base/ui_test_utils.h" 21 #include "chrome/test/base/ui_test_utils.h"
21 #include "content/public/browser/browser_thread.h" 22 #include "content/public/browser/browser_thread.h"
23 #include "content/public/browser/render_process_host.h"
22 #include "content/public/browser/render_view_host.h" 24 #include "content/public/browser/render_view_host.h"
23 #include "content/public/browser/web_contents.h" 25 #include "content/public/browser/web_contents.h"
24 #include "content/public/common/content_switches.h" 26 #include "content/public/common/content_switches.h"
25 #include "content/public/test/browser_test_utils.h" 27 #include "content/public/test/browser_test_utils.h"
26 #include "content/public/test/test_utils.h" 28 #include "content/public/test/test_utils.h"
27 #include "content/test/net/url_request_mock_http_job.h" 29 #include "content/test/net/url_request_mock_http_job.h"
28 #include "net/test/test_server.h" 30 #include "net/test/test_server.h"
29 31
30 #if defined(OS_MACOSX) 32 #if defined(OS_MACOSX)
31 #include "base/mac/scoped_nsautorelease_pool.h" 33 #include "base/mac/scoped_nsautorelease_pool.h"
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 GURL url = ui_test_utils::GetTestUrl( 308 GURL url = ui_test_utils::GetTestUrl(
307 FilePath(), FilePath().AppendASCII("clicktoplay.html")); 309 FilePath(), FilePath().AppendASCII("clicktoplay.html"));
308 ui_test_utils::NavigateToURL(browser(), url); 310 ui_test_utils::NavigateToURL(browser(), url);
309 311
310 string16 expected_title(ASCIIToUTF16("OK")); 312 string16 expected_title(ASCIIToUTF16("OK"));
311 content::TitleWatcher title_watcher( 313 content::TitleWatcher title_watcher(
312 browser()->tab_strip_model()->GetActiveWebContents(), expected_title); 314 browser()->tab_strip_model()->GetActiveWebContents(), expected_title);
313 315
314 content::RenderViewHost* host = 316 content::RenderViewHost* host =
315 browser()->tab_strip_model()->GetActiveWebContents()->GetRenderViewHost(); 317 browser()->tab_strip_model()->GetActiveWebContents()->GetRenderViewHost();
318 ChromePluginServiceFilter::GetInstance()->AuthorizeAllPlugins(
319 host->GetProcess()->GetID());
316 host->Send(new ChromeViewMsg_LoadBlockedPlugins( 320 host->Send(new ChromeViewMsg_LoadBlockedPlugins(
317 host->GetRoutingID(), std::string())); 321 host->GetRoutingID(), std::string()));
318 322
319 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); 323 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle());
320 } 324 }
321 325
322 // Verify that plugins can be allowed on a domain by adding an exception 326 // Verify that plugins can be allowed on a domain by adding an exception
323 IN_PROC_BROWSER_TEST_F(ClickToPlayPluginTest, AllowException) { 327 IN_PROC_BROWSER_TEST_F(ClickToPlayPluginTest, AllowException) {
324 GURL url = ui_test_utils::GetTestUrl( 328 GURL url = ui_test_utils::GetTestUrl(
325 FilePath(), FilePath().AppendASCII("clicktoplay.html")); 329 FilePath(), FilePath().AppendASCII("clicktoplay.html"));
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 GURL url = ui_test_utils::GetTestUrl( 370 GURL url = ui_test_utils::GetTestUrl(
367 FilePath(), FilePath().AppendASCII("load_all_blocked_plugins.html")); 371 FilePath(), FilePath().AppendASCII("load_all_blocked_plugins.html"));
368 ui_test_utils::NavigateToURL(browser(), url); 372 ui_test_utils::NavigateToURL(browser(), url);
369 373
370 string16 expected_title1(ASCIIToUTF16("1")); 374 string16 expected_title1(ASCIIToUTF16("1"));
371 content::TitleWatcher title_watcher1( 375 content::TitleWatcher title_watcher1(
372 browser()->tab_strip_model()->GetActiveWebContents(), expected_title1); 376 browser()->tab_strip_model()->GetActiveWebContents(), expected_title1);
373 377
374 content::RenderViewHost* host = 378 content::RenderViewHost* host =
375 browser()->tab_strip_model()->GetActiveWebContents()->GetRenderViewHost(); 379 browser()->tab_strip_model()->GetActiveWebContents()->GetRenderViewHost();
380 ChromePluginServiceFilter::GetInstance()->AuthorizeAllPlugins(
381 host->GetProcess()->GetID());
376 host->Send(new ChromeViewMsg_LoadBlockedPlugins( 382 host->Send(new ChromeViewMsg_LoadBlockedPlugins(
377 host->GetRoutingID(), std::string())); 383 host->GetRoutingID(), std::string()));
378 EXPECT_EQ(expected_title1, title_watcher1.WaitAndGetTitle()); 384 EXPECT_EQ(expected_title1, title_watcher1.WaitAndGetTitle());
379 385
380 string16 expected_title2(ASCIIToUTF16("2")); 386 string16 expected_title2(ASCIIToUTF16("2"));
381 content::TitleWatcher title_watcher2( 387 content::TitleWatcher title_watcher2(
382 browser()->tab_strip_model()->GetActiveWebContents(), expected_title2); 388 browser()->tab_strip_model()->GetActiveWebContents(), expected_title2);
383 389
384 ASSERT_TRUE(content::ExecuteScript( 390 ASSERT_TRUE(content::ExecuteScript(
385 browser()->tab_strip_model()->GetActiveWebContents(), "window.inject()")); 391 browser()->tab_strip_model()->GetActiveWebContents(), "window.inject()"));
(...skipping 13 matching lines...) Expand all
399 ASSERT_TRUE(content::ExecuteScript( 405 ASSERT_TRUE(content::ExecuteScript(
400 browser()->tab_strip_model()->GetActiveWebContents(), 406 browser()->tab_strip_model()->GetActiveWebContents(),
401 "CallOnStartup = function() { document.title = \"OK\"; }")); 407 "CallOnStartup = function() { document.title = \"OK\"; }"));
402 408
403 string16 expected_title(ASCIIToUTF16("OK")); 409 string16 expected_title(ASCIIToUTF16("OK"));
404 content::TitleWatcher title_watcher( 410 content::TitleWatcher title_watcher(
405 browser()->tab_strip_model()->GetActiveWebContents(), expected_title); 411 browser()->tab_strip_model()->GetActiveWebContents(), expected_title);
406 412
407 content::RenderViewHost* host = 413 content::RenderViewHost* host =
408 browser()->tab_strip_model()->GetActiveWebContents()->GetRenderViewHost(); 414 browser()->tab_strip_model()->GetActiveWebContents()->GetRenderViewHost();
415 ChromePluginServiceFilter::GetInstance()->AuthorizeAllPlugins(
416 host->GetProcess()->GetID());
409 host->Send(new ChromeViewMsg_LoadBlockedPlugins( 417 host->Send(new ChromeViewMsg_LoadBlockedPlugins(
410 host->GetRoutingID(), std::string())); 418 host->GetRoutingID(), std::string()));
411 419
412 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); 420 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle());
413 } 421 }
414 422
415 IN_PROC_BROWSER_TEST_F(ClickToPlayPluginTest, DeleteSelfAtLoad) { 423 IN_PROC_BROWSER_TEST_F(ClickToPlayPluginTest, DeleteSelfAtLoad) {
416 browser()->profile()->GetHostContentSettingsMap()->SetDefaultContentSetting( 424 browser()->profile()->GetHostContentSettingsMap()->SetDefaultContentSetting(
417 CONTENT_SETTINGS_TYPE_PLUGINS, CONTENT_SETTING_BLOCK); 425 CONTENT_SETTINGS_TYPE_PLUGINS, CONTENT_SETTING_BLOCK);
418 426
419 GURL url = ui_test_utils::GetTestUrl( 427 GURL url = ui_test_utils::GetTestUrl(
420 FilePath(), FilePath().AppendASCII("plugin_delete_self_at_load.html")); 428 FilePath(), FilePath().AppendASCII("plugin_delete_self_at_load.html"));
421 ui_test_utils::NavigateToURL(browser(), url); 429 ui_test_utils::NavigateToURL(browser(), url);
422 430
423 string16 expected_title(ASCIIToUTF16("OK")); 431 string16 expected_title(ASCIIToUTF16("OK"));
424 content::TitleWatcher title_watcher( 432 content::TitleWatcher title_watcher(
425 browser()->tab_strip_model()->GetActiveWebContents(), expected_title); 433 browser()->tab_strip_model()->GetActiveWebContents(), expected_title);
426 434
427 content::RenderViewHost* host = 435 content::RenderViewHost* host =
428 browser()->tab_strip_model()->GetActiveWebContents()->GetRenderViewHost(); 436 browser()->tab_strip_model()->GetActiveWebContents()->GetRenderViewHost();
437 ChromePluginServiceFilter::GetInstance()->AuthorizeAllPlugins(
438 host->GetProcess()->GetID());
429 host->Send(new ChromeViewMsg_LoadBlockedPlugins( 439 host->Send(new ChromeViewMsg_LoadBlockedPlugins(
430 host->GetRoutingID(), std::string())); 440 host->GetRoutingID(), std::string()));
431 441
432 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); 442 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle());
433 } 443 }
434 444
435 #endif // !defined(USE_AURA) 445 #endif // !defined(USE_AURA)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698