Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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); | |
|
Bernhard Bauer
2015/08/18 13:09:09
Nit: Broken lines are indentend four spaces.
PEConn2
2015/08/18 14:02:58
Done.
| |
| 255 settings_service->Subscribe(base::Bind( | |
|
Bernhard Bauer
2015/08/18 13:09:09
Hm... any time we open this page, this will subscr
PEConn2
2015/08/18 14:02:58
Done.
| |
| 256 &SupervisedUserInternalsMessageHandler::SendSupervisedUserSettings, | |
| 257 weak_factory_.GetWeakPtr())); | |
| 258 } | |
| 259 | |
| 260 void SupervisedUserInternalsMessageHandler::SendSupervisedUserSettings( | |
| 261 const base::DictionaryValue* settings){ | |
| 262 web_ui()->CallJavascriptFunction( | |
| 263 "chrome.supervised_user_internals.receiveUserSettings", | |
| 264 *settings); | |
| 249 } | 265 } |
| 250 | 266 |
| 251 void SupervisedUserInternalsMessageHandler::OnTryURLResult( | 267 void SupervisedUserInternalsMessageHandler::OnTryURLResult( |
| 252 SupervisedUserURLFilter::FilteringBehavior behavior, | 268 SupervisedUserURLFilter::FilteringBehavior behavior, |
| 253 SupervisedUserURLFilter::FilteringBehaviorReason reason, | 269 SupervisedUserURLFilter::FilteringBehaviorReason reason, |
| 254 bool uncertain) { | 270 bool uncertain) { |
| 255 web_ui()->CallJavascriptFunction( | 271 web_ui()->CallJavascriptFunction( |
| 256 "chrome.supervised_user_internals.receiveTryURLResult", | 272 "chrome.supervised_user_internals.receiveTryURLResult", |
| 257 base::StringValue(FilteringBehaviorToString(behavior, uncertain))); | 273 base::StringValue(FilteringBehaviorToString(behavior, uncertain))); |
| 258 } | 274 } |
| 259 | 275 |
| 260 void SupervisedUserInternalsMessageHandler::OnURLChecked( | 276 void SupervisedUserInternalsMessageHandler::OnURLChecked( |
| 261 const GURL& url, | 277 const GURL& url, |
| 262 SupervisedUserURLFilter::FilteringBehavior behavior, | 278 SupervisedUserURLFilter::FilteringBehavior behavior, |
| 263 SupervisedUserURLFilter::FilteringBehaviorReason reason, | 279 SupervisedUserURLFilter::FilteringBehaviorReason reason, |
| 264 bool uncertain) { | 280 bool uncertain) { |
| 265 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 281 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 266 base::DictionaryValue result; | 282 base::DictionaryValue result; |
| 267 result.SetString("url", url.possibly_invalid_spec()); | 283 result.SetString("url", url.possibly_invalid_spec()); |
| 268 result.SetString("result", FilteringBehaviorToString(behavior, uncertain)); | 284 result.SetString("result", FilteringBehaviorToString(behavior, uncertain)); |
| 269 result.SetString("reason", FilteringBehaviorReasonToString(reason)); | 285 result.SetString("reason", FilteringBehaviorReasonToString(reason)); |
| 270 web_ui()->CallJavascriptFunction( | 286 web_ui()->CallJavascriptFunction( |
| 271 "chrome.supervised_user_internals.receiveFilteringResult", result); | 287 "chrome.supervised_user_internals.receiveFilteringResult", result); |
| 272 } | 288 } |
| OLD | NEW |