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

Side by Side Diff: chrome/browser/ui/webui/supervised_user_internals_message_handler.cc

Issue 1865213004: Convert //chrome/browser/ui from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "chrome/browser/ui/webui/supervised_user_internals_message_handler.h" 5 #include "chrome/browser/ui/webui/supervised_user_internals_message_handler.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 19 matching lines...) Expand all
30 using content::BrowserThread; 30 using content::BrowserThread;
31 31
32 namespace { 32 namespace {
33 33
34 // Creates a 'section' for display on about:supervised-user-internals, 34 // Creates a 'section' for display on about:supervised-user-internals,
35 // consisting of a title and a list of fields. Returns a pointer to the new 35 // consisting of a title and a list of fields. Returns a pointer to the new
36 // section's contents, for use with |AddSectionEntry| below. Note that 36 // section's contents, for use with |AddSectionEntry| below. Note that
37 // |parent_list|, not the caller, owns the newly added section. 37 // |parent_list|, not the caller, owns the newly added section.
38 base::ListValue* AddSection(base::ListValue* parent_list, 38 base::ListValue* AddSection(base::ListValue* parent_list,
39 const std::string& title) { 39 const std::string& title) {
40 scoped_ptr<base::DictionaryValue> section(new base::DictionaryValue); 40 std::unique_ptr<base::DictionaryValue> section(new base::DictionaryValue);
41 scoped_ptr<base::ListValue> section_contents(new base::ListValue); 41 std::unique_ptr<base::ListValue> section_contents(new base::ListValue);
42 section->SetString("title", title); 42 section->SetString("title", title);
43 // Grab a raw pointer to the result before |Pass()|ing it on. 43 // Grab a raw pointer to the result before |Pass()|ing it on.
44 base::ListValue* result = section_contents.get(); 44 base::ListValue* result = section_contents.get();
45 section->Set("data", std::move(section_contents)); 45 section->Set("data", std::move(section_contents));
46 parent_list->Append(std::move(section)); 46 parent_list->Append(std::move(section));
47 return result; 47 return result;
48 } 48 }
49 49
50 // Adds a bool entry to a section (created with |AddSection| above). 50 // Adds a bool entry to a section (created with |AddSection| above).
51 void AddSectionEntry(base::ListValue* section_list, 51 void AddSectionEntry(base::ListValue* section_list,
52 const std::string& name, 52 const std::string& name,
53 bool value) { 53 bool value) {
54 scoped_ptr<base::DictionaryValue> entry(new base::DictionaryValue); 54 std::unique_ptr<base::DictionaryValue> entry(new base::DictionaryValue);
55 entry->SetString("stat_name", name); 55 entry->SetString("stat_name", name);
56 entry->SetBoolean("stat_value", value); 56 entry->SetBoolean("stat_value", value);
57 entry->SetBoolean("is_valid", true); 57 entry->SetBoolean("is_valid", true);
58 section_list->Append(std::move(entry)); 58 section_list->Append(std::move(entry));
59 } 59 }
60 60
61 // Adds a string entry to a section (created with |AddSection| above). 61 // Adds a string entry to a section (created with |AddSection| above).
62 void AddSectionEntry(base::ListValue* section_list, 62 void AddSectionEntry(base::ListValue* section_list,
63 const std::string& name, 63 const std::string& name,
64 const std::string& value) { 64 const std::string& value) {
65 scoped_ptr<base::DictionaryValue> entry(new base::DictionaryValue); 65 std::unique_ptr<base::DictionaryValue> entry(new base::DictionaryValue);
66 entry->SetString("stat_name", name); 66 entry->SetString("stat_name", name);
67 entry->SetString("stat_value", value); 67 entry->SetString("stat_value", value);
68 entry->SetBoolean("is_valid", true); 68 entry->SetBoolean("is_valid", true);
69 section_list->Append(std::move(entry)); 69 section_list->Append(std::move(entry));
70 } 70 }
71 71
72 std::string FilteringBehaviorToString( 72 std::string FilteringBehaviorToString(
73 SupervisedUserURLFilter::FilteringBehavior behavior) { 73 SupervisedUserURLFilter::FilteringBehavior behavior) {
74 switch (behavior) { 74 switch (behavior) {
75 case SupervisedUserURLFilter::ALLOW: 75 case SupervisedUserURLFilter::ALLOW:
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 SupervisedUserURLFilter* filter = 230 SupervisedUserURLFilter* filter =
231 GetSupervisedUserService()->GetURLFilterForUIThread(); 231 GetSupervisedUserService()->GetURLFilterForUIThread();
232 std::map<std::string, base::string16> whitelists = 232 std::map<std::string, base::string16> whitelists =
233 filter->GetMatchingWhitelistTitles(url); 233 filter->GetMatchingWhitelistTitles(url);
234 filter->GetFilteringBehaviorForURLWithAsyncChecks( 234 filter->GetFilteringBehaviorForURLWithAsyncChecks(
235 url, base::Bind(&SupervisedUserInternalsMessageHandler::OnTryURLResult, 235 url, base::Bind(&SupervisedUserInternalsMessageHandler::OnTryURLResult,
236 weak_factory_.GetWeakPtr(), whitelists)); 236 weak_factory_.GetWeakPtr(), whitelists));
237 } 237 }
238 238
239 void SupervisedUserInternalsMessageHandler::SendBasicInfo() { 239 void SupervisedUserInternalsMessageHandler::SendBasicInfo() {
240 scoped_ptr<base::ListValue> section_list(new base::ListValue); 240 std::unique_ptr<base::ListValue> section_list(new base::ListValue);
241 241
242 base::ListValue* section_general = AddSection(section_list.get(), "General"); 242 base::ListValue* section_general = AddSection(section_list.get(), "General");
243 AddSectionEntry(section_general, "Chrome version", 243 AddSectionEntry(section_general, "Chrome version",
244 chrome::GetVersionString()); 244 chrome::GetVersionString());
245 AddSectionEntry(section_general, "Child detection enabled", 245 AddSectionEntry(section_general, "Child detection enabled",
246 ChildAccountService::IsChildAccountDetectionEnabled()); 246 ChildAccountService::IsChildAccountDetectionEnabled());
247 247
248 Profile* profile = Profile::FromWebUI(web_ui()); 248 Profile* profile = Profile::FromWebUI(web_ui());
249 249
250 base::ListValue* section_profile = AddSection(section_list.get(), "Profile"); 250 base::ListValue* section_profile = AddSection(section_list.get(), "Profile");
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 supervised_user_error_page::FilteringBehaviorReason reason, 330 supervised_user_error_page::FilteringBehaviorReason reason,
331 bool uncertain) { 331 bool uncertain) {
332 DCHECK_CURRENTLY_ON(BrowserThread::UI); 332 DCHECK_CURRENTLY_ON(BrowserThread::UI);
333 base::DictionaryValue result; 333 base::DictionaryValue result;
334 result.SetString("url", url.possibly_invalid_spec()); 334 result.SetString("url", url.possibly_invalid_spec());
335 result.SetString("result", FilteringBehaviorToString(behavior, uncertain)); 335 result.SetString("result", FilteringBehaviorToString(behavior, uncertain));
336 result.SetString("reason", FilteringBehaviorReasonToString(reason)); 336 result.SetString("reason", FilteringBehaviorReasonToString(reason));
337 web_ui()->CallJavascriptFunction( 337 web_ui()->CallJavascriptFunction(
338 "chrome.supervised_user_internals.receiveFilteringResult", result); 338 "chrome.supervised_user_internals.receiveFilteringResult", result);
339 } 339 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698