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

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

Issue 2720503007: MD Settings: add more extension controlled pref handling. (Closed)
Patch Set: add comments Created 3 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/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
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
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);
Dan Beam 2017/02/28 17:52:45 if (extension_id.empty()) return nullptr;
scottchen 2017/02/28 18:56:14 Done.
746 return ExtensionRegistry::Get(profile_)->
747 GetExtensionById(extension_id, ExtensionRegistry::ENABLED);
742 } 748 }
743 749
744 } // namespace extensions 750 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698