 Chromium Code Reviews
 Chromium Code Reviews Issue 11307020:
  Cleanup: Simplify some extensions / content_settings Observer code by simply DCHECKING instead of u…  (Closed) 
  Base URL: svn://chrome-svn/chrome/trunk/src/
    
  
    Issue 11307020:
  Cleanup: Simplify some extensions / content_settings Observer code by simply DCHECKING instead of u…  (Closed) 
  Base URL: svn://chrome-svn/chrome/trunk/src/| 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 switch (type) { | 
| 83 case chrome::NOTIFICATION_PREF_CHANGED: { | 83 case chrome::NOTIFICATION_PREF_CHANGED: { | 
| 84 if (content::Source<PrefService>(source).ptr() == profile_->GetPrefs()) { | 84 if (content::Source<PrefService>(source).ptr() == profile_->GetPrefs()) { | 
| 85 std::string* pref_name = content::Details<std::string>(details).ptr(); | 85 DCHECK_EQ(*content::Details<std::string>(details).ptr(), | 
| 
Yoyo Zhou
2012/10/27 15:45:03
ditto
 
Lei Zhang
2012/10/30 00:01:45
If the DCHECK_EQ fails, it will print "expected fo
 | |
| 86 if (*pref_name == prefs::kExtensionInstallForceList) { | 86 std::string(prefs::kExtensionInstallForceList)); | 
| 87 StartLoading(); | 87 StartLoading(); | 
| 88 } else { | |
| 89 NOTREACHED() << "Unexpected preference name."; | |
| 90 } | |
| 91 } | 88 } | 
| 92 break; | 89 break; | 
| 93 } | 90 } | 
| 94 case chrome::NOTIFICATION_PROFILE_DESTROYED: { | 91 case chrome::NOTIFICATION_PROFILE_DESTROYED: { | 
| 95 if (content::Source<Profile>(source).ptr() == profile_) { | 92 if (content::Source<Profile>(source).ptr() == profile_) { | 
| 96 notification_registrar_.RemoveAll(); | 93 notification_registrar_.RemoveAll(); | 
| 97 pref_change_registrar_.RemoveAll(); | 94 pref_change_registrar_.RemoveAll(); | 
| 98 profile_ = NULL; | 95 profile_ = NULL; | 
| 99 } | 96 } | 
| 100 break; | 97 break; | 
| 101 } | 98 } | 
| 102 default: | 99 default: | 
| 103 NOTREACHED() << "Unexpected notification type."; | 100 NOTREACHED() << "Unexpected notification type."; | 
| 104 } | 101 } | 
| 105 } | 102 } | 
| 106 | 103 | 
| 107 } // namespace extensions | 104 } // namespace extensions | 
| OLD | NEW |