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

Side by Side Diff: chrome/browser/supervised_user/supervised_user_browsertest.cc

Issue 2776493005: Convert SupervisedUserResourceThrottle to a NavigationThrottle. (Closed)
Patch Set: Response to comments 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <utility> 5 #include <utility>
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 GoBack(tab); 231 GoBack(tab);
232 run_loop.Run(); 232 run_loop.Run();
233 EXPECT_EQ(prev_tab, tab_strip->GetActiveWebContents()); 233 EXPECT_EQ(prev_tab, tab_strip->GetActiveWebContents());
234 } 234 }
235 235
236 // Tests whether a visit attempt adds a special history entry. 236 // Tests whether a visit attempt adds a special history entry.
237 IN_PROC_BROWSER_TEST_F(SupervisedUserBlockModeTest, 237 IN_PROC_BROWSER_TEST_F(SupervisedUserBlockModeTest,
238 HistoryVisitRecorded) { 238 HistoryVisitRecorded) {
239 GURL allowed_url("http://www.example.com/simple.html"); 239 GURL allowed_url("http://www.example.com/simple.html");
240 240
241 scoped_refptr<SupervisedUserURLFilter> filter = 241 const SupervisedUserURLFilter* filter =
242 supervised_user_service_->GetURLFilterForUIThread(); 242 supervised_user_service_->GetURLFilter();
243 243
244 // Set the host as allowed. 244 // Set the host as allowed.
245 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue); 245 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue);
246 dict->SetBooleanWithoutPathExpansion(allowed_url.host(), true); 246 dict->SetBooleanWithoutPathExpansion(allowed_url.host(), true);
247 SupervisedUserSettingsService* supervised_user_settings_service = 247 SupervisedUserSettingsService* supervised_user_settings_service =
248 SupervisedUserSettingsServiceFactory::GetForProfile( 248 SupervisedUserSettingsServiceFactory::GetForProfile(
249 browser()->profile()); 249 browser()->profile());
250 supervised_user_settings_service->SetLocalSetting( 250 supervised_user_settings_service->SetLocalSetting(
251 supervised_users::kContentPackManualBehaviorHosts, std::move(dict)); 251 supervised_users::kContentPackManualBehaviorHosts, std::move(dict));
252 EXPECT_EQ(SupervisedUserURLFilter::ALLOW, 252 EXPECT_EQ(SupervisedUserURLFilter::ALLOW,
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 dict->SetBooleanWithoutPathExpansion(test_url.host(), false); 336 dict->SetBooleanWithoutPathExpansion(test_url.host(), false);
337 SupervisedUserSettingsService* supervised_user_settings_service = 337 SupervisedUserSettingsService* supervised_user_settings_service =
338 SupervisedUserSettingsServiceFactory::GetForProfile( 338 SupervisedUserSettingsServiceFactory::GetForProfile(
339 browser()->profile()); 339 browser()->profile());
340 auto message_loop_runner = make_scoped_refptr(new content::MessageLoopRunner); 340 auto message_loop_runner = make_scoped_refptr(new content::MessageLoopRunner);
341 InterstitialPageObserver interstitial_observer( 341 InterstitialPageObserver interstitial_observer(
342 web_contents, message_loop_runner->QuitClosure()); 342 web_contents, message_loop_runner->QuitClosure());
343 supervised_user_settings_service->SetLocalSetting( 343 supervised_user_settings_service->SetLocalSetting(
344 supervised_users::kContentPackManualBehaviorHosts, std::move(dict)); 344 supervised_users::kContentPackManualBehaviorHosts, std::move(dict));
345 345
346 scoped_refptr<SupervisedUserURLFilter> filter = 346 const SupervisedUserURLFilter* filter =
347 supervised_user_service_->GetURLFilterForUIThread(); 347 supervised_user_service_->GetURLFilter();
348 ASSERT_EQ(SupervisedUserURLFilter::BLOCK, 348 ASSERT_EQ(SupervisedUserURLFilter::BLOCK,
349 filter->GetFilteringBehaviorForURL(test_url)); 349 filter->GetFilteringBehaviorForURL(test_url));
350 350
351 message_loop_runner->Run(); 351 message_loop_runner->Run();
352 352
353 InterstitialPage* interstitial_page = web_contents->GetInterstitialPage(); 353 InterstitialPage* interstitial_page = web_contents->GetInterstitialPage();
354 ASSERT_TRUE(interstitial_page); 354 ASSERT_TRUE(interstitial_page);
355 355
356 content::WindowedNotificationObserver observer( 356 content::WindowedNotificationObserver observer(
357 content::NOTIFICATION_LOAD_STOP, 357 content::NOTIFICATION_LOAD_STOP,
(...skipping 19 matching lines...) Expand all
377 dict->SetBooleanWithoutPathExpansion(test_url.host(), false); 377 dict->SetBooleanWithoutPathExpansion(test_url.host(), false);
378 SupervisedUserSettingsService* supervised_user_settings_service = 378 SupervisedUserSettingsService* supervised_user_settings_service =
379 SupervisedUserSettingsServiceFactory::GetForProfile( 379 SupervisedUserSettingsServiceFactory::GetForProfile(
380 browser()->profile()); 380 browser()->profile());
381 auto message_loop_runner = make_scoped_refptr(new content::MessageLoopRunner); 381 auto message_loop_runner = make_scoped_refptr(new content::MessageLoopRunner);
382 InterstitialPageObserver observer(web_contents, 382 InterstitialPageObserver observer(web_contents,
383 message_loop_runner->QuitClosure()); 383 message_loop_runner->QuitClosure());
384 supervised_user_settings_service->SetLocalSetting( 384 supervised_user_settings_service->SetLocalSetting(
385 supervised_users::kContentPackManualBehaviorHosts, std::move(dict)); 385 supervised_users::kContentPackManualBehaviorHosts, std::move(dict));
386 386
387 scoped_refptr<SupervisedUserURLFilter> filter = 387 const SupervisedUserURLFilter* filter =
388 supervised_user_service_->GetURLFilterForUIThread(); 388 supervised_user_service_->GetURLFilter();
389 ASSERT_EQ(SupervisedUserURLFilter::BLOCK, 389 ASSERT_EQ(SupervisedUserURLFilter::BLOCK,
390 filter->GetFilteringBehaviorForURL(test_url)); 390 filter->GetFilteringBehaviorForURL(test_url));
391 391
392 message_loop_runner->Run(); 392 message_loop_runner->Run();
393 ASSERT_TRUE(ShownPageIsInterstitial(web_contents)); 393 ASSERT_TRUE(ShownPageIsInterstitial(web_contents));
394 394
395 dict = base::MakeUnique<base::DictionaryValue>(); 395 dict = base::MakeUnique<base::DictionaryValue>();
396 dict->SetBooleanWithoutPathExpansion(test_url.host(), true); 396 dict->SetBooleanWithoutPathExpansion(test_url.host(), true);
397 supervised_user_settings_service->SetLocalSetting( 397 supervised_user_settings_service->SetLocalSetting(
398 supervised_users::kContentPackManualBehaviorHosts, std::move(dict)); 398 supervised_users::kContentPackManualBehaviorHosts, std::move(dict));
(...skipping 20 matching lines...) Expand all
419 419
420 // Set the host as allowed. 420 // Set the host as allowed.
421 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue); 421 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue);
422 dict->SetBooleanWithoutPathExpansion(test_url.host(), true); 422 dict->SetBooleanWithoutPathExpansion(test_url.host(), true);
423 SupervisedUserSettingsService* supervised_user_settings_service = 423 SupervisedUserSettingsService* supervised_user_settings_service =
424 SupervisedUserSettingsServiceFactory::GetForProfile( 424 SupervisedUserSettingsServiceFactory::GetForProfile(
425 browser()->profile()); 425 browser()->profile());
426 supervised_user_settings_service->SetLocalSetting( 426 supervised_user_settings_service->SetLocalSetting(
427 supervised_users::kContentPackManualBehaviorHosts, std::move(dict)); 427 supervised_users::kContentPackManualBehaviorHosts, std::move(dict));
428 428
429 scoped_refptr<SupervisedUserURLFilter> filter = 429 const SupervisedUserURLFilter* filter =
430 supervised_user_service_->GetURLFilterForUIThread(); 430 supervised_user_service_->GetURLFilter();
431 EXPECT_EQ(SupervisedUserURLFilter::ALLOW, 431 EXPECT_EQ(SupervisedUserURLFilter::ALLOW,
432 filter->GetFilteringBehaviorForURL(test_url.GetWithEmptyPath())); 432 filter->GetFilteringBehaviorForURL(test_url.GetWithEmptyPath()));
433 433
434 observer.Wait(); 434 observer.Wait();
435 EXPECT_EQ(test_url, web_contents->GetURL()); 435 EXPECT_EQ(test_url, web_contents->GetURL());
436 } 436 }
437 437
438 } // namespace 438 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698