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

Side by Side Diff: chrome/browser/policy/policy_browsertest.cc

Issue 2826843004: Rewrite base::Bind to base::BindOnce with base_bind_rewriters in //chrome/browser/policy (Closed)
Patch Set: Created 3 years, 8 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
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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include <algorithm> 8 #include <algorithm>
9 #include <memory> 9 #include <memory>
10 #include <string> 10 #include <string>
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 private: 335 private:
336 DISALLOW_COPY_AND_ASSIGN(FailedJobInterceptor); 336 DISALLOW_COPY_AND_ASSIGN(FailedJobInterceptor);
337 }; 337 };
338 338
339 // While |MakeRequestFail| is in scope URLRequests to |host| will fail. 339 // While |MakeRequestFail| is in scope URLRequests to |host| will fail.
340 class MakeRequestFail { 340 class MakeRequestFail {
341 public: 341 public:
342 // Sets up the filter on IO thread such that requests to |host| fail. 342 // Sets up the filter on IO thread such that requests to |host| fail.
343 explicit MakeRequestFail(const std::string& host) : host_(host) { 343 explicit MakeRequestFail(const std::string& host) : host_(host) {
344 BrowserThread::PostTaskAndReply(BrowserThread::IO, FROM_HERE, 344 BrowserThread::PostTaskAndReply(BrowserThread::IO, FROM_HERE,
345 base::Bind(MakeRequestFailOnIO, host_), 345 base::BindOnce(MakeRequestFailOnIO, host_),
346 base::MessageLoop::QuitWhenIdleClosure()); 346 base::MessageLoop::QuitWhenIdleClosure());
347 content::RunMessageLoop(); 347 content::RunMessageLoop();
348 } 348 }
349 ~MakeRequestFail() { 349 ~MakeRequestFail() {
350 BrowserThread::PostTaskAndReply(BrowserThread::IO, FROM_HERE, 350 BrowserThread::PostTaskAndReply(
351 base::Bind(UndoMakeRequestFailOnIO, host_), 351 BrowserThread::IO, FROM_HERE,
352 base::MessageLoop::QuitWhenIdleClosure()); 352 base::BindOnce(UndoMakeRequestFailOnIO, host_),
353 base::MessageLoop::QuitWhenIdleClosure());
353 content::RunMessageLoop(); 354 content::RunMessageLoop();
354 } 355 }
355 356
356 private: 357 private:
357 // Filters requests to the |host| such that they fail. Run on IO thread. 358 // Filters requests to the |host| such that they fail. Run on IO thread.
358 static void MakeRequestFailOnIO(const std::string& host) { 359 static void MakeRequestFailOnIO(const std::string& host) {
359 net::URLRequestFilter* filter = net::URLRequestFilter::GetInstance(); 360 net::URLRequestFilter* filter = net::URLRequestFilter::GetInstance();
360 filter->AddHostnameInterceptor("http", host, 361 filter->AddHostnameInterceptor("http", host,
361 std::unique_ptr<net::URLRequestInterceptor>( 362 std::unique_ptr<net::URLRequestInterceptor>(
362 new FailedJobInterceptor())); 363 new FailedJobInterceptor()));
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
630 void SetUpInProcessBrowserTestFixture() override { 631 void SetUpInProcessBrowserTestFixture() override {
631 base::CommandLine::ForCurrentProcess()->AppendSwitch("noerrdialogs"); 632 base::CommandLine::ForCurrentProcess()->AppendSwitch("noerrdialogs");
632 EXPECT_CALL(provider_, IsInitializationComplete(_)) 633 EXPECT_CALL(provider_, IsInitializationComplete(_))
633 .WillRepeatedly(Return(true)); 634 .WillRepeatedly(Return(true));
634 BrowserPolicyConnector::SetPolicyProviderForTesting(&provider_); 635 BrowserPolicyConnector::SetPolicyProviderForTesting(&provider_);
635 } 636 }
636 637
637 void SetUpOnMainThread() override { 638 void SetUpOnMainThread() override {
638 BrowserThread::PostTask( 639 BrowserThread::PostTask(
639 BrowserThread::IO, FROM_HERE, 640 BrowserThread::IO, FROM_HERE,
640 base::Bind(chrome_browser_net::SetUrlRequestMocksEnabled, true)); 641 base::BindOnce(chrome_browser_net::SetUrlRequestMocksEnabled, true));
641 if (extension_service()->updater()) { 642 if (extension_service()->updater()) {
642 extension_service()->updater()->SetExtensionCacheForTesting( 643 extension_service()->updater()->SetExtensionCacheForTesting(
643 test_extension_cache_.get()); 644 test_extension_cache_.get());
644 } 645 }
645 } 646 }
646 647
647 // Makes URLRequestMockHTTPJobs serve data from content::DIR_TEST_DATA 648 // Makes URLRequestMockHTTPJobs serve data from content::DIR_TEST_DATA
648 // instead of chrome::DIR_TEST_DATA. 649 // instead of chrome::DIR_TEST_DATA.
649 void ServeContentTestData() { 650 void ServeContentTestData() {
650 base::FilePath root_http; 651 base::FilePath root_http;
651 PathService::Get(content::DIR_TEST_DATA, &root_http); 652 PathService::Get(content::DIR_TEST_DATA, &root_http);
652 BrowserThread::PostTaskAndReply( 653 BrowserThread::PostTaskAndReply(
653 BrowserThread::IO, FROM_HERE, 654 BrowserThread::IO, FROM_HERE,
654 base::Bind(URLRequestMockHTTPJob::AddUrlHandlers, root_http, 655 base::BindOnce(URLRequestMockHTTPJob::AddUrlHandlers, root_http,
655 make_scoped_refptr(BrowserThread::GetBlockingPool())), 656 make_scoped_refptr(BrowserThread::GetBlockingPool())),
656 base::MessageLoop::current()->QuitWhenIdleClosure()); 657 base::MessageLoop::current()->QuitWhenIdleClosure());
657 content::RunMessageLoop(); 658 content::RunMessageLoop();
658 } 659 }
659 660
660 void SetScreenshotPolicy(bool enabled) { 661 void SetScreenshotPolicy(bool enabled) {
661 PolicyMap policies; 662 PolicyMap policies;
662 policies.Set(key::kDisableScreenshots, POLICY_LEVEL_MANDATORY, 663 policies.Set(key::kDisableScreenshots, POLICY_LEVEL_MANDATORY,
663 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, 664 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD,
664 base::MakeUnique<base::Value>(!enabled), nullptr); 665 base::MakeUnique<base::Value>(!enabled), nullptr);
665 UpdateProviderPolicy(policies); 666 UpdateProviderPolicy(policies);
(...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after
1240 void GetPacHttpsUrlStrippingEnabledOnIOThread(IOThread* io_thread, 1241 void GetPacHttpsUrlStrippingEnabledOnIOThread(IOThread* io_thread,
1241 bool* enabled) { 1242 bool* enabled) {
1242 *enabled = io_thread->PacHttpsUrlStrippingEnabled(); 1243 *enabled = io_thread->PacHttpsUrlStrippingEnabled();
1243 } 1244 }
1244 1245
1245 bool GetPacHttpsUrlStrippingEnabled() { 1246 bool GetPacHttpsUrlStrippingEnabled() {
1246 bool enabled; 1247 bool enabled;
1247 base::RunLoop loop; 1248 base::RunLoop loop;
1248 BrowserThread::PostTaskAndReply( 1249 BrowserThread::PostTaskAndReply(
1249 BrowserThread::IO, FROM_HERE, 1250 BrowserThread::IO, FROM_HERE,
1250 base::Bind(&GetPacHttpsUrlStrippingEnabledOnIOThread, 1251 base::BindOnce(&GetPacHttpsUrlStrippingEnabledOnIOThread,
1251 g_browser_process->io_thread(), base::Unretained(&enabled)), 1252 g_browser_process->io_thread(),
1253 base::Unretained(&enabled)),
1252 loop.QuitClosure()); 1254 loop.QuitClosure());
1253 loop.Run(); 1255 loop.Run();
1254 return enabled; 1256 return enabled;
1255 } 1257 }
1256 1258
1257 } // namespace 1259 } // namespace
1258 1260
1259 // Verifies that stripping of https:// URLs before sending to PAC scripts can 1261 // Verifies that stripping of https:// URLs before sending to PAC scripts can
1260 // be disabled via a policy. Also verifies that stripping is enabled by 1262 // be disabled via a policy. Also verifies that stripping is enabled by
1261 // default. 1263 // default.
(...skipping 1083 matching lines...) Expand 10 before | Expand all | Expand 10 after
2345 "http://aaa.com/empty.html", 2347 "http://aaa.com/empty.html",
2346 "http://bbb.com/empty.html", 2348 "http://bbb.com/empty.html",
2347 "http://sub.bbb.com/empty.html", 2349 "http://sub.bbb.com/empty.html",
2348 "http://bbb.com/policy/blank.html", 2350 "http://bbb.com/policy/blank.html",
2349 "http://bbb.com./policy/blank.html", 2351 "http://bbb.com./policy/blank.html",
2350 }; 2352 };
2351 { 2353 {
2352 base::RunLoop loop; 2354 base::RunLoop loop;
2353 BrowserThread::PostTaskAndReply( 2355 BrowserThread::PostTaskAndReply(
2354 BrowserThread::IO, FROM_HERE, 2356 BrowserThread::IO, FROM_HERE,
2355 base::Bind(RedirectHostsToTestData, kURLS, arraysize(kURLS)), 2357 base::BindOnce(RedirectHostsToTestData, kURLS, arraysize(kURLS)),
2356 loop.QuitClosure()); 2358 loop.QuitClosure());
2357 loop.Run(); 2359 loop.Run();
2358 } 2360 }
2359 2361
2360 // Verify that "bbb.com" opens before applying the blacklist. 2362 // Verify that "bbb.com" opens before applying the blacklist.
2361 CheckCanOpenURL(browser(), kURLS[1]); 2363 CheckCanOpenURL(browser(), kURLS[1]);
2362 2364
2363 // Set a blacklist. 2365 // Set a blacklist.
2364 base::ListValue blacklist; 2366 base::ListValue blacklist;
2365 blacklist.AppendString("bbb.com"); 2367 blacklist.AppendString("bbb.com");
(...skipping 17 matching lines...) Expand all
2383 FlushBlacklistPolicy(); 2385 FlushBlacklistPolicy();
2384 CheckURLIsBlocked(browser(), kURLS[1]); 2386 CheckURLIsBlocked(browser(), kURLS[1]);
2385 CheckCanOpenURL(browser(), kURLS[2]); 2387 CheckCanOpenURL(browser(), kURLS[2]);
2386 CheckCanOpenURL(browser(), kURLS[3]); 2388 CheckCanOpenURL(browser(), kURLS[3]);
2387 CheckCanOpenURL(browser(), kURLS[4]); 2389 CheckCanOpenURL(browser(), kURLS[4]);
2388 2390
2389 { 2391 {
2390 base::RunLoop loop; 2392 base::RunLoop loop;
2391 BrowserThread::PostTaskAndReply( 2393 BrowserThread::PostTaskAndReply(
2392 BrowserThread::IO, FROM_HERE, 2394 BrowserThread::IO, FROM_HERE,
2393 base::Bind(UndoRedirectHostsToTestData, kURLS, arraysize(kURLS)), 2395 base::BindOnce(UndoRedirectHostsToTestData, kURLS, arraysize(kURLS)),
2394 loop.QuitClosure()); 2396 loop.QuitClosure());
2395 loop.Run(); 2397 loop.Run();
2396 } 2398 }
2397 } 2399 }
2398 2400
2399 IN_PROC_BROWSER_TEST_F(PolicyTest, URLBlacklistSubresources) { 2401 IN_PROC_BROWSER_TEST_F(PolicyTest, URLBlacklistSubresources) {
2400 // Checks that an image with a blacklisted URL is loaded, but an iframe with a 2402 // Checks that an image with a blacklisted URL is loaded, but an iframe with a
2401 // blacklisted URL is not. 2403 // blacklisted URL is not.
2402 2404
2403 GURL main_url = 2405 GURL main_url =
(...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after
2954 base::CommandLine::StringVector argv = command_line->argv(); 2956 base::CommandLine::StringVector argv = command_line->argv();
2955 argv.erase(std::remove_if(++argv.begin(), argv.end(), IsNonSwitchArgument), 2957 argv.erase(std::remove_if(++argv.begin(), argv.end(), IsNonSwitchArgument),
2956 argv.end()); 2958 argv.end());
2957 command_line->InitFromArgv(argv); 2959 command_line->InitFromArgv(argv);
2958 ASSERT_TRUE(std::equal(argv.begin(), argv.end(), 2960 ASSERT_TRUE(std::equal(argv.begin(), argv.end(),
2959 command_line->argv().begin())); 2961 command_line->argv().begin()));
2960 } 2962 }
2961 2963
2962 void SetUpOnMainThread() override { 2964 void SetUpOnMainThread() override {
2963 BrowserThread::PostTask( 2965 BrowserThread::PostTask(
2964 BrowserThread::IO, 2966 BrowserThread::IO, FROM_HERE,
2965 FROM_HERE, 2967 base::BindOnce(RedirectHostsToTestData, kRestoredURLs,
2966 base::Bind( 2968 arraysize(kRestoredURLs)));
2967 RedirectHostsToTestData, kRestoredURLs, arraysize(kRestoredURLs)));
2968 } 2969 }
2969 2970
2970 void ListOfURLs() { 2971 void ListOfURLs() {
2971 // Verifies that policy can set the startup pages to a list of URLs. 2972 // Verifies that policy can set the startup pages to a list of URLs.
2972 base::ListValue urls; 2973 base::ListValue urls;
2973 for (size_t i = 0; i < arraysize(kRestoredURLs); ++i) { 2974 for (size_t i = 0; i < arraysize(kRestoredURLs); ++i) {
2974 urls.AppendString(kRestoredURLs[i]); 2975 urls.AppendString(kRestoredURLs[i]);
2975 expected_urls_.push_back(GURL(kRestoredURLs[i])); 2976 expected_urls_.push_back(GURL(kRestoredURLs[i]));
2976 } 2977 }
2977 PolicyMap policies; 2978 PolicyMap policies;
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
3265 content::MediaStreamDevice fake_audio_device( 3266 content::MediaStreamDevice fake_audio_device(
3266 content::MEDIA_DEVICE_AUDIO_CAPTURE, "fake_dev", "Fake Audio Device"); 3267 content::MEDIA_DEVICE_AUDIO_CAPTURE, "fake_dev", "Fake Audio Device");
3267 audio_devices.push_back(fake_audio_device); 3268 audio_devices.push_back(fake_audio_device);
3268 3269
3269 PolicyMap policies; 3270 PolicyMap policies;
3270 ConfigurePolicyMap(&policies, key::kAudioCaptureAllowed, NULL, NULL); 3271 ConfigurePolicyMap(&policies, key::kAudioCaptureAllowed, NULL, NULL);
3271 UpdateProviderPolicy(policies); 3272 UpdateProviderPolicy(policies);
3272 3273
3273 content::BrowserThread::PostTaskAndReply( 3274 content::BrowserThread::PostTaskAndReply(
3274 content::BrowserThread::IO, FROM_HERE, 3275 content::BrowserThread::IO, FROM_HERE,
3275 base::Bind(&MediaCaptureDevicesDispatcher::SetTestAudioCaptureDevices, 3276 base::BindOnce(
3276 base::Unretained(MediaCaptureDevicesDispatcher::GetInstance()), 3277 &MediaCaptureDevicesDispatcher::SetTestAudioCaptureDevices,
3277 audio_devices), 3278 base::Unretained(MediaCaptureDevicesDispatcher::GetInstance()),
3278 base::Bind(&MediaStreamDevicesControllerBrowserTest::FinishAudioTest, 3279 audio_devices),
3279 base::Unretained(this))); 3280 base::BindOnce(&MediaStreamDevicesControllerBrowserTest::FinishAudioTest,
3281 base::Unretained(this)));
3280 3282
3281 base::RunLoop().Run(); 3283 base::RunLoop().Run();
3282 } 3284 }
3283 3285
3284 IN_PROC_BROWSER_TEST_P(MediaStreamDevicesControllerBrowserTest, 3286 IN_PROC_BROWSER_TEST_P(MediaStreamDevicesControllerBrowserTest,
3285 AudioCaptureAllowedUrls) { 3287 AudioCaptureAllowedUrls) {
3286 content::MediaStreamDevices audio_devices; 3288 content::MediaStreamDevices audio_devices;
3287 content::MediaStreamDevice fake_audio_device( 3289 content::MediaStreamDevice fake_audio_device(
3288 content::MEDIA_DEVICE_AUDIO_CAPTURE, "fake_dev", "Fake Audio Device"); 3290 content::MEDIA_DEVICE_AUDIO_CAPTURE, "fake_dev", "Fake Audio Device");
3289 audio_devices.push_back(fake_audio_device); 3291 audio_devices.push_back(fake_audio_device);
3290 3292
3291 const char* allow_pattern[] = { 3293 const char* allow_pattern[] = {
3292 kExampleRequestPattern, 3294 kExampleRequestPattern,
3293 // This will set an allow-all policy whitelist. Since we do not allow 3295 // This will set an allow-all policy whitelist. Since we do not allow
3294 // setting an allow-all entry in the whitelist, this entry should be ignored 3296 // setting an allow-all entry in the whitelist, this entry should be ignored
3295 // and therefore the request should be denied. 3297 // and therefore the request should be denied.
3296 NULL, 3298 NULL,
3297 }; 3299 };
3298 3300
3299 for (size_t i = 0; i < arraysize(allow_pattern); ++i) { 3301 for (size_t i = 0; i < arraysize(allow_pattern); ++i) {
3300 PolicyMap policies; 3302 PolicyMap policies;
3301 ConfigurePolicyMap(&policies, key::kAudioCaptureAllowed, 3303 ConfigurePolicyMap(&policies, key::kAudioCaptureAllowed,
3302 key::kAudioCaptureAllowedUrls, allow_pattern[i]); 3304 key::kAudioCaptureAllowedUrls, allow_pattern[i]);
3303 UpdateProviderPolicy(policies); 3305 UpdateProviderPolicy(policies);
3304 3306
3305 content::BrowserThread::PostTaskAndReply( 3307 content::BrowserThread::PostTaskAndReply(
3306 content::BrowserThread::IO, FROM_HERE, 3308 content::BrowserThread::IO, FROM_HERE,
3307 base::Bind( 3309 base::BindOnce(
3308 &MediaCaptureDevicesDispatcher::SetTestAudioCaptureDevices, 3310 &MediaCaptureDevicesDispatcher::SetTestAudioCaptureDevices,
3309 base::Unretained(MediaCaptureDevicesDispatcher::GetInstance()), 3311 base::Unretained(MediaCaptureDevicesDispatcher::GetInstance()),
3310 audio_devices), 3312 audio_devices),
3311 base::Bind( 3313 base::BindOnce(
3312 &MediaStreamDevicesControllerBrowserTest::FinishAudioTest, 3314 &MediaStreamDevicesControllerBrowserTest::FinishAudioTest,
3313 base::Unretained(this))); 3315 base::Unretained(this)));
3314 3316
3315 base::RunLoop().Run(); 3317 base::RunLoop().Run();
3316 } 3318 }
3317 } 3319 }
3318 3320
3319 IN_PROC_BROWSER_TEST_P(MediaStreamDevicesControllerBrowserTest, 3321 IN_PROC_BROWSER_TEST_P(MediaStreamDevicesControllerBrowserTest,
3320 VideoCaptureAllowed) { 3322 VideoCaptureAllowed) {
3321 content::MediaStreamDevices video_devices; 3323 content::MediaStreamDevices video_devices;
3322 content::MediaStreamDevice fake_video_device( 3324 content::MediaStreamDevice fake_video_device(
3323 content::MEDIA_DEVICE_VIDEO_CAPTURE, "fake_dev", "Fake Video Device"); 3325 content::MEDIA_DEVICE_VIDEO_CAPTURE, "fake_dev", "Fake Video Device");
3324 video_devices.push_back(fake_video_device); 3326 video_devices.push_back(fake_video_device);
3325 3327
3326 PolicyMap policies; 3328 PolicyMap policies;
3327 ConfigurePolicyMap(&policies, key::kVideoCaptureAllowed, NULL, NULL); 3329 ConfigurePolicyMap(&policies, key::kVideoCaptureAllowed, NULL, NULL);
3328 UpdateProviderPolicy(policies); 3330 UpdateProviderPolicy(policies);
3329 3331
3330 content::BrowserThread::PostTaskAndReply( 3332 content::BrowserThread::PostTaskAndReply(
3331 content::BrowserThread::IO, FROM_HERE, 3333 content::BrowserThread::IO, FROM_HERE,
3332 base::Bind(&MediaCaptureDevicesDispatcher::SetTestVideoCaptureDevices, 3334 base::BindOnce(
3333 base::Unretained(MediaCaptureDevicesDispatcher::GetInstance()), 3335 &MediaCaptureDevicesDispatcher::SetTestVideoCaptureDevices,
3334 video_devices), 3336 base::Unretained(MediaCaptureDevicesDispatcher::GetInstance()),
3335 base::Bind(&MediaStreamDevicesControllerBrowserTest::FinishVideoTest, 3337 video_devices),
3336 base::Unretained(this))); 3338 base::BindOnce(&MediaStreamDevicesControllerBrowserTest::FinishVideoTest,
3339 base::Unretained(this)));
3337 3340
3338 base::RunLoop().Run(); 3341 base::RunLoop().Run();
3339 } 3342 }
3340 3343
3341 IN_PROC_BROWSER_TEST_P(MediaStreamDevicesControllerBrowserTest, 3344 IN_PROC_BROWSER_TEST_P(MediaStreamDevicesControllerBrowserTest,
3342 VideoCaptureAllowedUrls) { 3345 VideoCaptureAllowedUrls) {
3343 content::MediaStreamDevices video_devices; 3346 content::MediaStreamDevices video_devices;
3344 content::MediaStreamDevice fake_video_device( 3347 content::MediaStreamDevice fake_video_device(
3345 content::MEDIA_DEVICE_VIDEO_CAPTURE, "fake_dev", "Fake Video Device"); 3348 content::MEDIA_DEVICE_VIDEO_CAPTURE, "fake_dev", "Fake Video Device");
3346 video_devices.push_back(fake_video_device); 3349 video_devices.push_back(fake_video_device);
3347 3350
3348 const char* allow_pattern[] = { 3351 const char* allow_pattern[] = {
3349 kExampleRequestPattern, 3352 kExampleRequestPattern,
3350 // This will set an allow-all policy whitelist. Since we do not allow 3353 // This will set an allow-all policy whitelist. Since we do not allow
3351 // setting an allow-all entry in the whitelist, this entry should be ignored 3354 // setting an allow-all entry in the whitelist, this entry should be ignored
3352 // and therefore the request should be denied. 3355 // and therefore the request should be denied.
3353 NULL, 3356 NULL,
3354 }; 3357 };
3355 3358
3356 for (size_t i = 0; i < arraysize(allow_pattern); ++i) { 3359 for (size_t i = 0; i < arraysize(allow_pattern); ++i) {
3357 PolicyMap policies; 3360 PolicyMap policies;
3358 ConfigurePolicyMap(&policies, key::kVideoCaptureAllowed, 3361 ConfigurePolicyMap(&policies, key::kVideoCaptureAllowed,
3359 key::kVideoCaptureAllowedUrls, allow_pattern[i]); 3362 key::kVideoCaptureAllowedUrls, allow_pattern[i]);
3360 UpdateProviderPolicy(policies); 3363 UpdateProviderPolicy(policies);
3361 3364
3362 content::BrowserThread::PostTaskAndReply( 3365 content::BrowserThread::PostTaskAndReply(
3363 content::BrowserThread::IO, FROM_HERE, 3366 content::BrowserThread::IO, FROM_HERE,
3364 base::Bind(&MediaCaptureDevicesDispatcher::SetTestVideoCaptureDevices, 3367 base::BindOnce(
3368 &MediaCaptureDevicesDispatcher::SetTestVideoCaptureDevices,
3365 base::Unretained(MediaCaptureDevicesDispatcher::GetInstance()), 3369 base::Unretained(MediaCaptureDevicesDispatcher::GetInstance()),
3366 video_devices), 3370 video_devices),
3367 base::Bind( 3371 base::BindOnce(
3368 &MediaStreamDevicesControllerBrowserTest::FinishVideoTest, 3372 &MediaStreamDevicesControllerBrowserTest::FinishVideoTest,
3369 base::Unretained(this))); 3373 base::Unretained(this)));
3370 3374
3371 base::RunLoop().Run(); 3375 base::RunLoop().Run();
3372 } 3376 }
3373 } 3377 }
3374 3378
3375 INSTANTIATE_TEST_CASE_P(MediaStreamDevicesControllerBrowserTestInstance, 3379 INSTANTIATE_TEST_CASE_P(MediaStreamDevicesControllerBrowserTestInstance,
3376 MediaStreamDevicesControllerBrowserTest, 3380 MediaStreamDevicesControllerBrowserTest,
3377 testing::Bool()); 3381 testing::Bool());
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
3436 nullptr))); 3440 nullptr)));
3437 3441
3438 net::EmbeddedTestServer https_server_ok(net::EmbeddedTestServer::TYPE_HTTPS); 3442 net::EmbeddedTestServer https_server_ok(net::EmbeddedTestServer::TYPE_HTTPS);
3439 https_server_ok.SetSSLConfig(net::EmbeddedTestServer::CERT_OK); 3443 https_server_ok.SetSSLConfig(net::EmbeddedTestServer::CERT_OK);
3440 https_server_ok.ServeFilesFromSourceDirectory("chrome/test/data"); 3444 https_server_ok.ServeFilesFromSourceDirectory("chrome/test/data");
3441 ASSERT_TRUE(https_server_ok.Start()); 3445 ASSERT_TRUE(https_server_ok.Start());
3442 3446
3443 // Require CT for all hosts (in the absence of policy). 3447 // Require CT for all hosts (in the absence of policy).
3444 BrowserThread::PostTask( 3448 BrowserThread::PostTask(
3445 BrowserThread::IO, FROM_HERE, 3449 BrowserThread::IO, FROM_HERE,
3446 base::Bind(net::TransportSecurityState::SetShouldRequireCTForTesting, 3450 base::BindOnce(net::TransportSecurityState::SetShouldRequireCTForTesting,
3447 base::Owned(new bool(true)))); 3451 base::Owned(new bool(true))));
3448 3452
3449 ui_test_utils::NavigateToURL(browser(), https_server_ok.GetURL("/")); 3453 ui_test_utils::NavigateToURL(browser(), https_server_ok.GetURL("/"));
3450 3454
3451 // The page should initially be blocked. 3455 // The page should initially be blocked.
3452 const content::InterstitialPage* interstitial = 3456 const content::InterstitialPage* interstitial =
3453 content::InterstitialPage::GetInterstitialPage( 3457 content::InterstitialPage::GetInterstitialPage(
3454 browser()->tab_strip_model()->GetActiveWebContents()); 3458 browser()->tab_strip_model()->GetActiveWebContents());
3455 ASSERT_TRUE(interstitial); 3459 ASSERT_TRUE(interstitial);
3456 ASSERT_TRUE(content::WaitForRenderFrameReady(interstitial->GetMainFrame())); 3460 ASSERT_TRUE(content::WaitForRenderFrameReady(interstitial->GetMainFrame()));
3457 3461
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after
3891 EXPECT_TRUE(post_interceptor_->ExpectRequest( 3895 EXPECT_TRUE(post_interceptor_->ExpectRequest(
3892 new update_client::PartialMatch("updatecheck"), 200)); 3896 new update_client::PartialMatch("updatecheck"), 200));
3893 EXPECT_TRUE(cus_->RegisterComponent(crx_component)); 3897 EXPECT_TRUE(cus_->RegisterComponent(crx_component));
3894 cus_->GetOnDemandUpdater().OnDemandUpdate( 3898 cus_->GetOnDemandUpdater().OnDemandUpdate(
3895 component_id_, base::Bind(&ComponentUpdaterPolicyTest::OnDemandComplete, 3899 component_id_, base::Bind(&ComponentUpdaterPolicyTest::OnDemandComplete,
3896 base::Unretained(this))); 3900 base::Unretained(this)));
3897 } 3901 }
3898 3902
3899 void ComponentUpdaterPolicyTest::CallAsync(TestCaseAction action) { 3903 void ComponentUpdaterPolicyTest::CallAsync(TestCaseAction action) {
3900 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, 3904 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
3901 base::Bind(action, base::Unretained(this))); 3905 base::BindOnce(action, base::Unretained(this)));
3902 } 3906 }
3903 3907
3904 void ComponentUpdaterPolicyTest::OnDemandComplete(update_client::Error error) { 3908 void ComponentUpdaterPolicyTest::OnDemandComplete(update_client::Error error) {
3905 CallAsync(cur_test_case_.second); 3909 CallAsync(cur_test_case_.second);
3906 } 3910 }
3907 3911
3908 void ComponentUpdaterPolicyTest::BeginTest() { 3912 void ComponentUpdaterPolicyTest::BeginTest() {
3909 cus_ = g_browser_process->component_updater(); 3913 cus_ = g_browser_process->component_updater();
3910 3914
3911 const auto config = component_updater::MakeChromeComponentUpdaterConfigurator( 3915 const auto config = component_updater::MakeChromeComponentUpdaterConfigurator(
(...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after
4485 4489
4486 SetEmptyPolicy(); 4490 SetEmptyPolicy();
4487 // Policy not set. 4491 // Policy not set.
4488 CheckSystemTimezoneAutomaticDetectionPolicyUnset(); 4492 CheckSystemTimezoneAutomaticDetectionPolicyUnset();
4489 EXPECT_TRUE(CheckResolveTimezoneByGeolocation(true, false)); 4493 EXPECT_TRUE(CheckResolveTimezoneByGeolocation(true, false));
4490 EXPECT_TRUE(manager->TimeZoneResolverShouldBeRunningForTests()); 4494 EXPECT_TRUE(manager->TimeZoneResolverShouldBeRunningForTests());
4491 } 4495 }
4492 #endif // defined(OS_CHROMEOS) 4496 #endif // defined(OS_CHROMEOS)
4493 4497
4494 } // namespace policy 4498 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/policy/cloud/user_policy_signin_service_base.cc ('k') | chrome/browser/policy/policy_network_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698