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/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/plugin_service.h" |
| 24 #include "content/public/browser/render_process_host.h" |
22 #include "content/public/browser/render_view_host.h" | 25 #include "content/public/browser/render_view_host.h" |
23 #include "content/public/browser/web_contents.h" | 26 #include "content/public/browser/web_contents.h" |
24 #include "content/public/common/content_switches.h" | 27 #include "content/public/common/content_switches.h" |
25 #include "content/public/test/browser_test_utils.h" | 28 #include "content/public/test/browser_test_utils.h" |
26 #include "content/public/test/test_utils.h" | 29 #include "content/public/test/test_utils.h" |
27 #include "content/test/net/url_request_mock_http_job.h" | 30 #include "content/test/net/url_request_mock_http_job.h" |
28 #include "net/test/test_server.h" | 31 #include "net/test/test_server.h" |
29 | 32 |
30 #if defined(OS_MACOSX) | 33 #if defined(OS_MACOSX) |
31 #include "base/mac/scoped_nsautorelease_pool.h" | 34 #include "base/mac/scoped_nsautorelease_pool.h" |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 GURL url = ui_test_utils::GetTestUrl( | 309 GURL url = ui_test_utils::GetTestUrl( |
307 FilePath(), FilePath().AppendASCII("clicktoplay.html")); | 310 FilePath(), FilePath().AppendASCII("clicktoplay.html")); |
308 ui_test_utils::NavigateToURL(browser(), url); | 311 ui_test_utils::NavigateToURL(browser(), url); |
309 | 312 |
310 string16 expected_title(ASCIIToUTF16("OK")); | 313 string16 expected_title(ASCIIToUTF16("OK")); |
311 content::TitleWatcher title_watcher( | 314 content::TitleWatcher title_watcher( |
312 browser()->tab_strip_model()->GetActiveWebContents(), expected_title); | 315 browser()->tab_strip_model()->GetActiveWebContents(), expected_title); |
313 | 316 |
314 content::RenderViewHost* host = | 317 content::RenderViewHost* host = |
315 browser()->tab_strip_model()->GetActiveWebContents()->GetRenderViewHost(); | 318 browser()->tab_strip_model()->GetActiveWebContents()->GetRenderViewHost(); |
| 319 ChromePluginServiceFilter* filter = ChromePluginServiceFilter::GetInstance(); |
| 320 int process_id = host->GetProcess()->GetID(); |
| 321 FilePath path(FILE_PATH_LITERAL("blah")); |
| 322 EXPECT_FALSE(filter->CanLoadPlugin(process_id, path)); |
| 323 filter->AuthorizeAllPlugins(process_id); |
| 324 EXPECT_TRUE(filter->CanLoadPlugin(process_id, path)); |
316 host->Send(new ChromeViewMsg_LoadBlockedPlugins( | 325 host->Send(new ChromeViewMsg_LoadBlockedPlugins( |
317 host->GetRoutingID(), std::string())); | 326 host->GetRoutingID(), std::string())); |
318 | 327 |
319 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); | 328 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); |
320 } | 329 } |
321 | 330 |
322 // Verify that plugins can be allowed on a domain by adding an exception | 331 // Verify that plugins can be allowed on a domain by adding an exception |
323 IN_PROC_BROWSER_TEST_F(ClickToPlayPluginTest, AllowException) { | 332 IN_PROC_BROWSER_TEST_F(ClickToPlayPluginTest, AllowException) { |
324 GURL url = ui_test_utils::GetTestUrl( | 333 GURL url = ui_test_utils::GetTestUrl( |
325 FilePath(), FilePath().AppendASCII("clicktoplay.html")); | 334 FilePath(), FilePath().AppendASCII("clicktoplay.html")); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 GURL url = ui_test_utils::GetTestUrl( | 375 GURL url = ui_test_utils::GetTestUrl( |
367 FilePath(), FilePath().AppendASCII("load_all_blocked_plugins.html")); | 376 FilePath(), FilePath().AppendASCII("load_all_blocked_plugins.html")); |
368 ui_test_utils::NavigateToURL(browser(), url); | 377 ui_test_utils::NavigateToURL(browser(), url); |
369 | 378 |
370 string16 expected_title1(ASCIIToUTF16("1")); | 379 string16 expected_title1(ASCIIToUTF16("1")); |
371 content::TitleWatcher title_watcher1( | 380 content::TitleWatcher title_watcher1( |
372 browser()->tab_strip_model()->GetActiveWebContents(), expected_title1); | 381 browser()->tab_strip_model()->GetActiveWebContents(), expected_title1); |
373 | 382 |
374 content::RenderViewHost* host = | 383 content::RenderViewHost* host = |
375 browser()->tab_strip_model()->GetActiveWebContents()->GetRenderViewHost(); | 384 browser()->tab_strip_model()->GetActiveWebContents()->GetRenderViewHost(); |
| 385 ChromePluginServiceFilter::GetInstance()->AuthorizeAllPlugins( |
| 386 host->GetProcess()->GetID()); |
376 host->Send(new ChromeViewMsg_LoadBlockedPlugins( | 387 host->Send(new ChromeViewMsg_LoadBlockedPlugins( |
377 host->GetRoutingID(), std::string())); | 388 host->GetRoutingID(), std::string())); |
378 EXPECT_EQ(expected_title1, title_watcher1.WaitAndGetTitle()); | 389 EXPECT_EQ(expected_title1, title_watcher1.WaitAndGetTitle()); |
379 | 390 |
380 string16 expected_title2(ASCIIToUTF16("2")); | 391 string16 expected_title2(ASCIIToUTF16("2")); |
381 content::TitleWatcher title_watcher2( | 392 content::TitleWatcher title_watcher2( |
382 browser()->tab_strip_model()->GetActiveWebContents(), expected_title2); | 393 browser()->tab_strip_model()->GetActiveWebContents(), expected_title2); |
383 | 394 |
384 ASSERT_TRUE(content::ExecuteScript( | 395 ASSERT_TRUE(content::ExecuteScript( |
385 browser()->tab_strip_model()->GetActiveWebContents(), "window.inject()")); | 396 browser()->tab_strip_model()->GetActiveWebContents(), "window.inject()")); |
(...skipping 13 matching lines...) Expand all Loading... |
399 ASSERT_TRUE(content::ExecuteScript( | 410 ASSERT_TRUE(content::ExecuteScript( |
400 browser()->tab_strip_model()->GetActiveWebContents(), | 411 browser()->tab_strip_model()->GetActiveWebContents(), |
401 "CallOnStartup = function() { document.title = \"OK\"; }")); | 412 "CallOnStartup = function() { document.title = \"OK\"; }")); |
402 | 413 |
403 string16 expected_title(ASCIIToUTF16("OK")); | 414 string16 expected_title(ASCIIToUTF16("OK")); |
404 content::TitleWatcher title_watcher( | 415 content::TitleWatcher title_watcher( |
405 browser()->tab_strip_model()->GetActiveWebContents(), expected_title); | 416 browser()->tab_strip_model()->GetActiveWebContents(), expected_title); |
406 | 417 |
407 content::RenderViewHost* host = | 418 content::RenderViewHost* host = |
408 browser()->tab_strip_model()->GetActiveWebContents()->GetRenderViewHost(); | 419 browser()->tab_strip_model()->GetActiveWebContents()->GetRenderViewHost(); |
| 420 ChromePluginServiceFilter::GetInstance()->AuthorizeAllPlugins( |
| 421 host->GetProcess()->GetID()); |
409 host->Send(new ChromeViewMsg_LoadBlockedPlugins( | 422 host->Send(new ChromeViewMsg_LoadBlockedPlugins( |
410 host->GetRoutingID(), std::string())); | 423 host->GetRoutingID(), std::string())); |
411 | 424 |
412 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); | 425 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); |
413 } | 426 } |
414 | 427 |
415 IN_PROC_BROWSER_TEST_F(ClickToPlayPluginTest, DeleteSelfAtLoad) { | 428 IN_PROC_BROWSER_TEST_F(ClickToPlayPluginTest, DeleteSelfAtLoad) { |
416 browser()->profile()->GetHostContentSettingsMap()->SetDefaultContentSetting( | 429 browser()->profile()->GetHostContentSettingsMap()->SetDefaultContentSetting( |
417 CONTENT_SETTINGS_TYPE_PLUGINS, CONTENT_SETTING_BLOCK); | 430 CONTENT_SETTINGS_TYPE_PLUGINS, CONTENT_SETTING_BLOCK); |
418 | 431 |
419 GURL url = ui_test_utils::GetTestUrl( | 432 GURL url = ui_test_utils::GetTestUrl( |
420 FilePath(), FilePath().AppendASCII("plugin_delete_self_at_load.html")); | 433 FilePath(), FilePath().AppendASCII("plugin_delete_self_at_load.html")); |
421 ui_test_utils::NavigateToURL(browser(), url); | 434 ui_test_utils::NavigateToURL(browser(), url); |
422 | 435 |
423 string16 expected_title(ASCIIToUTF16("OK")); | 436 string16 expected_title(ASCIIToUTF16("OK")); |
424 content::TitleWatcher title_watcher( | 437 content::TitleWatcher title_watcher( |
425 browser()->tab_strip_model()->GetActiveWebContents(), expected_title); | 438 browser()->tab_strip_model()->GetActiveWebContents(), expected_title); |
426 | 439 |
427 content::RenderViewHost* host = | 440 content::RenderViewHost* host = |
428 browser()->tab_strip_model()->GetActiveWebContents()->GetRenderViewHost(); | 441 browser()->tab_strip_model()->GetActiveWebContents()->GetRenderViewHost(); |
| 442 ChromePluginServiceFilter::GetInstance()->AuthorizeAllPlugins( |
| 443 host->GetProcess()->GetID()); |
429 host->Send(new ChromeViewMsg_LoadBlockedPlugins( | 444 host->Send(new ChromeViewMsg_LoadBlockedPlugins( |
430 host->GetRoutingID(), std::string())); | 445 host->GetRoutingID(), std::string())); |
431 | 446 |
432 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); | 447 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); |
433 } | 448 } |
434 | 449 |
435 #endif // !defined(USE_AURA) | 450 #endif // !defined(USE_AURA) |
OLD | NEW |