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/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/extensions/settings_api_helpers.h" | |
| 11 #include "chrome/browser/prefs/session_startup_pref.h" | |
| 10 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
| 11 #include "chrome/common/pref_names.h" | 13 #include "chrome/common/pref_names.h" |
| 12 #include "components/autofill/core/common/autofill_pref_names.h" | 14 #include "components/autofill/core/common/autofill_pref_names.h" |
| 13 #include "components/bookmarks/common/bookmark_pref_names.h" | 15 #include "components/bookmarks/common/bookmark_pref_names.h" |
| 14 #include "components/browsing_data/core/pref_names.h" | 16 #include "components/browsing_data/core/pref_names.h" |
| 15 #include "components/content_settings/core/common/pref_names.h" | 17 #include "components/content_settings/core/common/pref_names.h" |
| 16 #include "components/drive/drive_pref_names.h" | 18 #include "components/drive/drive_pref_names.h" |
| 17 #include "components/password_manager/core/common/password_manager_pref_names.h" | 19 #include "components/password_manager/core/common/password_manager_pref_names.h" |
| 18 #include "components/prefs/pref_service.h" | 20 #include "components/prefs/pref_service.h" |
| 19 #include "components/proxy_config/proxy_config_pref_names.h" | 21 #include "components/proxy_config/proxy_config_pref_names.h" |
| 20 #include "components/proxy_config/proxy_config_pref_names.h" | 22 #include "components/proxy_config/proxy_config_pref_names.h" |
| 21 #include "components/safe_browsing_db/safe_browsing_prefs.h" | 23 #include "components/safe_browsing_db/safe_browsing_prefs.h" |
| 24 #include "components/search_engines/search_engines_pref_names.h" | |
| 22 #include "components/spellcheck/browser/pref_names.h" | 25 #include "components/spellcheck/browser/pref_names.h" |
| 23 #include "components/translate/core/browser/translate_prefs.h" | 26 #include "components/translate/core/browser/translate_prefs.h" |
| 24 #include "components/translate/core/common/translate_pref_names.h" | 27 #include "components/translate/core/common/translate_pref_names.h" |
| 25 #include "components/url_formatter/url_fixer.h" | 28 #include "components/url_formatter/url_fixer.h" |
| 26 #include "extensions/browser/extension_pref_value_map.h" | 29 #include "extensions/browser/extension_pref_value_map.h" |
| 27 #include "extensions/browser/extension_pref_value_map_factory.h" | 30 #include "extensions/browser/extension_pref_value_map_factory.h" |
| 28 #include "extensions/browser/extension_registry.h" | 31 #include "extensions/browser/extension_registry.h" |
| 32 #include "extensions/browser/extension_system.h" | |
| 33 #include "extensions/browser/management_policy.h" | |
| 29 #include "extensions/common/extension.h" | 34 #include "extensions/common/extension.h" |
| 30 | 35 |
| 31 #if defined(OS_CHROMEOS) | 36 #if defined(OS_CHROMEOS) |
| 32 #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos.h" | 37 #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos.h" |
| 33 #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos_fact ory.h" | 38 #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos_fact ory.h" |
| 34 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" | 39 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" |
| 35 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 40 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 36 #include "chrome/browser/chromeos/settings/cros_settings.h" | 41 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 37 #include "chromeos/settings/cros_settings_names.h" | 42 #include "chromeos/settings/cros_settings_names.h" |
| 38 #endif | 43 #endif |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 86 (*s_whitelist)[::prefs::kShowHomeButton] = | 91 (*s_whitelist)[::prefs::kShowHomeButton] = |
| 87 settings_private::PrefType::PREF_TYPE_BOOLEAN; | 92 settings_private::PrefType::PREF_TYPE_BOOLEAN; |
| 88 | 93 |
| 89 // Appearance settings. | 94 // Appearance settings. |
| 90 (*s_whitelist)[::prefs::kCurrentThemeID] = | 95 (*s_whitelist)[::prefs::kCurrentThemeID] = |
| 91 settings_private::PrefType::PREF_TYPE_STRING; | 96 settings_private::PrefType::PREF_TYPE_STRING; |
| 92 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | 97 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| 93 (*s_whitelist)[::prefs::kUsesSystemTheme] = | 98 (*s_whitelist)[::prefs::kUsesSystemTheme] = |
| 94 settings_private::PrefType::PREF_TYPE_BOOLEAN; | 99 settings_private::PrefType::PREF_TYPE_BOOLEAN; |
| 95 #endif | 100 #endif |
| 101 (*s_whitelist)[::prefs::kHomePage] = | |
| 102 settings_private::PrefType::PREF_TYPE_URL; | |
| 103 (*s_whitelist)[::prefs::kHomePageIsNewTabPage] = | |
| 104 settings_private::PrefType::PREF_TYPE_BOOLEAN; | |
| 96 (*s_whitelist)[::prefs::kWebKitDefaultFixedFontSize] = | 105 (*s_whitelist)[::prefs::kWebKitDefaultFixedFontSize] = |
| 97 settings_private::PrefType::PREF_TYPE_NUMBER; | 106 settings_private::PrefType::PREF_TYPE_NUMBER; |
| 98 (*s_whitelist)[::prefs::kWebKitDefaultFontSize] = | 107 (*s_whitelist)[::prefs::kWebKitDefaultFontSize] = |
| 99 settings_private::PrefType::PREF_TYPE_NUMBER; | 108 settings_private::PrefType::PREF_TYPE_NUMBER; |
| 100 (*s_whitelist)[::prefs::kWebKitMinimumFontSize] = | 109 (*s_whitelist)[::prefs::kWebKitMinimumFontSize] = |
| 101 settings_private::PrefType::PREF_TYPE_NUMBER; | 110 settings_private::PrefType::PREF_TYPE_NUMBER; |
| 102 (*s_whitelist)[::prefs::kWebKitFixedFontFamily] = | 111 (*s_whitelist)[::prefs::kWebKitFixedFontFamily] = |
| 103 settings_private::PrefType::PREF_TYPE_STRING; | 112 settings_private::PrefType::PREF_TYPE_STRING; |
| 104 (*s_whitelist)[::prefs::kWebKitSansSerifFontFamily] = | 113 (*s_whitelist)[::prefs::kWebKitSansSerifFontFamily] = |
| 105 settings_private::PrefType::PREF_TYPE_STRING; | 114 settings_private::PrefType::PREF_TYPE_STRING; |
| 106 (*s_whitelist)[::prefs::kWebKitSerifFontFamily] = | 115 (*s_whitelist)[::prefs::kWebKitSerifFontFamily] = |
| 107 settings_private::PrefType::PREF_TYPE_STRING; | 116 settings_private::PrefType::PREF_TYPE_STRING; |
| 108 (*s_whitelist)[::prefs::kWebKitStandardFontFamily] = | 117 (*s_whitelist)[::prefs::kWebKitStandardFontFamily] = |
| 109 settings_private::PrefType::PREF_TYPE_STRING; | 118 settings_private::PrefType::PREF_TYPE_STRING; |
| 110 (*s_whitelist)[::prefs::kDefaultCharset] = | 119 (*s_whitelist)[::prefs::kDefaultCharset] = |
| 111 settings_private::PrefType::PREF_TYPE_STRING; | 120 settings_private::PrefType::PREF_TYPE_STRING; |
| 112 | 121 |
| 122 // On startup. | |
| 123 (*s_whitelist)[::prefs::kRestoreOnStartup] = | |
| 124 settings_private::PrefType::PREF_TYPE_NUMBER; | |
| 125 (*s_whitelist)[::prefs::kURLsToRestoreOnStartup] = | |
| 126 settings_private::PrefType::PREF_TYPE_LIST; | |
| 127 | |
| 113 // Downloads settings. | 128 // Downloads settings. |
| 114 (*s_whitelist)[::prefs::kDownloadDefaultDirectory] = | 129 (*s_whitelist)[::prefs::kDownloadDefaultDirectory] = |
| 115 settings_private::PrefType::PREF_TYPE_STRING; | 130 settings_private::PrefType::PREF_TYPE_STRING; |
| 116 (*s_whitelist)[::prefs::kPromptForDownload] = | 131 (*s_whitelist)[::prefs::kPromptForDownload] = |
| 117 settings_private::PrefType::PREF_TYPE_BOOLEAN; | 132 settings_private::PrefType::PREF_TYPE_BOOLEAN; |
| 118 (*s_whitelist)[drive::prefs::kDisableDrive] = | 133 (*s_whitelist)[drive::prefs::kDisableDrive] = |
| 119 settings_private::PrefType::PREF_TYPE_BOOLEAN; | 134 settings_private::PrefType::PREF_TYPE_BOOLEAN; |
| 120 | 135 |
| 121 // Printing settings. | 136 // Printing settings. |
| 122 (*s_whitelist)[::prefs::kLocalDiscoveryNotificationsEnabled] = | 137 (*s_whitelist)[::prefs::kLocalDiscoveryNotificationsEnabled] = |
| 123 settings_private::PrefType::PREF_TYPE_BOOLEAN; | 138 settings_private::PrefType::PREF_TYPE_BOOLEAN; |
| 124 | 139 |
| 125 // Miscelaneous. TODO(stevenjb): categorize. | 140 // Miscellaneous. TODO(stevenjb): categorize. |
| 126 (*s_whitelist)[::prefs::kEnableDoNotTrack] = | 141 (*s_whitelist)[::prefs::kEnableDoNotTrack] = |
| 127 settings_private::PrefType::PREF_TYPE_BOOLEAN; | 142 settings_private::PrefType::PREF_TYPE_BOOLEAN; |
| 128 (*s_whitelist)[::prefs::kHomePage] = | |
| 129 settings_private::PrefType::PREF_TYPE_URL; | |
| 130 (*s_whitelist)[::prefs::kHomePageIsNewTabPage] = | |
| 131 settings_private::PrefType::PREF_TYPE_BOOLEAN; | |
| 132 (*s_whitelist)[::prefs::kApplicationLocale] = | 143 (*s_whitelist)[::prefs::kApplicationLocale] = |
| 133 settings_private::PrefType::PREF_TYPE_STRING; | 144 settings_private::PrefType::PREF_TYPE_STRING; |
| 134 (*s_whitelist)[::prefs::kNetworkPredictionOptions] = | 145 (*s_whitelist)[::prefs::kNetworkPredictionOptions] = |
| 135 settings_private::PrefType::PREF_TYPE_NUMBER; | 146 settings_private::PrefType::PREF_TYPE_NUMBER; |
| 136 (*s_whitelist)[password_manager::prefs::kPasswordManagerSavingEnabled] = | 147 (*s_whitelist)[password_manager::prefs::kPasswordManagerSavingEnabled] = |
| 137 settings_private::PrefType::PREF_TYPE_BOOLEAN; | 148 settings_private::PrefType::PREF_TYPE_BOOLEAN; |
| 138 (*s_whitelist)[password_manager::prefs::kCredentialsEnableAutosignin] = | 149 (*s_whitelist)[password_manager::prefs::kCredentialsEnableAutosignin] = |
| 139 settings_private::PrefType::PREF_TYPE_BOOLEAN; | 150 settings_private::PrefType::PREF_TYPE_BOOLEAN; |
| 140 (*s_whitelist)[::prefs::kSafeBrowsingEnabled] = | 151 (*s_whitelist)[::prefs::kSafeBrowsingEnabled] = |
| 141 settings_private::PrefType::PREF_TYPE_BOOLEAN; | 152 settings_private::PrefType::PREF_TYPE_BOOLEAN; |
| 142 (*s_whitelist)[::prefs::kSafeBrowsingExtendedReportingEnabled] = | 153 (*s_whitelist)[::prefs::kSafeBrowsingExtendedReportingEnabled] = |
| 143 settings_private::PrefType::PREF_TYPE_BOOLEAN; | 154 settings_private::PrefType::PREF_TYPE_BOOLEAN; |
| 144 (*s_whitelist)[::prefs::kSearchSuggestEnabled] = | 155 (*s_whitelist)[::prefs::kSearchSuggestEnabled] = |
| 145 settings_private::PrefType::PREF_TYPE_BOOLEAN; | 156 settings_private::PrefType::PREF_TYPE_BOOLEAN; |
| 146 (*s_whitelist)[::prefs::kRestoreOnStartup] = | |
| 147 settings_private::PrefType::PREF_TYPE_NUMBER; | |
| 148 (*s_whitelist)[::prefs::kURLsToRestoreOnStartup] = | |
| 149 settings_private::PrefType::PREF_TYPE_LIST; | |
| 150 (*s_whitelist)[spellcheck::prefs::kSpellCheckDictionaries] = | 157 (*s_whitelist)[spellcheck::prefs::kSpellCheckDictionaries] = |
| 151 settings_private::PrefType::PREF_TYPE_LIST; | 158 settings_private::PrefType::PREF_TYPE_LIST; |
| 152 (*s_whitelist)[spellcheck::prefs::kSpellCheckUseSpellingService] = | 159 (*s_whitelist)[spellcheck::prefs::kSpellCheckUseSpellingService] = |
| 153 settings_private::PrefType::PREF_TYPE_BOOLEAN; | 160 settings_private::PrefType::PREF_TYPE_BOOLEAN; |
| 154 (*s_whitelist)[::prefs::kEnableTranslate] = | 161 (*s_whitelist)[::prefs::kEnableTranslate] = |
| 155 settings_private::PrefType::PREF_TYPE_BOOLEAN; | 162 settings_private::PrefType::PREF_TYPE_BOOLEAN; |
| 156 (*s_whitelist)[translate::TranslatePrefs::kPrefTranslateBlockedLanguages] = | 163 (*s_whitelist)[translate::TranslatePrefs::kPrefTranslateBlockedLanguages] = |
| 157 settings_private::PrefType::PREF_TYPE_LIST; | 164 settings_private::PrefType::PREF_TYPE_LIST; |
| 158 | 165 |
| 159 // Site Settings prefs. | 166 // Site Settings prefs. |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 360 if (!pref) | 367 if (!pref) |
| 361 return nullptr; | 368 return nullptr; |
| 362 pref_object.reset(new settings_private::PrefObject()); | 369 pref_object.reset(new settings_private::PrefObject()); |
| 363 pref_object->key = pref->name(); | 370 pref_object->key = pref->name(); |
| 364 pref_object->type = GetType(name, pref->GetType()); | 371 pref_object->type = GetType(name, pref->GetType()); |
| 365 pref_object->value.reset(pref->GetValue()->DeepCopy()); | 372 pref_object->value.reset(pref->GetValue()->DeepCopy()); |
| 366 } | 373 } |
| 367 | 374 |
| 368 #if defined(OS_CHROMEOS) | 375 #if defined(OS_CHROMEOS) |
| 369 if (IsPrefPrimaryUserControlled(name)) { | 376 if (IsPrefPrimaryUserControlled(name)) { |
| 370 pref_object->policy_source = | 377 pref_object->controlled_by = |
| 371 settings_private::PolicySource::POLICY_SOURCE_PRIMARY_USER; | 378 settings_private::ControlledBy::CONTROLLED_BY_PRIMARY_USER; |
| 372 pref_object->policy_enforcement = | 379 pref_object->enforcement = |
| 373 settings_private::PolicyEnforcement::POLICY_ENFORCEMENT_ENFORCED; | 380 settings_private::Enforcement::ENFORCEMENT_ENFORCED; |
| 374 pref_object->policy_source_name.reset( | 381 pref_object->controlled_by_name.reset( |
| 375 new std::string(user_manager::UserManager::Get() | 382 new std::string(user_manager::UserManager::Get() |
| 376 ->GetPrimaryUser() | 383 ->GetPrimaryUser() |
| 377 ->GetAccountId() | 384 ->GetAccountId() |
| 378 .GetUserEmail())); | 385 .GetUserEmail())); |
| 379 return pref_object; | 386 return pref_object; |
| 380 } | 387 } |
| 388 | |
| 381 if (IsPrefEnterpriseManaged(name)) { | 389 if (IsPrefEnterpriseManaged(name)) { |
| 382 // Enterprise managed prefs are treated the same as device policy restricted | 390 // Enterprise managed prefs are treated the same as device policy restricted |
| 383 // prefs in the UI. | 391 // prefs in the UI. |
| 384 pref_object->policy_source = | 392 pref_object->controlled_by = |
| 385 settings_private::PolicySource::POLICY_SOURCE_DEVICE_POLICY; | 393 settings_private::ControlledBy::CONTROLLED_BY_DEVICE_POLICY; |
| 386 pref_object->policy_enforcement = | 394 pref_object->enforcement = |
| 387 settings_private::PolicyEnforcement::POLICY_ENFORCEMENT_ENFORCED; | 395 settings_private::Enforcement::ENFORCEMENT_ENFORCED; |
| 388 return pref_object; | 396 return pref_object; |
| 389 } | 397 } |
| 390 #endif | 398 #endif |
| 391 | 399 |
| 392 if (pref && pref->IsManaged()) { | 400 if (pref && pref->IsManaged()) { |
| 393 pref_object->policy_source = | 401 pref_object->controlled_by = |
| 394 settings_private::PolicySource::POLICY_SOURCE_USER_POLICY; | 402 settings_private::ControlledBy::CONTROLLED_BY_USER_POLICY; |
| 395 pref_object->policy_enforcement = | 403 pref_object->enforcement = |
| 396 settings_private::PolicyEnforcement::POLICY_ENFORCEMENT_ENFORCED; | 404 settings_private::Enforcement::ENFORCEMENT_ENFORCED; |
| 397 return pref_object; | 405 return pref_object; |
| 398 } | 406 } |
| 407 | |
| 399 if (pref && pref->IsRecommended()) { | 408 if (pref && pref->IsRecommended()) { |
| 400 pref_object->policy_source = | 409 pref_object->controlled_by = |
| 401 settings_private::PolicySource::POLICY_SOURCE_USER_POLICY; | 410 settings_private::ControlledBy::CONTROLLED_BY_USER_POLICY; |
| 402 pref_object->policy_enforcement = | 411 pref_object->enforcement = |
| 403 settings_private::PolicyEnforcement::POLICY_ENFORCEMENT_RECOMMENDED; | 412 settings_private::Enforcement::ENFORCEMENT_RECOMMENDED; |
| 404 pref_object->recommended_value.reset( | 413 pref_object->recommended_value.reset( |
| 405 pref->GetRecommendedValue()->DeepCopy()); | 414 pref->GetRecommendedValue()->DeepCopy()); |
| 406 return pref_object; | 415 return pref_object; |
| 407 } | 416 } |
| 408 | 417 |
| 409 #if defined(OS_CHROMEOS) | 418 #if defined(OS_CHROMEOS) |
| 410 if (IsPrefOwnerControlled(name)) { | 419 if (IsPrefOwnerControlled(name)) { |
| 411 // Check for owner controlled after managed checks because if there is a | 420 // Check for owner controlled after managed checks because if there is a |
| 412 // device policy there is no "owner". (In the unlikely case that both | 421 // device policy there is no "owner". (In the unlikely case that both |
| 413 // situations apply, either badge is potentially relevant, so the order | 422 // situations apply, either badge is potentially relevant, so the order |
| 414 // is somewhat arbitrary). | 423 // is somewhat arbitrary). |
| 415 pref_object->policy_source = | 424 pref_object->controlled_by = |
| 416 settings_private::PolicySource::POLICY_SOURCE_OWNER; | 425 settings_private::ControlledBy::CONTROLLED_BY_OWNER; |
| 417 pref_object->policy_enforcement = | 426 pref_object->enforcement = |
| 418 settings_private::PolicyEnforcement::POLICY_ENFORCEMENT_ENFORCED; | 427 settings_private::Enforcement::ENFORCEMENT_ENFORCED; |
| 419 pref_object->policy_source_name.reset(new std::string( | 428 pref_object->controlled_by_name.reset(new std::string( |
| 420 user_manager::UserManager::Get()->GetOwnerAccountId().GetUserEmail())); | 429 user_manager::UserManager::Get()->GetOwnerAccountId().GetUserEmail())); |
| 421 return pref_object; | 430 return pref_object; |
| 422 } | 431 } |
| 423 #endif | 432 #endif |
| 424 | 433 |
| 425 if (pref && pref->IsExtensionControlled()) { | 434 const Extension* extension = GetExtensionControllingPref(*pref_object); |
| 426 std::string extension_id = | 435 if (extension) { |
| 427 ExtensionPrefValueMapFactory::GetForBrowserContext(profile_) | 436 pref_object->controlled_by = |
| 428 ->GetExtensionControllingPref(pref->name()); | 437 settings_private::ControlledBy::CONTROLLED_BY_EXTENSION; |
| 429 const Extension* extension = ExtensionRegistry::Get(profile_)-> | 438 pref_object->enforcement = |
| 430 GetExtensionById(extension_id, ExtensionRegistry::ENABLED); | 439 settings_private::Enforcement::ENFORCEMENT_ENFORCED; |
| 431 if (extension) { | 440 pref_object->extension_id.reset(new std::string(extension->id())); |
| 432 pref_object->policy_source = | 441 pref_object->controlled_by_name.reset(new std::string(extension->name())); |
| 433 settings_private::PolicySource::POLICY_SOURCE_EXTENSION; | 442 bool can_be_disabled = !ExtensionSystem::Get(profile_)->management_policy() |
| 434 pref_object->policy_enforcement = | 443 ->MustRemainEnabled(extension, nullptr); |
| 435 settings_private::PolicyEnforcement::POLICY_ENFORCEMENT_ENFORCED; | 444 pref_object->extension_can_be_disabled.reset(new bool(can_be_disabled)); |
| 436 pref_object->extension_id.reset(new std::string(extension_id)); | |
| 437 pref_object->policy_source_name.reset(new std::string(extension->name())); | |
| 438 return pref_object; | |
| 439 } | |
| 440 } | |
| 441 if (pref && (!pref->IsUserModifiable() || IsPrefSupervisorControlled(name))) { | |
| 442 // TODO(stevenjb): Investigate whether either of these should be badged. | |
| 443 pref_object->read_only.reset(new bool(true)); | |
| 444 return pref_object; | 445 return pref_object; |
| 445 } | 446 } |
| 446 | 447 |
| 448 // TODO(dbeam): surface !IsUserModifiable or IsPrefSupervisorControlled? | |
| 449 | |
| 447 return pref_object; | 450 return pref_object; |
| 448 } | 451 } |
| 449 | 452 |
| 450 PrefsUtil::SetPrefResult PrefsUtil::SetPref(const std::string& pref_name, | 453 PrefsUtil::SetPrefResult PrefsUtil::SetPref(const std::string& pref_name, |
| 451 const base::Value* value) { | 454 const base::Value* value) { |
| 452 if (IsCrosSetting(pref_name)) | 455 if (IsCrosSetting(pref_name)) |
| 453 return SetCrosSettingsPref(pref_name, value); | 456 return SetCrosSettingsPref(pref_name, value); |
| 454 | 457 |
| 455 PrefService* pref_service = FindServiceForPref(pref_name); | 458 PrefService* pref_service = FindServiceForPref(pref_name); |
| 456 | 459 |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 658 } | 661 } |
| 659 | 662 |
| 660 bool PrefsUtil::IsCrosSetting(const std::string& pref_name) { | 663 bool PrefsUtil::IsCrosSetting(const std::string& pref_name) { |
| 661 #if defined(OS_CHROMEOS) | 664 #if defined(OS_CHROMEOS) |
| 662 return CrosSettings::Get()->IsCrosSettings(pref_name); | 665 return CrosSettings::Get()->IsCrosSettings(pref_name); |
| 663 #else | 666 #else |
| 664 return false; | 667 return false; |
| 665 #endif | 668 #endif |
| 666 } | 669 } |
| 667 | 670 |
| 671 const Extension* PrefsUtil::GetExtensionControllingPref( | |
| 672 const settings_private::PrefObject& pref_object) { | |
|
stevenjb
2016/11/12 01:31:46
Can we add a comment here, similar to what's in th
Dan Beam
2016/11/15 05:38:39
Done.
| |
| 673 if (pref_object.key == ::prefs::kHomePage) | |
| 674 return GetExtensionOverridingHomepage(profile_); | |
| 675 | |
| 676 if (pref_object.key == ::prefs::kRestoreOnStartup) { | |
| 677 int session_startup_type; | |
| 678 CHECK(pref_object.value->GetAsInteger(&session_startup_type)); | |
| 679 if (session_startup_type == SessionStartupPref::kPrefValueNewTab) | |
| 680 return GetExtensionOverridingNewTabPage(profile_); | |
| 681 if (session_startup_type == SessionStartupPref::kPrefValueURLs) | |
| 682 return GetExtensionOverridingStartupPages(profile_); | |
| 683 } | |
| 684 | |
| 685 if (pref_object.key == ::prefs::kDefaultSearchProviderEnabled) | |
| 686 return GetExtensionOverridingSearchEngine(profile_); | |
| 687 | |
| 688 if (pref_object.key == proxy_config::prefs::kProxy) | |
| 689 return GetExtensionOverridingProxy(profile_); | |
| 690 | |
| 691 return nullptr; | |
| 692 } | |
| 693 | |
| 668 } // namespace extensions | 694 } // namespace extensions |
| OLD | NEW |