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

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

Issue 697693004: Supervised users: if history recording is off, allow incognito and deleting history (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix browser_tests Created 6 years, 1 month 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 "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/history/history_service_factory.h" 10 #include "chrome/browser/history/history_service_factory.h"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 // was not supervised when the browser was created. 101 // was not supervised when the browser was created.
102 content::WebContents* web_contents = 102 content::WebContents* web_contents =
103 browser()->tab_strip_model()->GetActiveWebContents(); 103 browser()->tab_strip_model()->GetActiveWebContents();
104 SupervisedUserNavigationObserver::CreateForWebContents(web_contents); 104 SupervisedUserNavigationObserver::CreateForWebContents(web_contents);
105 105
106 Profile* profile = browser()->profile(); 106 Profile* profile = browser()->profile();
107 supervised_user_service_ = 107 supervised_user_service_ =
108 SupervisedUserServiceFactory::GetForProfile(profile); 108 SupervisedUserServiceFactory::GetForProfile(profile);
109 SupervisedUserSettingsService* supervised_user_settings_service = 109 SupervisedUserSettingsService* supervised_user_settings_service =
110 SupervisedUserSettingsServiceFactory::GetForProfile(profile); 110 SupervisedUserSettingsServiceFactory::GetForProfile(profile);
111 supervised_user_settings_service->SetLocalSettingForTesting( 111 supervised_user_settings_service->SetLocalSetting(
112 supervised_users::kContentPackDefaultFilteringBehavior, 112 supervised_users::kContentPackDefaultFilteringBehavior,
113 scoped_ptr<base::Value>( 113 scoped_ptr<base::Value>(
114 new base::FundamentalValue(SupervisedUserURLFilter::BLOCK))); 114 new base::FundamentalValue(SupervisedUserURLFilter::BLOCK)));
115 } 115 }
116 116
117 void SetUpCommandLine(CommandLine* command_line) override { 117 void SetUpCommandLine(CommandLine* command_line) override {
118 // Enable the test server and remap all URLs to it. 118 // Enable the test server and remap all URLs to it.
119 ASSERT_TRUE(test_server()->Start()); 119 ASSERT_TRUE(test_server()->Start());
120 std::string host_port = test_server()->host_port_pair().ToString(); 120 std::string host_port = test_server()->host_port_pair().ToString();
121 command_line->AppendSwitchASCII(switches::kHostResolverRules, 121 command_line->AppendSwitchASCII(switches::kHostResolverRules,
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 229
230 scoped_refptr<SupervisedUserURLFilter> filter = 230 scoped_refptr<SupervisedUserURLFilter> filter =
231 supervised_user_service_->GetURLFilterForUIThread(); 231 supervised_user_service_->GetURLFilterForUIThread();
232 232
233 // Set the host as allowed. 233 // Set the host as allowed.
234 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue); 234 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue);
235 dict->SetBooleanWithoutPathExpansion(allowed_url.host(), true); 235 dict->SetBooleanWithoutPathExpansion(allowed_url.host(), true);
236 SupervisedUserSettingsService* supervised_user_settings_service = 236 SupervisedUserSettingsService* supervised_user_settings_service =
237 SupervisedUserSettingsServiceFactory::GetForProfile( 237 SupervisedUserSettingsServiceFactory::GetForProfile(
238 browser()->profile()); 238 browser()->profile());
239 supervised_user_settings_service->SetLocalSettingForTesting( 239 supervised_user_settings_service->SetLocalSetting(
240 supervised_users::kContentPackManualBehaviorHosts, dict.Pass()); 240 supervised_users::kContentPackManualBehaviorHosts, dict.Pass());
241 EXPECT_EQ(SupervisedUserURLFilter::ALLOW, 241 EXPECT_EQ(SupervisedUserURLFilter::ALLOW,
242 filter->GetFilteringBehaviorForURL(allowed_url)); 242 filter->GetFilteringBehaviorForURL(allowed_url));
243 EXPECT_EQ(SupervisedUserURLFilter::ALLOW, 243 EXPECT_EQ(SupervisedUserURLFilter::ALLOW,
244 filter->GetFilteringBehaviorForURL(allowed_url.GetWithEmptyPath())); 244 filter->GetFilteringBehaviorForURL(allowed_url.GetWithEmptyPath()));
245 245
246 ui_test_utils::NavigateToURL(browser(), allowed_url); 246 ui_test_utils::NavigateToURL(browser(), allowed_url);
247 247
248 // Navigate to it and check that we don't get an interstitial. 248 // Navigate to it and check that we don't get an interstitial.
249 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); 249 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents();
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 content::WindowedNotificationObserver observer( 293 content::WindowedNotificationObserver observer(
294 content::NOTIFICATION_LOAD_STOP, 294 content::NOTIFICATION_LOAD_STOP,
295 content::NotificationService::AllSources()); 295 content::NotificationService::AllSources());
296 296
297 // Set the host as allowed. 297 // Set the host as allowed.
298 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue); 298 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue);
299 dict->SetBooleanWithoutPathExpansion(test_url.host(), true); 299 dict->SetBooleanWithoutPathExpansion(test_url.host(), true);
300 SupervisedUserSettingsService* supervised_user_settings_service = 300 SupervisedUserSettingsService* supervised_user_settings_service =
301 SupervisedUserSettingsServiceFactory::GetForProfile( 301 SupervisedUserSettingsServiceFactory::GetForProfile(
302 browser()->profile()); 302 browser()->profile());
303 supervised_user_settings_service->SetLocalSettingForTesting( 303 supervised_user_settings_service->SetLocalSetting(
304 supervised_users::kContentPackManualBehaviorHosts, dict.Pass()); 304 supervised_users::kContentPackManualBehaviorHosts, dict.Pass());
305 305
306 scoped_refptr<SupervisedUserURLFilter> filter = 306 scoped_refptr<SupervisedUserURLFilter> filter =
307 supervised_user_service_->GetURLFilterForUIThread(); 307 supervised_user_service_->GetURLFilterForUIThread();
308 EXPECT_EQ(SupervisedUserURLFilter::ALLOW, 308 EXPECT_EQ(SupervisedUserURLFilter::ALLOW,
309 filter->GetFilteringBehaviorForURL(test_url.GetWithEmptyPath())); 309 filter->GetFilteringBehaviorForURL(test_url.GetWithEmptyPath()));
310 310
311 observer.Wait(); 311 observer.Wait();
312 EXPECT_EQ(test_url, web_contents->GetURL()); 312 EXPECT_EQ(test_url, web_contents->GetURL());
313 } 313 }
314 314
315 } // namespace 315 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698