OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/options/core_options_handler.h" | 5 #include "chrome/browser/ui/webui/options/core_options_handler.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <utility> | 10 #include <utility> |
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 std::unique_ptr<base::Value> value) { | 355 std::unique_ptr<base::Value> value) { |
356 std::pair<PreferenceCallbackMap::const_iterator, | 356 std::pair<PreferenceCallbackMap::const_iterator, |
357 PreferenceCallbackMap::const_iterator> range = | 357 PreferenceCallbackMap::const_iterator> range = |
358 pref_callback_map_.equal_range(name); | 358 pref_callback_map_.equal_range(name); |
359 base::ListValue result_value; | 359 base::ListValue result_value; |
360 result_value.AppendString(name); | 360 result_value.AppendString(name); |
361 result_value.Append(value.release()); | 361 result_value.Append(value.release()); |
362 for (PreferenceCallbackMap::const_iterator iter = range.first; | 362 for (PreferenceCallbackMap::const_iterator iter = range.first; |
363 iter != range.second; ++iter) { | 363 iter != range.second; ++iter) { |
364 const std::string& callback_function = iter->second; | 364 const std::string& callback_function = iter->second; |
365 web_ui()->CallJavascriptFunction(callback_function, result_value); | 365 web_ui()->CallJavascriptFunctionUnsafe(callback_function, result_value); |
366 } | 366 } |
367 } | 367 } |
368 | 368 |
369 base::Value* CoreOptionsHandler::CreateValueForPref( | 369 base::Value* CoreOptionsHandler::CreateValueForPref( |
370 const std::string& pref_name, | 370 const std::string& pref_name, |
371 const std::string& controlling_pref_name) { | 371 const std::string& controlling_pref_name) { |
372 const PrefService* pref_service = FindServiceForPref(pref_name); | 372 const PrefService* pref_service = FindServiceForPref(pref_name); |
373 const PrefService::Preference* pref = | 373 const PrefService::Preference* pref = |
374 pref_service->FindPreference(pref_name); | 374 pref_service->FindPreference(pref_name); |
375 if (!pref) { | 375 if (!pref) { |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
464 | 464 |
465 if (!list_member->IsType(base::Value::TYPE_STRING)) | 465 if (!list_member->IsType(base::Value::TYPE_STRING)) |
466 continue; | 466 continue; |
467 | 467 |
468 std::string pref_name; | 468 std::string pref_name; |
469 if (!list_member->GetAsString(&pref_name)) | 469 if (!list_member->GetAsString(&pref_name)) |
470 continue; | 470 continue; |
471 | 471 |
472 result_value.Set(pref_name, FetchPref(pref_name)); | 472 result_value.Set(pref_name, FetchPref(pref_name)); |
473 } | 473 } |
474 web_ui()->CallJavascriptFunction(base::UTF16ToASCII(callback_function), | 474 web_ui()->CallJavascriptFunctionUnsafe(base::UTF16ToASCII(callback_function), |
475 result_value); | 475 result_value); |
476 } | 476 } |
477 | 477 |
478 void CoreOptionsHandler::HandleObservePrefs(const base::ListValue* args) { | 478 void CoreOptionsHandler::HandleObservePrefs(const base::ListValue* args) { |
479 // First param is name is JS callback function name, the rest are pref | 479 // First param is name is JS callback function name, the rest are pref |
480 // identifiers that we are observing. | 480 // identifiers that we are observing. |
481 DCHECK_GE(static_cast<int>(args->GetSize()), 2); | 481 DCHECK_GE(static_cast<int>(args->GetSize()), 2); |
482 | 482 |
483 // Get preference change callback function name. | 483 // Get preference change callback function name. |
484 std::string callback_func_name; | 484 std::string callback_func_name; |
485 if (!args->GetString(0, &callback_func_name)) | 485 if (!args->GetString(0, &callback_func_name)) |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
641 extension_service->DisableExtension( | 641 extension_service->DisableExtension( |
642 extension_id, extensions::Extension::DISABLE_USER_ACTION); | 642 extension_id, extensions::Extension::DISABLE_USER_ACTION); |
643 } else { | 643 } else { |
644 NOTREACHED(); | 644 NOTREACHED(); |
645 } | 645 } |
646 } | 646 } |
647 | 647 |
648 void CoreOptionsHandler::UpdateClearPluginLSOData() { | 648 void CoreOptionsHandler::UpdateClearPluginLSOData() { |
649 base::FundamentalValue enabled( | 649 base::FundamentalValue enabled( |
650 plugin_status_pref_setter_.IsClearPluginLSODataEnabled()); | 650 plugin_status_pref_setter_.IsClearPluginLSODataEnabled()); |
651 web_ui()->CallJavascriptFunction( | 651 web_ui()->CallJavascriptFunctionUnsafe( |
652 "options.OptionsPage.setClearPluginLSODataEnabled", enabled); | 652 "options.OptionsPage.setClearPluginLSODataEnabled", enabled); |
653 } | 653 } |
654 | 654 |
655 void CoreOptionsHandler::UpdatePepperFlashSettingsEnabled() { | 655 void CoreOptionsHandler::UpdatePepperFlashSettingsEnabled() { |
656 base::FundamentalValue enabled( | 656 base::FundamentalValue enabled( |
657 plugin_status_pref_setter_.IsPepperFlashSettingsEnabled()); | 657 plugin_status_pref_setter_.IsPepperFlashSettingsEnabled()); |
658 web_ui()->CallJavascriptFunction( | 658 web_ui()->CallJavascriptFunctionUnsafe( |
659 "options.OptionsPage.setPepperFlashSettingsEnabled", enabled); | 659 "options.OptionsPage.setPepperFlashSettingsEnabled", enabled); |
660 } | 660 } |
661 | 661 |
662 bool CoreOptionsHandler::IsUserUnsupervised(const base::Value* to_value) { | 662 bool CoreOptionsHandler::IsUserUnsupervised(const base::Value* to_value) { |
663 return !Profile::FromWebUI(web_ui())->IsSupervised(); | 663 return !Profile::FromWebUI(web_ui())->IsSupervised(); |
664 } | 664 } |
665 | 665 |
666 } // namespace options | 666 } // namespace options |
OLD | NEW |