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

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

Issue 1878143002: Convert //chrome/browser/supervised_user from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "chrome/browser/chrome_notification_types.h" 10 #include "chrome/browser/chrome_notification_types.h"
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 browser()->tab_strip_model()->GetActiveWebContents(); 106 browser()->tab_strip_model()->GetActiveWebContents();
107 SupervisedUserNavigationObserver::CreateForWebContents(web_contents); 107 SupervisedUserNavigationObserver::CreateForWebContents(web_contents);
108 108
109 Profile* profile = browser()->profile(); 109 Profile* profile = browser()->profile();
110 supervised_user_service_ = 110 supervised_user_service_ =
111 SupervisedUserServiceFactory::GetForProfile(profile); 111 SupervisedUserServiceFactory::GetForProfile(profile);
112 SupervisedUserSettingsService* supervised_user_settings_service = 112 SupervisedUserSettingsService* supervised_user_settings_service =
113 SupervisedUserSettingsServiceFactory::GetForProfile(profile); 113 SupervisedUserSettingsServiceFactory::GetForProfile(profile);
114 supervised_user_settings_service->SetLocalSetting( 114 supervised_user_settings_service->SetLocalSetting(
115 supervised_users::kContentPackDefaultFilteringBehavior, 115 supervised_users::kContentPackDefaultFilteringBehavior,
116 scoped_ptr<base::Value>( 116 std::unique_ptr<base::Value>(
117 new base::FundamentalValue(SupervisedUserURLFilter::BLOCK))); 117 new base::FundamentalValue(SupervisedUserURLFilter::BLOCK)));
118 } 118 }
119 119
120 void SetUpCommandLine(base::CommandLine* command_line) override { 120 void SetUpCommandLine(base::CommandLine* command_line) override {
121 // Enable the test server and remap all URLs to it. 121 // Enable the test server and remap all URLs to it.
122 ASSERT_TRUE(embedded_test_server()->Start()); 122 ASSERT_TRUE(embedded_test_server()->Start());
123 std::string host_port = embedded_test_server()->host_port_pair().ToString(); 123 std::string host_port = embedded_test_server()->host_port_pair().ToString();
124 command_line->AppendSwitchASCII(switches::kHostResolverRules, 124 command_line->AppendSwitchASCII(switches::kHostResolverRules,
125 "MAP *.example.com " + host_port + "," + 125 "MAP *.example.com " + host_port + "," +
126 "MAP *.new-example.com " + host_port + "," + 126 "MAP *.new-example.com " + host_port + "," +
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 227
228 // Tests whether a visit attempt adds a special history entry. 228 // Tests whether a visit attempt adds a special history entry.
229 IN_PROC_BROWSER_TEST_F(SupervisedUserBlockModeTest, 229 IN_PROC_BROWSER_TEST_F(SupervisedUserBlockModeTest,
230 HistoryVisitRecorded) { 230 HistoryVisitRecorded) {
231 GURL allowed_url("http://www.example.com/simple.html"); 231 GURL allowed_url("http://www.example.com/simple.html");
232 232
233 scoped_refptr<SupervisedUserURLFilter> filter = 233 scoped_refptr<SupervisedUserURLFilter> filter =
234 supervised_user_service_->GetURLFilterForUIThread(); 234 supervised_user_service_->GetURLFilterForUIThread();
235 235
236 // Set the host as allowed. 236 // Set the host as allowed.
237 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue); 237 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue);
238 dict->SetBooleanWithoutPathExpansion(allowed_url.host(), true); 238 dict->SetBooleanWithoutPathExpansion(allowed_url.host(), true);
239 SupervisedUserSettingsService* supervised_user_settings_service = 239 SupervisedUserSettingsService* supervised_user_settings_service =
240 SupervisedUserSettingsServiceFactory::GetForProfile( 240 SupervisedUserSettingsServiceFactory::GetForProfile(
241 browser()->profile()); 241 browser()->profile());
242 supervised_user_settings_service->SetLocalSetting( 242 supervised_user_settings_service->SetLocalSetting(
243 supervised_users::kContentPackManualBehaviorHosts, std::move(dict)); 243 supervised_users::kContentPackManualBehaviorHosts, std::move(dict));
244 EXPECT_EQ(SupervisedUserURLFilter::ALLOW, 244 EXPECT_EQ(SupervisedUserURLFilter::ALLOW,
245 filter->GetFilteringBehaviorForURL(allowed_url)); 245 filter->GetFilteringBehaviorForURL(allowed_url));
246 EXPECT_EQ(SupervisedUserURLFilter::ALLOW, 246 EXPECT_EQ(SupervisedUserURLFilter::ALLOW,
247 filter->GetFilteringBehaviorForURL(allowed_url.GetWithEmptyPath())); 247 filter->GetFilteringBehaviorForURL(allowed_url.GetWithEmptyPath()));
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 WebContents* web_contents = 292 WebContents* web_contents =
293 browser()->tab_strip_model()->GetActiveWebContents(); 293 browser()->tab_strip_model()->GetActiveWebContents();
294 294
295 CheckShownPageIsInterstitial(web_contents); 295 CheckShownPageIsInterstitial(web_contents);
296 296
297 content::WindowedNotificationObserver observer( 297 content::WindowedNotificationObserver observer(
298 content::NOTIFICATION_LOAD_STOP, 298 content::NOTIFICATION_LOAD_STOP,
299 content::NotificationService::AllSources()); 299 content::NotificationService::AllSources());
300 300
301 // Set the host as allowed. 301 // Set the host as allowed.
302 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue); 302 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue);
303 dict->SetBooleanWithoutPathExpansion(test_url.host(), true); 303 dict->SetBooleanWithoutPathExpansion(test_url.host(), true);
304 SupervisedUserSettingsService* supervised_user_settings_service = 304 SupervisedUserSettingsService* supervised_user_settings_service =
305 SupervisedUserSettingsServiceFactory::GetForProfile( 305 SupervisedUserSettingsServiceFactory::GetForProfile(
306 browser()->profile()); 306 browser()->profile());
307 supervised_user_settings_service->SetLocalSetting( 307 supervised_user_settings_service->SetLocalSetting(
308 supervised_users::kContentPackManualBehaviorHosts, std::move(dict)); 308 supervised_users::kContentPackManualBehaviorHosts, std::move(dict));
309 309
310 scoped_refptr<SupervisedUserURLFilter> filter = 310 scoped_refptr<SupervisedUserURLFilter> filter =
311 supervised_user_service_->GetURLFilterForUIThread(); 311 supervised_user_service_->GetURLFilterForUIThread();
312 EXPECT_EQ(SupervisedUserURLFilter::ALLOW, 312 EXPECT_EQ(SupervisedUserURLFilter::ALLOW,
313 filter->GetFilteringBehaviorForURL(test_url.GetWithEmptyPath())); 313 filter->GetFilteringBehaviorForURL(test_url.GetWithEmptyPath()));
314 314
315 observer.Wait(); 315 observer.Wait();
316 EXPECT_EQ(test_url, web_contents->GetURL()); 316 EXPECT_EQ(test_url, web_contents->GetURL());
317 } 317 }
318 318
319 } // namespace 319 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698