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

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

Issue 1300643002: Added user settings to chrome://supervised-user-internals. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 1st response to comments Created 5 years, 4 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
« no previous file with comments | « chrome/browser/ui/webui/supervised_user_internals_message_handler.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/bind.h" 7 #include "base/bind.h"
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
11 #include "chrome/browser/supervised_user/supervised_user_service.h" 11 #include "chrome/browser/supervised_user/supervised_user_service.h"
12 #include "chrome/browser/supervised_user/supervised_user_service_factory.h" 12 #include "chrome/browser/supervised_user/supervised_user_service_factory.h"
13 #include "chrome/browser/supervised_user/supervised_user_settings_service.h"
14 #include "chrome/browser/supervised_user/supervised_user_settings_service_factor y.h"
13 #include "components/url_formatter/url_fixer.h" 15 #include "components/url_formatter/url_fixer.h"
14 #include "content/public/browser/browser_thread.h" 16 #include "content/public/browser/browser_thread.h"
15 #include "content/public/browser/web_ui.h" 17 #include "content/public/browser/web_ui.h"
16 18
17 using content::BrowserThread; 19 using content::BrowserThread;
18 20
19 namespace { 21 namespace {
20 22
21 // Creates a 'section' for display on about:supervised-user-internals, 23 // Creates a 'section' for display on about:supervised-user-internals,
22 // consisting of a title and a list of fields. Returns a pointer to the new 24 // consisting of a title and a list of fields. Returns a pointer to the new
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 AddSectionEntry(section_filter, "Online checks active", 241 AddSectionEntry(section_filter, "Online checks active",
240 filter->HasAsyncURLChecker()); 242 filter->HasAsyncURLChecker());
241 AddSectionEntry(section_filter, "Default behavior", 243 AddSectionEntry(section_filter, "Default behavior",
242 FilteringBehaviorToString( 244 FilteringBehaviorToString(
243 filter->GetDefaultFilteringBehavior())); 245 filter->GetDefaultFilteringBehavior()));
244 246
245 base::DictionaryValue result; 247 base::DictionaryValue result;
246 result.Set("sections", section_list.Pass()); 248 result.Set("sections", section_list.Pass());
247 web_ui()->CallJavascriptFunction( 249 web_ui()->CallJavascriptFunction(
248 "chrome.supervised_user_internals.receiveBasicInfo", result); 250 "chrome.supervised_user_internals.receiveBasicInfo", result);
251
252 // Trigger retrieval of the user settings
253 SupervisedUserSettingsService* settings_service =
254 SupervisedUserSettingsServiceFactory::GetForProfile(profile);
255 // TODO: Change interface to SupervisedUserSettingsService to allow
Bernhard Bauer 2015/08/18 15:39:23 Nit: Write TODOs in the form TODO(ldap), so it's e
256 // unsubscription, otherwise the subscription remains after this
257 // object is destroyed resulting in a small memory leak.
258 settings_service->Subscribe(base::Bind(
259 &SupervisedUserInternalsMessageHandler::SendSupervisedUserSettings,
260 weak_factory_.GetWeakPtr()));
261 }
262
263 void SupervisedUserInternalsMessageHandler::SendSupervisedUserSettings(
264 const base::DictionaryValue* settings){
265 web_ui()->CallJavascriptFunction(
266 "chrome.supervised_user_internals.receiveUserSettings",
267 *settings);
249 } 268 }
250 269
251 void SupervisedUserInternalsMessageHandler::OnTryURLResult( 270 void SupervisedUserInternalsMessageHandler::OnTryURLResult(
252 SupervisedUserURLFilter::FilteringBehavior behavior, 271 SupervisedUserURLFilter::FilteringBehavior behavior,
253 SupervisedUserURLFilter::FilteringBehaviorReason reason, 272 SupervisedUserURLFilter::FilteringBehaviorReason reason,
254 bool uncertain) { 273 bool uncertain) {
255 web_ui()->CallJavascriptFunction( 274 web_ui()->CallJavascriptFunction(
256 "chrome.supervised_user_internals.receiveTryURLResult", 275 "chrome.supervised_user_internals.receiveTryURLResult",
257 base::StringValue(FilteringBehaviorToString(behavior, uncertain))); 276 base::StringValue(FilteringBehaviorToString(behavior, uncertain)));
258 } 277 }
259 278
260 void SupervisedUserInternalsMessageHandler::OnURLChecked( 279 void SupervisedUserInternalsMessageHandler::OnURLChecked(
261 const GURL& url, 280 const GURL& url,
262 SupervisedUserURLFilter::FilteringBehavior behavior, 281 SupervisedUserURLFilter::FilteringBehavior behavior,
263 SupervisedUserURLFilter::FilteringBehaviorReason reason, 282 SupervisedUserURLFilter::FilteringBehaviorReason reason,
264 bool uncertain) { 283 bool uncertain) {
265 DCHECK_CURRENTLY_ON(BrowserThread::UI); 284 DCHECK_CURRENTLY_ON(BrowserThread::UI);
266 base::DictionaryValue result; 285 base::DictionaryValue result;
267 result.SetString("url", url.possibly_invalid_spec()); 286 result.SetString("url", url.possibly_invalid_spec());
268 result.SetString("result", FilteringBehaviorToString(behavior, uncertain)); 287 result.SetString("result", FilteringBehaviorToString(behavior, uncertain));
269 result.SetString("reason", FilteringBehaviorReasonToString(reason)); 288 result.SetString("reason", FilteringBehaviorReasonToString(reason));
270 web_ui()->CallJavascriptFunction( 289 web_ui()->CallJavascriptFunction(
271 "chrome.supervised_user_internals.receiveFilteringResult", result); 290 "chrome.supervised_user_internals.receiveFilteringResult", result);
272 } 291 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/supervised_user_internals_message_handler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698