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

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

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

Powered by Google App Engine
This is Rietveld 408576698