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

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

Issue 12315023: Merge 180159 (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1364/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/chrome_plugin_service_filter.h"
9 #include "chrome/browser/content_settings/cookie_settings.h" 10 #include "chrome/browser/content_settings/cookie_settings.h"
10 #include "chrome/browser/content_settings/host_content_settings_map.h" 11 #include "chrome/browser/content_settings/host_content_settings_map.h"
11 #include "chrome/browser/content_settings/tab_specific_content_settings.h" 12 #include "chrome/browser/content_settings/tab_specific_content_settings.h"
12 #include "chrome/browser/net/url_request_mock_util.h" 13 #include "chrome/browser/net/url_request_mock_util.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/browser_tabstrip.h" 17 #include "chrome/browser/ui/browser_tabstrip.h"
17 #include "chrome/browser/ui/tabs/tab_strip_model.h" 18 #include "chrome/browser/ui/tabs/tab_strip_model.h"
18 #include "chrome/common/chrome_notification_types.h" 19 #include "chrome/common/chrome_notification_types.h"
19 #include "chrome/common/render_messages.h" 20 #include "chrome/common/render_messages.h"
20 #include "chrome/test/base/in_process_browser_test.h" 21 #include "chrome/test/base/in_process_browser_test.h"
21 #include "chrome/test/base/ui_test_utils.h" 22 #include "chrome/test/base/ui_test_utils.h"
22 #include "content/public/browser/browser_thread.h" 23 #include "content/public/browser/browser_thread.h"
24 #include "content/public/browser/plugin_service.h"
25 #include "content/public/browser/render_process_host.h"
23 #include "content/public/browser/render_view_host.h" 26 #include "content/public/browser/render_view_host.h"
24 #include "content/public/browser/web_contents.h" 27 #include "content/public/browser/web_contents.h"
25 #include "content/public/common/content_switches.h" 28 #include "content/public/common/content_switches.h"
26 #include "content/public/test/browser_test_utils.h" 29 #include "content/public/test/browser_test_utils.h"
27 #include "content/public/test/test_utils.h" 30 #include "content/public/test/test_utils.h"
28 #include "content/test/net/url_request_mock_http_job.h" 31 #include "content/test/net/url_request_mock_http_job.h"
29 #include "net/test/test_server.h" 32 #include "net/test/test_server.h"
30 33
31 #if defined(OS_MACOSX) 34 #if defined(OS_MACOSX)
32 #include "base/mac/scoped_nsautorelease_pool.h" 35 #include "base/mac/scoped_nsautorelease_pool.h"
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 GURL url = ui_test_utils::GetTestUrl( 307 GURL url = ui_test_utils::GetTestUrl(
305 FilePath(), FilePath().AppendASCII("clicktoplay.html")); 308 FilePath(), FilePath().AppendASCII("clicktoplay.html"));
306 ui_test_utils::NavigateToURL(browser(), url); 309 ui_test_utils::NavigateToURL(browser(), url);
307 310
308 string16 expected_title(ASCIIToUTF16("OK")); 311 string16 expected_title(ASCIIToUTF16("OK"));
309 content::TitleWatcher title_watcher( 312 content::TitleWatcher title_watcher(
310 chrome::GetActiveWebContents(browser()), expected_title); 313 chrome::GetActiveWebContents(browser()), expected_title);
311 314
312 content::RenderViewHost* host = 315 content::RenderViewHost* host =
313 chrome::GetActiveWebContents(browser())->GetRenderViewHost(); 316 chrome::GetActiveWebContents(browser())->GetRenderViewHost();
317 ChromePluginServiceFilter* filter = ChromePluginServiceFilter::GetInstance();
318 int process_id = host->GetProcess()->GetID();
319 FilePath path(FILE_PATH_LITERAL("blah"));
320 EXPECT_FALSE(filter->CanLoadPlugin(process_id, path));
321 filter->AuthorizeAllPlugins(process_id);
322 EXPECT_TRUE(filter->CanLoadPlugin(process_id, path));
314 host->Send(new ChromeViewMsg_LoadBlockedPlugins( 323 host->Send(new ChromeViewMsg_LoadBlockedPlugins(
315 host->GetRoutingID(), std::string())); 324 host->GetRoutingID(), std::string()));
316 325
317 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); 326 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle());
318 } 327 }
319 328
320 // Verify that plugins can be allowed on a domain by adding an exception 329 // Verify that plugins can be allowed on a domain by adding an exception
321 IN_PROC_BROWSER_TEST_F(ClickToPlayPluginTest, AllowException) { 330 IN_PROC_BROWSER_TEST_F(ClickToPlayPluginTest, AllowException) {
322 GURL url = ui_test_utils::GetTestUrl( 331 GURL url = ui_test_utils::GetTestUrl(
323 FilePath(), FilePath().AppendASCII("clicktoplay.html")); 332 FilePath(), FilePath().AppendASCII("clicktoplay.html"));
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 GURL url = ui_test_utils::GetTestUrl( 373 GURL url = ui_test_utils::GetTestUrl(
365 FilePath(), FilePath().AppendASCII("load_all_blocked_plugins.html")); 374 FilePath(), FilePath().AppendASCII("load_all_blocked_plugins.html"));
366 ui_test_utils::NavigateToURL(browser(), url); 375 ui_test_utils::NavigateToURL(browser(), url);
367 376
368 string16 expected_title1(ASCIIToUTF16("1")); 377 string16 expected_title1(ASCIIToUTF16("1"));
369 content::TitleWatcher title_watcher1( 378 content::TitleWatcher title_watcher1(
370 chrome::GetActiveWebContents(browser()), expected_title1); 379 chrome::GetActiveWebContents(browser()), expected_title1);
371 380
372 content::RenderViewHost* host = 381 content::RenderViewHost* host =
373 chrome::GetActiveWebContents(browser())->GetRenderViewHost(); 382 chrome::GetActiveWebContents(browser())->GetRenderViewHost();
383 ChromePluginServiceFilter::GetInstance()->AuthorizeAllPlugins(
384 host->GetProcess()->GetID());
374 host->Send(new ChromeViewMsg_LoadBlockedPlugins( 385 host->Send(new ChromeViewMsg_LoadBlockedPlugins(
375 host->GetRoutingID(), std::string())); 386 host->GetRoutingID(), std::string()));
376 EXPECT_EQ(expected_title1, title_watcher1.WaitAndGetTitle()); 387 EXPECT_EQ(expected_title1, title_watcher1.WaitAndGetTitle());
377 388
378 string16 expected_title2(ASCIIToUTF16("2")); 389 string16 expected_title2(ASCIIToUTF16("2"));
379 content::TitleWatcher title_watcher2( 390 content::TitleWatcher title_watcher2(
380 chrome::GetActiveWebContents(browser()), expected_title2); 391 chrome::GetActiveWebContents(browser()), expected_title2);
381 392
382 ASSERT_TRUE(content::ExecuteJavaScript( 393 ASSERT_TRUE(content::ExecuteJavaScript(
383 chrome::GetActiveWebContents(browser())->GetRenderViewHost(), 394 chrome::GetActiveWebContents(browser())->GetRenderViewHost(),
(...skipping 14 matching lines...) Expand all
398 ASSERT_TRUE(content::ExecuteJavaScript( 409 ASSERT_TRUE(content::ExecuteJavaScript(
399 chrome::GetActiveWebContents(browser())->GetRenderViewHost(), 410 chrome::GetActiveWebContents(browser())->GetRenderViewHost(),
400 L"", L"CallOnStartup = function() { document.title = \"OK\"; }")); 411 L"", L"CallOnStartup = function() { document.title = \"OK\"; }"));
401 412
402 string16 expected_title(ASCIIToUTF16("OK")); 413 string16 expected_title(ASCIIToUTF16("OK"));
403 content::TitleWatcher title_watcher( 414 content::TitleWatcher title_watcher(
404 chrome::GetActiveWebContents(browser()), expected_title); 415 chrome::GetActiveWebContents(browser()), expected_title);
405 416
406 content::RenderViewHost* host = 417 content::RenderViewHost* host =
407 chrome::GetActiveWebContents(browser())->GetRenderViewHost(); 418 chrome::GetActiveWebContents(browser())->GetRenderViewHost();
419 ChromePluginServiceFilter::GetInstance()->AuthorizeAllPlugins(
420 host->GetProcess()->GetID());
408 host->Send(new ChromeViewMsg_LoadBlockedPlugins( 421 host->Send(new ChromeViewMsg_LoadBlockedPlugins(
409 host->GetRoutingID(), std::string())); 422 host->GetRoutingID(), std::string()));
410 423
411 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); 424 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle());
412 } 425 }
413 426
414 IN_PROC_BROWSER_TEST_F(ClickToPlayPluginTest, DeleteSelfAtLoad) { 427 IN_PROC_BROWSER_TEST_F(ClickToPlayPluginTest, DeleteSelfAtLoad) {
415 browser()->profile()->GetHostContentSettingsMap()->SetDefaultContentSetting( 428 browser()->profile()->GetHostContentSettingsMap()->SetDefaultContentSetting(
416 CONTENT_SETTINGS_TYPE_PLUGINS, CONTENT_SETTING_BLOCK); 429 CONTENT_SETTINGS_TYPE_PLUGINS, CONTENT_SETTING_BLOCK);
417 430
418 GURL url = ui_test_utils::GetTestUrl( 431 GURL url = ui_test_utils::GetTestUrl(
419 FilePath(), FilePath().AppendASCII("plugin_delete_self_at_load.html")); 432 FilePath(), FilePath().AppendASCII("plugin_delete_self_at_load.html"));
420 ui_test_utils::NavigateToURL(browser(), url); 433 ui_test_utils::NavigateToURL(browser(), url);
421 434
422 string16 expected_title(ASCIIToUTF16("OK")); 435 string16 expected_title(ASCIIToUTF16("OK"));
423 content::TitleWatcher title_watcher( 436 content::TitleWatcher title_watcher(
424 chrome::GetActiveWebContents(browser()), expected_title); 437 chrome::GetActiveWebContents(browser()), expected_title);
425 438
426 content::RenderViewHost* host = 439 content::RenderViewHost* host =
427 chrome::GetActiveWebContents(browser())->GetRenderViewHost(); 440 chrome::GetActiveWebContents(browser())->GetRenderViewHost();
441 ChromePluginServiceFilter::GetInstance()->AuthorizeAllPlugins(
442 host->GetProcess()->GetID());
428 host->Send(new ChromeViewMsg_LoadBlockedPlugins( 443 host->Send(new ChromeViewMsg_LoadBlockedPlugins(
429 host->GetRoutingID(), std::string())); 444 host->GetRoutingID(), std::string()));
430 445
431 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); 446 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle());
432 } 447 }
433 448
434 #endif // !defined(USE_AURA) 449 #endif // !defined(USE_AURA)
OLDNEW
« no previous file with comments | « chrome/browser/chrome_plugin_service_filter.cc ('k') | chrome/browser/plugins/plugin_infobar_delegates.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698