OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/external_policy_loader.h" | 5 #include "chrome/browser/extensions/external_policy_loader.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "chrome/browser/prefs/pref_service.h" | 9 #include "chrome/browser/prefs/pref_service.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 } | 72 } |
73 prefs_.reset(result); | 73 prefs_.reset(result); |
74 LoadFinished(); | 74 LoadFinished(); |
75 } | 75 } |
76 | 76 |
77 void ExternalPolicyLoader::Observe( | 77 void ExternalPolicyLoader::Observe( |
78 int type, | 78 int type, |
79 const content::NotificationSource& source, | 79 const content::NotificationSource& source, |
80 const content::NotificationDetails& details) { | 80 const content::NotificationDetails& details) { |
81 if (profile_ == NULL) return; | 81 if (profile_ == NULL) return; |
82 switch (type) { | 82 DCHECK(type == chrome::NOTIFICATION_PROFILE_DESTROYED) << |
83 case chrome::NOTIFICATION_PREF_CHANGED: { | 83 "Unexpected notification type."; |
84 if (content::Source<PrefService>(source).ptr() == profile_->GetPrefs()) { | 84 if (content::Source<Profile>(source).ptr() == profile_) { |
85 std::string* pref_name = content::Details<std::string>(details).ptr(); | 85 notification_registrar_.RemoveAll(); |
86 if (*pref_name == prefs::kExtensionInstallForceList) { | 86 pref_change_registrar_.RemoveAll(); |
87 StartLoading(); | 87 profile_ = NULL; |
88 } else { | |
89 NOTREACHED() << "Unexpected preference name."; | |
90 } | |
91 } | |
92 break; | |
93 } | |
94 case chrome::NOTIFICATION_PROFILE_DESTROYED: { | |
95 if (content::Source<Profile>(source).ptr() == profile_) { | |
96 notification_registrar_.RemoveAll(); | |
97 pref_change_registrar_.RemoveAll(); | |
98 profile_ = NULL; | |
99 } | |
100 break; | |
101 } | |
102 default: | |
103 NOTREACHED() << "Unexpected notification type."; | |
104 } | 88 } |
105 } | 89 } |
106 | 90 |
| 91 void ExternalPolicyLoader::OnPreferenceChanged(PrefServiceBase* service, |
| 92 const std::string& pref_name) { |
| 93 if (service == profile_->GetPrefs()) { |
| 94 if (pref_name == prefs::kExtensionInstallForceList) { |
| 95 StartLoading(); |
| 96 } else { |
| 97 NOTREACHED() << "Unexpected preference name."; |
| 98 } |
| 99 } |
| 100 } |
| 101 |
107 } // namespace extensions | 102 } // namespace extensions |
OLD | NEW |