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/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
11 #include "base/values.h" | 11 #include "base/values.h" |
12 #include "chrome/browser/chrome_notification_types.h" | 12 #include "chrome/browser/chrome_notification_types.h" |
13 #include "chrome/browser/extensions/external_provider_impl.h" | 13 #include "chrome/browser/extensions/external_provider_impl.h" |
14 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
15 #include "chrome/common/pref_names.h" | 15 #include "chrome/common/pref_names.h" |
16 #include "content/public/browser/notification_details.h" | 16 #include "content/public/browser/notification_details.h" |
17 #include "content/public/browser/notification_source.h" | 17 #include "content/public/browser/notification_source.h" |
| 18 #include "extensions/browser/pref_names.h" |
18 | 19 |
19 namespace extensions { | 20 namespace extensions { |
20 | 21 |
21 ExternalPolicyLoader::ExternalPolicyLoader(Profile* profile) | 22 ExternalPolicyLoader::ExternalPolicyLoader(Profile* profile) |
22 : profile_(profile) { | 23 : profile_(profile) { |
23 pref_change_registrar_.Init(profile_->GetPrefs()); | 24 pref_change_registrar_.Init(profile_->GetPrefs()); |
24 pref_change_registrar_.Add(prefs::kExtensionInstallForceList, | 25 pref_change_registrar_.Add(pref_names::kInstallForceList, |
25 base::Bind(&ExternalPolicyLoader::StartLoading, | 26 base::Bind(&ExternalPolicyLoader::StartLoading, |
26 base::Unretained(this))); | 27 base::Unretained(this))); |
27 pref_change_registrar_.Add(prefs::kExtensionAllowedTypes, | 28 pref_change_registrar_.Add(pref_names::kAllowedTypes, |
28 base::Bind(&ExternalPolicyLoader::StartLoading, | 29 base::Bind(&ExternalPolicyLoader::StartLoading, |
29 base::Unretained(this))); | 30 base::Unretained(this))); |
30 notification_registrar_.Add(this, | 31 notification_registrar_.Add(this, |
31 chrome::NOTIFICATION_PROFILE_DESTROYED, | 32 chrome::NOTIFICATION_PROFILE_DESTROYED, |
32 content::Source<Profile>(profile_)); | 33 content::Source<Profile>(profile_)); |
33 } | 34 } |
34 | 35 |
35 // static | 36 // static |
36 void ExternalPolicyLoader::AddExtension(base::DictionaryValue* dict, | 37 void ExternalPolicyLoader::AddExtension(base::DictionaryValue* dict, |
37 const std::string& extension_id, | 38 const std::string& extension_id, |
(...skipping 12 matching lines...) Expand all Loading... |
50 "Unexpected notification type."; | 51 "Unexpected notification type."; |
51 if (content::Source<Profile>(source).ptr() == profile_) { | 52 if (content::Source<Profile>(source).ptr() == profile_) { |
52 notification_registrar_.RemoveAll(); | 53 notification_registrar_.RemoveAll(); |
53 pref_change_registrar_.RemoveAll(); | 54 pref_change_registrar_.RemoveAll(); |
54 profile_ = NULL; | 55 profile_ = NULL; |
55 } | 56 } |
56 } | 57 } |
57 | 58 |
58 void ExternalPolicyLoader::StartLoading() { | 59 void ExternalPolicyLoader::StartLoading() { |
59 const base::DictionaryValue* forcelist = | 60 const base::DictionaryValue* forcelist = |
60 profile_->GetPrefs()->GetDictionary(prefs::kExtensionInstallForceList); | 61 profile_->GetPrefs()->GetDictionary(pref_names::kInstallForceList); |
61 prefs_.reset(forcelist ? forcelist->DeepCopy() : NULL); | 62 prefs_.reset(forcelist ? forcelist->DeepCopy() : NULL); |
62 LoadFinished(); | 63 LoadFinished(); |
63 } | 64 } |
64 | 65 |
65 } // namespace extensions | 66 } // namespace extensions |
OLD | NEW |