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

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

Issue 1993813002: Revert of media: Add helper function to register pepper CDMs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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
« no previous file with comments | « no previous file | chrome/browser/media/encrypted_media_browsertest.cc » ('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/strings/stringprintf.h" 7 #include "base/strings/stringprintf.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "build/build_config.h" 9 #include "build/build_config.h"
10 #include "chrome/browser/chrome_notification_types.h" 10 #include "chrome/browser/chrome_notification_types.h"
(...skipping 25 matching lines...) Expand all
36 #include "net/dns/mock_host_resolver.h" 36 #include "net/dns/mock_host_resolver.h"
37 #include "net/test/embedded_test_server/embedded_test_server.h" 37 #include "net/test/embedded_test_server/embedded_test_server.h"
38 #include "net/test/url_request/url_request_mock_http_job.h" 38 #include "net/test/url_request/url_request_mock_http_job.h"
39 39
40 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. 40 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR.
41 41
42 #if defined(OS_MACOSX) 42 #if defined(OS_MACOSX)
43 #include "base/mac/scoped_nsautorelease_pool.h" 43 #include "base/mac/scoped_nsautorelease_pool.h"
44 #endif 44 #endif
45 45
46 #if defined(ENABLE_PEPPER_CDMS)
47 #include "chrome/browser/media/pepper_cdm_test_helper.h"
48 #endif
49
50 using content::BrowserThread; 46 using content::BrowserThread;
51 using net::URLRequestMockHTTPJob; 47 using net::URLRequestMockHTTPJob;
52 48
53 namespace { 49 namespace {
54 50
55 const LocalSharedObjectsContainer* GetSiteSettingsCookieContainer( 51 const LocalSharedObjectsContainer* GetSiteSettingsCookieContainer(
56 Browser* browser) { 52 Browser* browser) {
57 TabSpecificContentSettings* settings = 53 TabSpecificContentSettings* settings =
58 TabSpecificContentSettings::FromWebContents( 54 TabSpecificContentSettings::FromWebContents(
59 browser->tab_strip_model()->GetWebContentsAt(0)); 55 browser->tab_strip_model()->GetWebContentsAt(0));
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 content::WebContents* web_contents = 310 content::WebContents* web_contents =
315 browser()->tab_strip_model()->GetActiveWebContents(); 311 browser()->tab_strip_model()->GetActiveWebContents();
316 312
317 EXPECT_TRUE(TabSpecificContentSettings::FromWebContents(web_contents)-> 313 EXPECT_TRUE(TabSpecificContentSettings::FromWebContents(web_contents)->
318 IsContentBlocked(CONTENT_SETTINGS_TYPE_COOKIES)); 314 IsContentBlocked(CONTENT_SETTINGS_TYPE_COOKIES));
319 } 315 }
320 316
321 #if defined(ENABLE_PLUGINS) 317 #if defined(ENABLE_PLUGINS)
322 class PepperContentSettingsSpecialCasesTest : public ContentSettingsTest { 318 class PepperContentSettingsSpecialCasesTest : public ContentSettingsTest {
323 protected: 319 protected:
320 static const char kExternalClearKeyMimeType[];
321
324 // Registers any CDM plugins not registered by default. 322 // Registers any CDM plugins not registered by default.
325 void SetUpCommandLine(base::CommandLine* command_line) override { 323 void SetUpCommandLine(base::CommandLine* command_line) override {
326 #if defined(ENABLE_PEPPER_CDMS) 324 #if defined(ENABLE_PEPPER_CDMS)
325 // Platform-specific filename relative to the chrome executable.
326 #if defined(OS_WIN)
327 const char kLibraryName[] = "clearkeycdmadapter.dll";
328 #else // !defined(OS_WIN)
329 #if defined(OS_MACOSX)
330 const char kLibraryName[] = "clearkeycdmadapter.plugin";
331 #elif defined(OS_POSIX)
332 const char kLibraryName[] = "libclearkeycdmadapter.so";
333 #endif // defined(OS_MACOSX)
334 #endif // defined(OS_WIN)
335
327 // Append the switch to register the External Clear Key CDM. 336 // Append the switch to register the External Clear Key CDM.
328 base::FilePath::StringType pepper_plugins = BuildPepperCdmRegistration( 337 base::FilePath::StringType pepper_plugins = BuildPepperPluginRegistration(
329 kClearKeyCdmAdapterFileName, kClearKeyCdmPepperMimeType); 338 kLibraryName, "Clear Key CDM", kExternalClearKeyMimeType);
330 #if defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_IS_COMPONENT) 339 #if defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_IS_COMPONENT)
331 // The CDM must be registered when it is a component. 340 // The CDM must be registered when it is a component.
332 pepper_plugins.append(FILE_PATH_LITERAL(",")); 341 pepper_plugins.append(FILE_PATH_LITERAL(","));
333 pepper_plugins.append(BuildPepperCdmRegistration( 342 pepper_plugins.append(
334 kWidevineCdmAdapterFileName, kWidevineCdmPluginMimeType)); 343 BuildPepperPluginRegistration(kWidevineCdmAdapterFileName,
344 kWidevineCdmDisplayName,
345 kWidevineCdmPluginMimeType));
335 #endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_IS_COMPONENT) 346 #endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_IS_COMPONENT)
336 command_line->AppendSwitchNative(switches::kRegisterPepperPlugins, 347 command_line->AppendSwitchNative(switches::kRegisterPepperPlugins,
337 pepper_plugins); 348 pepper_plugins);
338 #endif // defined(ENABLE_PEPPER_CDMS) 349 #endif // defined(ENABLE_PEPPER_CDMS)
339 350
340 #if !defined(DISABLE_NACL) 351 #if !defined(DISABLE_NACL)
341 // Ensure NaCl can run. 352 // Ensure NaCl can run.
342 command_line->AppendSwitch(switches::kEnableNaCl); 353 command_line->AppendSwitch(switches::kEnableNaCl);
343 #endif 354 #endif
344 } 355 }
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 // false, javascript_content_blocked_observer would never succeed. 421 // false, javascript_content_blocked_observer would never succeed.
411 // There is no way to ensure blocked content would not have been reported 422 // There is no way to ensure blocked content would not have been reported
412 // after the check below. For coverage of this scenario, we must rely on 423 // after the check below. For coverage of this scenario, we must rely on
413 // the TitleWatcher adding sufficient delay most of the time. 424 // the TitleWatcher adding sufficient delay most of the time.
414 } 425 }
415 426
416 EXPECT_EQ(expect_is_javascript_content_blocked, 427 EXPECT_EQ(expect_is_javascript_content_blocked,
417 tab_settings->IsContentBlocked(CONTENT_SETTINGS_TYPE_JAVASCRIPT)); 428 tab_settings->IsContentBlocked(CONTENT_SETTINGS_TYPE_JAVASCRIPT));
418 EXPECT_FALSE(tab_settings->IsContentBlocked(CONTENT_SETTINGS_TYPE_PLUGINS)); 429 EXPECT_FALSE(tab_settings->IsContentBlocked(CONTENT_SETTINGS_TYPE_PLUGINS));
419 } 430 }
431
432 private:
433 // Builds the string to pass to kRegisterPepperPlugins for a single
434 // plugin using the provided parameters and a dummy version.
435 // Multiple results may be passed to kRegisterPepperPlugins, separated by ",".
436 base::FilePath::StringType BuildPepperPluginRegistration(
437 const char* library_name,
438 const char* display_name,
439 const char* mime_type) {
440 base::FilePath plugin_dir;
441 EXPECT_TRUE(PathService::Get(base::DIR_MODULE, &plugin_dir));
442
443 base::FilePath plugin_lib = plugin_dir.AppendASCII(library_name);
444 EXPECT_TRUE(base::PathExists(plugin_lib));
445
446 base::FilePath::StringType pepper_plugin = plugin_lib.value();
447 std::string string_to_append = "#";
448 string_to_append.append(display_name);
449 string_to_append.append("#A CDM#0.1.0.0;");
450 string_to_append.append(mime_type);
451
452 #if defined(OS_WIN)
453 pepper_plugin.append(base::ASCIIToUTF16(string_to_append));
454 #else
455 pepper_plugin.append(string_to_append);
456 #endif
457
458 return pepper_plugin;
459 }
420 }; 460 };
421 461
462 const char
463 PepperContentSettingsSpecialCasesTest::kExternalClearKeyMimeType[] =
464 "application/x-ppapi-clearkey-cdm";
465
422 class PepperContentSettingsSpecialCasesPluginsBlockedTest 466 class PepperContentSettingsSpecialCasesPluginsBlockedTest
423 : public PepperContentSettingsSpecialCasesTest { 467 : public PepperContentSettingsSpecialCasesTest {
424 public: 468 public:
425 void SetUpOnMainThread() override { 469 void SetUpOnMainThread() override {
426 PepperContentSettingsSpecialCasesTest::SetUpOnMainThread(); 470 PepperContentSettingsSpecialCasesTest::SetUpOnMainThread();
427 HostContentSettingsMapFactory::GetForProfile(browser()->profile()) 471 HostContentSettingsMapFactory::GetForProfile(browser()->profile())
428 ->SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_PLUGINS, 472 ->SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_PLUGINS,
429 CONTENT_SETTING_BLOCK); 473 CONTENT_SETTING_BLOCK);
430 } 474 }
431 }; 475 };
(...skipping 13 matching lines...) Expand all
445 }; 489 };
446 490
447 #if defined(ENABLE_PEPPER_CDMS) 491 #if defined(ENABLE_PEPPER_CDMS)
448 // A sanity check to verify that the plugin that is used as a baseline below 492 // A sanity check to verify that the plugin that is used as a baseline below
449 // can be loaded. 493 // can be loaded.
450 IN_PROC_BROWSER_TEST_F(PepperContentSettingsSpecialCasesTest, Baseline) { 494 IN_PROC_BROWSER_TEST_F(PepperContentSettingsSpecialCasesTest, Baseline) {
451 HostContentSettingsMapFactory::GetForProfile(browser()->profile()) 495 HostContentSettingsMapFactory::GetForProfile(browser()->profile())
452 ->SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_PLUGINS, 496 ->SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_PLUGINS,
453 CONTENT_SETTING_ALLOW); 497 CONTENT_SETTING_ALLOW);
454 498
455 RunLoadPepperPluginTest(kClearKeyCdmPepperMimeType, true); 499 RunLoadPepperPluginTest(kExternalClearKeyMimeType, true);
456 } 500 }
457 #endif // defined(ENABLE_PEPPER_CDMS) 501 #endif // defined(ENABLE_PEPPER_CDMS)
458 502
459 // The following tests verify that Pepper plugins that use JavaScript settings 503 // The following tests verify that Pepper plugins that use JavaScript settings
460 // instead of Plugins settings still work when Plugins are blocked. 504 // instead of Plugins settings still work when Plugins are blocked.
461 505
462 #if defined(ENABLE_PEPPER_CDMS) 506 #if defined(ENABLE_PEPPER_CDMS)
463 // The plugin successfully loaded above is blocked. 507 // The plugin successfully loaded above is blocked.
464 IN_PROC_BROWSER_TEST_F(PepperContentSettingsSpecialCasesPluginsBlockedTest, 508 IN_PROC_BROWSER_TEST_F(PepperContentSettingsSpecialCasesPluginsBlockedTest,
465 Normal) { 509 Normal) {
466 RunLoadPepperPluginTest(kClearKeyCdmPepperMimeType, false); 510 RunLoadPepperPluginTest(kExternalClearKeyMimeType, false);
467 } 511 }
468 512
469 #if defined(WIDEVINE_CDM_AVAILABLE) && !defined(OS_CHROMEOS) 513 #if defined(WIDEVINE_CDM_AVAILABLE) && !defined(OS_CHROMEOS)
470 IN_PROC_BROWSER_TEST_F(PepperContentSettingsSpecialCasesPluginsBlockedTest, 514 IN_PROC_BROWSER_TEST_F(PepperContentSettingsSpecialCasesPluginsBlockedTest,
471 WidevineCdm) { 515 WidevineCdm) {
472 RunLoadPepperPluginTest(kWidevineCdmPluginMimeType, true); 516 RunLoadPepperPluginTest(kWidevineCdmPluginMimeType, true);
473 } 517 }
474 #endif // defined(WIDEVINE_CDM_AVAILABLE) && !defined(OS_CHROMEOS) 518 #endif // defined(WIDEVINE_CDM_AVAILABLE) && !defined(OS_CHROMEOS)
475 #endif // defined(ENABLE_PEPPER_CDMS) 519 #endif // defined(ENABLE_PEPPER_CDMS)
476 520
(...skipping 23 matching lines...) Expand all
500 #endif // defined(ENABLE_PEPPER_CDMS) 544 #endif // defined(ENABLE_PEPPER_CDMS)
501 545
502 #if !defined(DISABLE_NACL) 546 #if !defined(DISABLE_NACL)
503 IN_PROC_BROWSER_TEST_F(PepperContentSettingsSpecialCasesJavaScriptBlockedTest, 547 IN_PROC_BROWSER_TEST_F(PepperContentSettingsSpecialCasesJavaScriptBlockedTest,
504 NaCl) { 548 NaCl) {
505 RunJavaScriptBlockedTest("load_nacl_no_js.html", true); 549 RunJavaScriptBlockedTest("load_nacl_no_js.html", true);
506 } 550 }
507 #endif // !defined(DISABLE_NACL) 551 #endif // !defined(DISABLE_NACL)
508 552
509 #endif // defined(ENABLE_PLUGINS) 553 #endif // defined(ENABLE_PLUGINS)
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/media/encrypted_media_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698