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

Side by Side Diff: chrome/browser/extensions/api/settings_private/prefs_util.cc

Issue 1775803002: MD Settings: add a semi-functional System page (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@v2-md_history
Patch Set: fixes Created 4 years, 9 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/extensions/api/settings_private/prefs_util.h" 5 #include "chrome/browser/extensions/api/settings_private/prefs_util.h"
6 6
7 #include "build/build_config.h" 7 #include "build/build_config.h"
8 #include "chrome/browser/browser_process.h" 8 #include "chrome/browser/browser_process.h"
9 #include "chrome/browser/extensions/chrome_extension_function.h" 9 #include "chrome/browser/extensions/chrome_extension_function.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 PrefsUtil::~PrefsUtil() {} 52 PrefsUtil::~PrefsUtil() {}
53 53
54 #if defined(OS_CHROMEOS) 54 #if defined(OS_CHROMEOS)
55 using CrosSettings = chromeos::CrosSettings; 55 using CrosSettings = chromeos::CrosSettings;
56 #endif 56 #endif
57 57
58 const PrefsUtil::TypedPrefMap& PrefsUtil::GetWhitelistedKeys() { 58 const PrefsUtil::TypedPrefMap& PrefsUtil::GetWhitelistedKeys() {
59 static PrefsUtil::TypedPrefMap* s_whitelist = nullptr; 59 static PrefsUtil::TypedPrefMap* s_whitelist = nullptr;
60 if (s_whitelist) 60 if (s_whitelist)
61 return *s_whitelist; 61 return *s_whitelist;
62 // TODO(dbeam): why aren't we using kPrefName from pref_names.h?
62 s_whitelist = new PrefsUtil::TypedPrefMap(); 63 s_whitelist = new PrefsUtil::TypedPrefMap();
63 (*s_whitelist)["alternate_error_pages.enabled"] = 64 (*s_whitelist)["alternate_error_pages.enabled"] =
64 settings_private::PrefType::PREF_TYPE_BOOLEAN; 65 settings_private::PrefType::PREF_TYPE_BOOLEAN;
65 (*s_whitelist)["autofill.enabled"] = 66 (*s_whitelist)["autofill.enabled"] =
66 settings_private::PrefType::PREF_TYPE_BOOLEAN; 67 settings_private::PrefType::PREF_TYPE_BOOLEAN;
67 (*s_whitelist)["bookmark_bar.show_on_all_tabs"] = 68 (*s_whitelist)["bookmark_bar.show_on_all_tabs"] =
68 settings_private::PrefType::PREF_TYPE_BOOLEAN; 69 settings_private::PrefType::PREF_TYPE_BOOLEAN;
69 (*s_whitelist)["browser.show_home_button"] = 70 (*s_whitelist)["browser.show_home_button"] =
70 settings_private::PrefType::PREF_TYPE_BOOLEAN; 71 settings_private::PrefType::PREF_TYPE_BOOLEAN;
71 72
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 settings_private::PrefType::PREF_TYPE_NUMBER; 237 settings_private::PrefType::PREF_TYPE_NUMBER;
237 (*s_whitelist)["settings.language.remap_caps_lock_key_to"] = 238 (*s_whitelist)["settings.language.remap_caps_lock_key_to"] =
238 settings_private::PrefType::PREF_TYPE_NUMBER; 239 settings_private::PrefType::PREF_TYPE_NUMBER;
239 (*s_whitelist)["settings.language.remap_diamond_key_to"] = 240 (*s_whitelist)["settings.language.remap_diamond_key_to"] =
240 settings_private::PrefType::PREF_TYPE_NUMBER; 241 settings_private::PrefType::PREF_TYPE_NUMBER;
241 (*s_whitelist)["settings.language.send_function_keys"] = 242 (*s_whitelist)["settings.language.send_function_keys"] =
242 settings_private::PrefType::PREF_TYPE_BOOLEAN; 243 settings_private::PrefType::PREF_TYPE_BOOLEAN;
243 #else 244 #else
244 (*s_whitelist)["intl.accept_languages"] = 245 (*s_whitelist)["intl.accept_languages"] =
245 settings_private::PrefType::PREF_TYPE_STRING; 246 settings_private::PrefType::PREF_TYPE_STRING;
247
248 // System settings.
249 (*s_whitelist)["background_mode.enabled"] =
250 settings_private::PrefType::PREF_TYPE_BOOLEAN;
251 (*s_whitelist)["hardware_acceleration_mode.enabled"] =
252 settings_private::PrefType::PREF_TYPE_BOOLEAN;
246 #endif 253 #endif
247 254
248 #if defined(GOOGLE_CHROME_BUILD) 255 #if defined(GOOGLE_CHROME_BUILD)
249 (*s_whitelist)["media_router.cloudservices.enabled"] = 256 (*s_whitelist)["media_router.cloudservices.enabled"] =
250 settings_private::PrefType::PREF_TYPE_BOOLEAN; 257 settings_private::PrefType::PREF_TYPE_BOOLEAN;
251 #endif // defined(GOOGLE_CHROME_BUILD) 258 #endif // defined(GOOGLE_CHROME_BUILD)
252 259
253 return *s_whitelist; 260 return *s_whitelist;
254 } 261 }
255 262
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 553
547 bool PrefsUtil::IsPrefSupervisorControlled(const std::string& pref_name) { 554 bool PrefsUtil::IsPrefSupervisorControlled(const std::string& pref_name) {
548 if (pref_name != prefs::kBrowserGuestModeEnabled && 555 if (pref_name != prefs::kBrowserGuestModeEnabled &&
549 pref_name != prefs::kBrowserAddPersonEnabled) { 556 pref_name != prefs::kBrowserAddPersonEnabled) {
550 return false; 557 return false;
551 } 558 }
552 return profile_->IsSupervised(); 559 return profile_->IsSupervised();
553 } 560 }
554 561
555 bool PrefsUtil::IsPrefUserModifiable(const std::string& pref_name) { 562 bool PrefsUtil::IsPrefUserModifiable(const std::string& pref_name) {
556 PrefService* pref_service = profile_->GetPrefs(); 563 const PrefService::Preference* profile_pref =
557 const PrefService::Preference* pref = 564 profile_->GetPrefs()->FindPreference(pref_name);
558 pref_service->FindPreference(pref_name.c_str()); 565 if (profile_pref)
559 return pref && pref->IsUserModifiable(); 566 return profile_pref->IsUserModifiable();
567
568 const PrefService::Preference* local_state_pref =
569 g_browser_process->local_state()->FindPreference(pref_name);
Dan Beam 2016/03/08 07:13:21 i guess this is the first local_state() pref we've
570 if (local_state_pref)
571 return local_state_pref->IsUserModifiable();
572
573 return false;
560 } 574 }
561 575
562 PrefService* PrefsUtil::FindServiceForPref(const std::string& pref_name) { 576 PrefService* PrefsUtil::FindServiceForPref(const std::string& pref_name) {
563 PrefService* user_prefs = profile_->GetPrefs(); 577 PrefService* user_prefs = profile_->GetPrefs();
564 578
565 // Proxy is a peculiar case: on ChromeOS, settings exist in both user 579 // Proxy is a peculiar case: on ChromeOS, settings exist in both user
566 // prefs and local state, but chrome://settings should affect only user prefs. 580 // prefs and local state, but chrome://settings should affect only user prefs.
567 // Elsewhere the proxy settings are stored in local state. 581 // Elsewhere the proxy settings are stored in local state.
568 // See http://crbug.com/157147 582 // See http://crbug.com/157147
569 583
(...skipping 19 matching lines...) Expand all
589 603
590 bool PrefsUtil::IsCrosSetting(const std::string& pref_name) { 604 bool PrefsUtil::IsCrosSetting(const std::string& pref_name) {
591 #if defined(OS_CHROMEOS) 605 #if defined(OS_CHROMEOS)
592 return CrosSettings::Get()->IsCrosSettings(pref_name); 606 return CrosSettings::Get()->IsCrosSettings(pref_name);
593 #else 607 #else
594 return false; 608 return false;
595 #endif 609 #endif
596 } 610 }
597 611
598 } // namespace extensions 612 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698