| OLD | NEW |
| 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/prefs/pref_service.h" | 6 #include "base/prefs/pref_service.h" |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 #include "chrome/browser/chrome_notification_types.h" | 9 #include "chrome/browser/chrome_notification_types.h" |
| 10 #include "chrome/browser/common/cancelable_request.h" | 10 #include "chrome/browser/common/cancelable_request.h" |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 | 175 |
| 176 CheckShownPageIsNotInterstitial(tab); | 176 CheckShownPageIsNotInterstitial(tab); |
| 177 } | 177 } |
| 178 | 178 |
| 179 // Tests whether a visit attempt adds a special history entry. | 179 // Tests whether a visit attempt adds a special history entry. |
| 180 IN_PROC_BROWSER_TEST_F(ManagedModeBlockModeTest, | 180 IN_PROC_BROWSER_TEST_F(ManagedModeBlockModeTest, |
| 181 HistoryVisitRecorded) { | 181 HistoryVisitRecorded) { |
| 182 GURL allowed_url("http://www.example.com/files/simple.html"); | 182 GURL allowed_url("http://www.example.com/files/simple.html"); |
| 183 | 183 |
| 184 // Set the host as allowed. | 184 // Set the host as allowed. |
| 185 scoped_ptr<DictionaryValue> dict(new DictionaryValue); | 185 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue); |
| 186 dict->SetBooleanWithoutPathExpansion(allowed_url.host(), true); | 186 dict->SetBooleanWithoutPathExpansion(allowed_url.host(), true); |
| 187 ManagedUserSettingsService* managed_user_settings_service = | 187 ManagedUserSettingsService* managed_user_settings_service = |
| 188 ManagedUserSettingsServiceFactory::GetForProfile( | 188 ManagedUserSettingsServiceFactory::GetForProfile( |
| 189 browser()->profile()); | 189 browser()->profile()); |
| 190 managed_user_settings_service->SetLocalSettingForTesting( | 190 managed_user_settings_service->SetLocalSettingForTesting( |
| 191 managed_users::kContentPackManualBehaviorHosts, dict.PassAs<Value>()); | 191 managed_users::kContentPackManualBehaviorHosts, |
| 192 dict.PassAs<base::Value>()); |
| 192 EXPECT_EQ( | 193 EXPECT_EQ( |
| 193 ManagedUserService::MANUAL_ALLOW, | 194 ManagedUserService::MANUAL_ALLOW, |
| 194 managed_user_service_->GetManualBehaviorForHost(allowed_url.host())); | 195 managed_user_service_->GetManualBehaviorForHost(allowed_url.host())); |
| 195 | 196 |
| 196 ui_test_utils::NavigateToURL(browser(), allowed_url); | 197 ui_test_utils::NavigateToURL(browser(), allowed_url); |
| 197 | 198 |
| 198 // Navigate to it and check that we don't get an interstitial. | 199 // Navigate to it and check that we don't get an interstitial. |
| 199 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); | 200 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); |
| 200 CheckShownPageIsNotInterstitial(tab); | 201 CheckShownPageIsNotInterstitial(tab); |
| 201 | 202 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 WebContents* web_contents = | 240 WebContents* web_contents = |
| 240 browser()->tab_strip_model()->GetActiveWebContents(); | 241 browser()->tab_strip_model()->GetActiveWebContents(); |
| 241 | 242 |
| 242 CheckShownPageIsInterstitial(web_contents); | 243 CheckShownPageIsInterstitial(web_contents); |
| 243 | 244 |
| 244 content::WindowedNotificationObserver observer( | 245 content::WindowedNotificationObserver observer( |
| 245 content::NOTIFICATION_LOAD_STOP, | 246 content::NOTIFICATION_LOAD_STOP, |
| 246 content::NotificationService::AllSources()); | 247 content::NotificationService::AllSources()); |
| 247 | 248 |
| 248 // Set the host as allowed. | 249 // Set the host as allowed. |
| 249 scoped_ptr<DictionaryValue> dict(new DictionaryValue); | 250 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue); |
| 250 dict->SetBooleanWithoutPathExpansion(test_url.host(), true); | 251 dict->SetBooleanWithoutPathExpansion(test_url.host(), true); |
| 251 ManagedUserSettingsService* managed_user_settings_service = | 252 ManagedUserSettingsService* managed_user_settings_service = |
| 252 ManagedUserSettingsServiceFactory::GetForProfile( | 253 ManagedUserSettingsServiceFactory::GetForProfile( |
| 253 browser()->profile()); | 254 browser()->profile()); |
| 254 managed_user_settings_service->SetLocalSettingForTesting( | 255 managed_user_settings_service->SetLocalSettingForTesting( |
| 255 managed_users::kContentPackManualBehaviorHosts, dict.PassAs<Value>()); | 256 managed_users::kContentPackManualBehaviorHosts, |
| 257 dict.PassAs<base::Value>()); |
| 256 EXPECT_EQ( | 258 EXPECT_EQ( |
| 257 ManagedUserService::MANUAL_ALLOW, | 259 ManagedUserService::MANUAL_ALLOW, |
| 258 managed_user_service_->GetManualBehaviorForHost(test_url.host())); | 260 managed_user_service_->GetManualBehaviorForHost(test_url.host())); |
| 259 | 261 |
| 260 observer.Wait(); | 262 observer.Wait(); |
| 261 EXPECT_EQ(test_url, web_contents->GetURL()); | 263 EXPECT_EQ(test_url, web_contents->GetURL()); |
| 262 } | 264 } |
| 263 | 265 |
| 264 } // namespace | 266 } // namespace |
| OLD | NEW |