| OLD | NEW |
| 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> |
| 6 |
| 5 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 6 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
| 7 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 8 #include "base/values.h" | 10 #include "base/values.h" |
| 9 #include "chrome/browser/chrome_notification_types.h" | 11 #include "chrome/browser/chrome_notification_types.h" |
| 10 #include "chrome/browser/history/history_service_factory.h" | 12 #include "chrome/browser/history/history_service_factory.h" |
| 11 #include "chrome/browser/infobars/infobar_service.h" | 13 #include "chrome/browser/infobars/infobar_service.h" |
| 12 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 13 #include "chrome/browser/supervised_user/supervised_user_constants.h" | 15 #include "chrome/browser/supervised_user/supervised_user_constants.h" |
| 14 #include "chrome/browser/supervised_user/supervised_user_interstitial.h" | 16 #include "chrome/browser/supervised_user/supervised_user_interstitial.h" |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 scoped_refptr<SupervisedUserURLFilter> filter = | 233 scoped_refptr<SupervisedUserURLFilter> filter = |
| 232 supervised_user_service_->GetURLFilterForUIThread(); | 234 supervised_user_service_->GetURLFilterForUIThread(); |
| 233 | 235 |
| 234 // Set the host as allowed. | 236 // Set the host as allowed. |
| 235 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue); | 237 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue); |
| 236 dict->SetBooleanWithoutPathExpansion(allowed_url.host(), true); | 238 dict->SetBooleanWithoutPathExpansion(allowed_url.host(), true); |
| 237 SupervisedUserSettingsService* supervised_user_settings_service = | 239 SupervisedUserSettingsService* supervised_user_settings_service = |
| 238 SupervisedUserSettingsServiceFactory::GetForProfile( | 240 SupervisedUserSettingsServiceFactory::GetForProfile( |
| 239 browser()->profile()); | 241 browser()->profile()); |
| 240 supervised_user_settings_service->SetLocalSetting( | 242 supervised_user_settings_service->SetLocalSetting( |
| 241 supervised_users::kContentPackManualBehaviorHosts, dict.Pass()); | 243 supervised_users::kContentPackManualBehaviorHosts, std::move(dict)); |
| 242 EXPECT_EQ(SupervisedUserURLFilter::ALLOW, | 244 EXPECT_EQ(SupervisedUserURLFilter::ALLOW, |
| 243 filter->GetFilteringBehaviorForURL(allowed_url)); | 245 filter->GetFilteringBehaviorForURL(allowed_url)); |
| 244 EXPECT_EQ(SupervisedUserURLFilter::ALLOW, | 246 EXPECT_EQ(SupervisedUserURLFilter::ALLOW, |
| 245 filter->GetFilteringBehaviorForURL(allowed_url.GetWithEmptyPath())); | 247 filter->GetFilteringBehaviorForURL(allowed_url.GetWithEmptyPath())); |
| 246 | 248 |
| 247 ui_test_utils::NavigateToURL(browser(), allowed_url); | 249 ui_test_utils::NavigateToURL(browser(), allowed_url); |
| 248 | 250 |
| 249 // Navigate to it and check that we don't get an interstitial. | 251 // Navigate to it and check that we don't get an interstitial. |
| 250 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); | 252 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); |
| 251 CheckShownPageIsNotInterstitial(tab); | 253 CheckShownPageIsNotInterstitial(tab); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 content::NOTIFICATION_LOAD_STOP, | 298 content::NOTIFICATION_LOAD_STOP, |
| 297 content::NotificationService::AllSources()); | 299 content::NotificationService::AllSources()); |
| 298 | 300 |
| 299 // Set the host as allowed. | 301 // Set the host as allowed. |
| 300 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue); | 302 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue); |
| 301 dict->SetBooleanWithoutPathExpansion(test_url.host(), true); | 303 dict->SetBooleanWithoutPathExpansion(test_url.host(), true); |
| 302 SupervisedUserSettingsService* supervised_user_settings_service = | 304 SupervisedUserSettingsService* supervised_user_settings_service = |
| 303 SupervisedUserSettingsServiceFactory::GetForProfile( | 305 SupervisedUserSettingsServiceFactory::GetForProfile( |
| 304 browser()->profile()); | 306 browser()->profile()); |
| 305 supervised_user_settings_service->SetLocalSetting( | 307 supervised_user_settings_service->SetLocalSetting( |
| 306 supervised_users::kContentPackManualBehaviorHosts, dict.Pass()); | 308 supervised_users::kContentPackManualBehaviorHosts, std::move(dict)); |
| 307 | 309 |
| 308 scoped_refptr<SupervisedUserURLFilter> filter = | 310 scoped_refptr<SupervisedUserURLFilter> filter = |
| 309 supervised_user_service_->GetURLFilterForUIThread(); | 311 supervised_user_service_->GetURLFilterForUIThread(); |
| 310 EXPECT_EQ(SupervisedUserURLFilter::ALLOW, | 312 EXPECT_EQ(SupervisedUserURLFilter::ALLOW, |
| 311 filter->GetFilteringBehaviorForURL(test_url.GetWithEmptyPath())); | 313 filter->GetFilteringBehaviorForURL(test_url.GetWithEmptyPath())); |
| 312 | 314 |
| 313 observer.Wait(); | 315 observer.Wait(); |
| 314 EXPECT_EQ(test_url, web_contents->GetURL()); | 316 EXPECT_EQ(test_url, web_contents->GetURL()); |
| 315 } | 317 } |
| 316 | 318 |
| 317 } // namespace | 319 } // namespace |
| OLD | NEW |