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" | 10 #include "chrome/browser/extensions/settings_api_helpers.h" |
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
471 settings_private::ControlledBy::CONTROLLED_BY_OWNER; | 471 settings_private::ControlledBy::CONTROLLED_BY_OWNER; |
472 pref_object->enforcement = | 472 pref_object->enforcement = |
473 settings_private::Enforcement::ENFORCEMENT_ENFORCED; | 473 settings_private::Enforcement::ENFORCEMENT_ENFORCED; |
474 pref_object->controlled_by_name.reset(new std::string( | 474 pref_object->controlled_by_name.reset(new std::string( |
475 user_manager::UserManager::Get()->GetOwnerAccountId().GetUserEmail())); | 475 user_manager::UserManager::Get()->GetOwnerAccountId().GetUserEmail())); |
476 return pref_object; | 476 return pref_object; |
477 } | 477 } |
478 #endif | 478 #endif |
479 | 479 |
480 const Extension* extension = GetExtensionControllingPref(*pref_object); | 480 const Extension* extension = GetExtensionControllingPref(*pref_object); |
| 481 |
481 if (extension) { | 482 if (extension) { |
482 pref_object->controlled_by = | 483 pref_object->controlled_by = |
483 settings_private::ControlledBy::CONTROLLED_BY_EXTENSION; | 484 settings_private::ControlledBy::CONTROLLED_BY_EXTENSION; |
484 pref_object->enforcement = | 485 pref_object->enforcement = |
485 settings_private::Enforcement::ENFORCEMENT_ENFORCED; | 486 settings_private::Enforcement::ENFORCEMENT_ENFORCED; |
486 pref_object->extension_id.reset(new std::string(extension->id())); | 487 pref_object->extension_id.reset(new std::string(extension->id())); |
487 pref_object->controlled_by_name.reset(new std::string(extension->name())); | 488 pref_object->controlled_by_name.reset(new std::string(extension->name())); |
488 bool can_be_disabled = !ExtensionSystem::Get(profile_)->management_policy() | 489 bool can_be_disabled = !ExtensionSystem::Get(profile_)->management_policy() |
489 ->MustRemainEnabled(extension, nullptr); | 490 ->MustRemainEnabled(extension, nullptr); |
490 pref_object->extension_can_be_disabled.reset(new bool(can_be_disabled)); | 491 pref_object->extension_can_be_disabled.reset(new bool(can_be_disabled)); |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
731 | 732 |
732 if (pref_object.key == ::prefs::kURLsToRestoreOnStartup) | 733 if (pref_object.key == ::prefs::kURLsToRestoreOnStartup) |
733 return GetExtensionOverridingStartupPages(profile_); | 734 return GetExtensionOverridingStartupPages(profile_); |
734 | 735 |
735 if (pref_object.key == ::prefs::kDefaultSearchProviderEnabled) | 736 if (pref_object.key == ::prefs::kDefaultSearchProviderEnabled) |
736 return GetExtensionOverridingSearchEngine(profile_); | 737 return GetExtensionOverridingSearchEngine(profile_); |
737 | 738 |
738 if (pref_object.key == proxy_config::prefs::kProxy) | 739 if (pref_object.key == proxy_config::prefs::kProxy) |
739 return GetExtensionOverridingProxy(profile_); | 740 return GetExtensionOverridingProxy(profile_); |
740 | 741 |
741 return nullptr; | 742 // If it's none of the above, attempt a more general strategy. |
| 743 std::string extension_id = |
| 744 ExtensionPrefValueMapFactory::GetForBrowserContext(profile_) |
| 745 ->GetExtensionControllingPref(pref_object.key); |
| 746 if (extension_id.empty()) |
| 747 return nullptr; |
| 748 |
| 749 return ExtensionRegistry::Get(profile_)->GetExtensionById( |
| 750 extension_id, ExtensionRegistry::ENABLED); |
742 } | 751 } |
743 | 752 |
744 } // namespace extensions | 753 } // namespace extensions |
OLD | NEW |