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

Side by Side Diff: extensions/browser/extension_prefs.cc

Issue 714133002: Add more management policy checking after extension installed (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove two tests Created 6 years, 1 month 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 | « extensions/browser/extension_prefs.h ('k') | extensions/common/extension.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "extensions/browser/extension_prefs.h" 5 #include "extensions/browser/extension_prefs.h"
6 6
7 #include <iterator> 7 #include <iterator>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/prefs/pref_notifier.h" 10 #include "base/prefs/pref_notifier.h"
(...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after
739 } 739 }
740 740
741 bool ExtensionPrefs::HasDisableReason( 741 bool ExtensionPrefs::HasDisableReason(
742 const std::string& extension_id, 742 const std::string& extension_id,
743 Extension::DisableReason disable_reason) const { 743 Extension::DisableReason disable_reason) const {
744 return (GetDisableReasons(extension_id) & disable_reason) != 0; 744 return (GetDisableReasons(extension_id) & disable_reason) != 0;
745 } 745 }
746 746
747 void ExtensionPrefs::AddDisableReason(const std::string& extension_id, 747 void ExtensionPrefs::AddDisableReason(const std::string& extension_id,
748 Extension::DisableReason disable_reason) { 748 Extension::DisableReason disable_reason) {
749 ModifyDisableReason(extension_id, disable_reason, DISABLE_REASON_ADD); 749 ModifyDisableReasons(extension_id, disable_reason, DISABLE_REASON_ADD);
750 }
751
752 void ExtensionPrefs::AddDisableReasons(const std::string& extension_id,
753 int disable_reasons) {
754 ModifyDisableReasons(extension_id, disable_reasons, DISABLE_REASON_ADD);
750 } 755 }
751 756
752 void ExtensionPrefs::RemoveDisableReason( 757 void ExtensionPrefs::RemoveDisableReason(
753 const std::string& extension_id, 758 const std::string& extension_id,
754 Extension::DisableReason disable_reason) { 759 Extension::DisableReason disable_reason) {
755 ModifyDisableReason(extension_id, disable_reason, DISABLE_REASON_REMOVE); 760 ModifyDisableReasons(extension_id, disable_reason, DISABLE_REASON_REMOVE);
756 } 761 }
757 762
758 void ExtensionPrefs::ClearDisableReasons(const std::string& extension_id) { 763 void ExtensionPrefs::ClearDisableReasons(const std::string& extension_id) {
759 ModifyDisableReason( 764 ModifyDisableReasons(extension_id, Extension::DISABLE_NONE,
760 extension_id, Extension::DISABLE_NONE, DISABLE_REASON_CLEAR); 765 DISABLE_REASON_CLEAR);
761 } 766 }
762 767
763 void ExtensionPrefs::ModifyDisableReason(const std::string& extension_id, 768 void ExtensionPrefs::ModifyDisableReasons(const std::string& extension_id,
764 Extension::DisableReason reason, 769 int reasons,
765 DisableReasonChange change) { 770 DisableReasonChange change) {
766 int old_value = GetDisableReasons(extension_id); 771 int old_value = GetDisableReasons(extension_id);
767 int new_value = old_value; 772 int new_value = old_value;
768 switch (change) { 773 switch (change) {
769 case DISABLE_REASON_ADD: 774 case DISABLE_REASON_ADD:
770 new_value |= static_cast<int>(reason); 775 new_value |= reasons;
771 break; 776 break;
772 case DISABLE_REASON_REMOVE: 777 case DISABLE_REASON_REMOVE:
773 new_value &= ~static_cast<int>(reason); 778 new_value &= ~reasons;
774 break; 779 break;
775 case DISABLE_REASON_CLEAR: 780 case DISABLE_REASON_CLEAR:
776 new_value = Extension::DISABLE_NONE; 781 new_value = Extension::DISABLE_NONE;
777 break; 782 break;
778 } 783 }
779 784
780 if (old_value == new_value) // no change, return. 785 if (old_value == new_value) // no change, return.
781 return; 786 return;
782 787
783 if (new_value == Extension::DISABLE_NONE) { 788 if (new_value == Extension::DISABLE_NONE) {
(...skipping 1317 matching lines...) Expand 10 before | Expand all | Expand 10 after
2101 extension_pref_value_map_->RegisterExtension( 2106 extension_pref_value_map_->RegisterExtension(
2102 extension_id, install_time, is_enabled, is_incognito_enabled); 2107 extension_id, install_time, is_enabled, is_incognito_enabled);
2103 2108
2104 FOR_EACH_OBSERVER( 2109 FOR_EACH_OBSERVER(
2105 ExtensionPrefsObserver, 2110 ExtensionPrefsObserver,
2106 observer_list_, 2111 observer_list_,
2107 OnExtensionRegistered(extension_id, install_time, is_enabled)); 2112 OnExtensionRegistered(extension_id, install_time, is_enabled));
2108 } 2113 }
2109 2114
2110 } // namespace extensions 2115 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/extension_prefs.h ('k') | extensions/common/extension.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698