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

Side by Side Diff: chrome/browser/extensions/external_policy_loader.cc

Issue 11377131: Removing PrefObserver usage, batch 4. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Respond to review comments. Created 8 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 | Annotate | Revision Log
OLDNEW
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 23 matching lines...) Expand all
34 return false; 34 return false;
35 } 35 }
36 return true; 36 return true;
37 } 37 }
38 38
39 } // namespace 39 } // namespace
40 40
41 ExternalPolicyLoader::ExternalPolicyLoader(Profile* profile) 41 ExternalPolicyLoader::ExternalPolicyLoader(Profile* profile)
42 : profile_(profile) { 42 : profile_(profile) {
43 pref_change_registrar_.Init(profile_->GetPrefs()); 43 pref_change_registrar_.Init(profile_->GetPrefs());
44 pref_change_registrar_.Add(prefs::kExtensionInstallForceList, this); 44 pref_change_registrar_.Add(prefs::kExtensionInstallForceList,
45 base::Bind(&ExternalPolicyLoader::StartLoading,
46 base::Unretained(this)));
45 notification_registrar_.Add(this, 47 notification_registrar_.Add(this,
46 chrome::NOTIFICATION_PROFILE_DESTROYED, 48 chrome::NOTIFICATION_PROFILE_DESTROYED,
47 content::Source<Profile>(profile_)); 49 content::Source<Profile>(profile_));
48 } 50 }
49 51
50 void ExternalPolicyLoader::StartLoading() { 52 void ExternalPolicyLoader::StartLoading() {
51 const ListValue* forcelist = 53 const ListValue* forcelist =
52 profile_->GetPrefs()->GetList(prefs::kExtensionInstallForceList); 54 profile_->GetPrefs()->GetList(prefs::kExtensionInstallForceList);
53 DictionaryValue* result = new DictionaryValue(); 55 DictionaryValue* result = new DictionaryValue();
54 if (forcelist != NULL) { 56 if (forcelist != NULL) {
(...skipping 26 matching lines...) Expand all
81 if (profile_ == NULL) return; 83 if (profile_ == NULL) return;
82 DCHECK(type == chrome::NOTIFICATION_PROFILE_DESTROYED) << 84 DCHECK(type == chrome::NOTIFICATION_PROFILE_DESTROYED) <<
83 "Unexpected notification type."; 85 "Unexpected notification type.";
84 if (content::Source<Profile>(source).ptr() == profile_) { 86 if (content::Source<Profile>(source).ptr() == profile_) {
85 notification_registrar_.RemoveAll(); 87 notification_registrar_.RemoveAll();
86 pref_change_registrar_.RemoveAll(); 88 pref_change_registrar_.RemoveAll();
87 profile_ = NULL; 89 profile_ = NULL;
88 } 90 }
89 } 91 }
90 92
91 void ExternalPolicyLoader::OnPreferenceChanged(PrefServiceBase* service,
92 const std::string& pref_name) {
93 if (service == profile_->GetPrefs()) {
94 DCHECK_EQ(std::string(prefs::kExtensionInstallForceList), pref_name);
95 StartLoading();
96 }
97 }
98
99 } // namespace extensions 93 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/external_policy_loader.h ('k') | chrome/browser/media_gallery/media_file_system_registry.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698