| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/extension_preference_api.h" | 5 #include "chrome/browser/extensions/extension_preference_api.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 | 8 |
| 9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
| 10 #include "base/memory/singleton.h" | 10 #include "base/memory/singleton.h" |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 dict->Set(kValue, transformer->BrowserToExtensionPref(pref->GetValue())); | 309 dict->Set(kValue, transformer->BrowserToExtensionPref(pref->GetValue())); |
| 310 if (incognito) { | 310 if (incognito) { |
| 311 ExtensionPrefs* ep = extension_service->extension_prefs(); | 311 ExtensionPrefs* ep = extension_service->extension_prefs(); |
| 312 dict->SetBoolean(kIncognitoSpecific, | 312 dict->SetBoolean(kIncognitoSpecific, |
| 313 ep->HasIncognitoPrefValue(browser_pref)); | 313 ep->HasIncognitoPrefValue(browser_pref)); |
| 314 } | 314 } |
| 315 | 315 |
| 316 ExtensionEventRouter* router = profile_->GetExtensionEventRouter(); | 316 ExtensionEventRouter* router = profile_->GetExtensionEventRouter(); |
| 317 if (!router || !router->HasEventListener(event_name)) | 317 if (!router || !router->HasEventListener(event_name)) |
| 318 return; | 318 return; |
| 319 const ExtensionList* extensions = extension_service->extensions(); | 319 const ExtensionSet* extensions = extension_service->extensions(); |
| 320 for (ExtensionList::const_iterator it = extensions->begin(); | 320 for (ExtensionSet::const_iterator it = extensions->begin(); |
| 321 it != extensions->end(); ++it) { | 321 it != extensions->end(); ++it) { |
| 322 std::string extension_id = (*it)->id(); | 322 std::string extension_id = (*it)->id(); |
| 323 // TODO(bauerb): Only iterate over registered event listeners. | 323 // TODO(bauerb): Only iterate over registered event listeners. |
| 324 if (router->ExtensionHasEventListener(extension_id, event_name) && | 324 if (router->ExtensionHasEventListener(extension_id, event_name) && |
| 325 (*it)->HasAPIPermission(permission) && | 325 (*it)->HasAPIPermission(permission) && |
| 326 (!incognito || extension_service->CanCrossIncognito(*it))) { | 326 (!incognito || extension_service->CanCrossIncognito(*it))) { |
| 327 std::string level_of_control = | 327 std::string level_of_control = |
| 328 GetLevelOfControl(profile_, extension_id, browser_pref, incognito); | 328 GetLevelOfControl(profile_, extension_id, browser_pref, incognito); |
| 329 dict->SetString(kLevelOfControl, level_of_control); | 329 dict->SetString(kLevelOfControl, level_of_control); |
| 330 | 330 |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 511 pref_key, &browser_pref, &permission)); | 511 pref_key, &browser_pref, &permission)); |
| 512 if (!GetExtension()->HasAPIPermission(permission)) { | 512 if (!GetExtension()->HasAPIPermission(permission)) { |
| 513 error_ = ExtensionErrorUtils::FormatErrorMessage( | 513 error_ = ExtensionErrorUtils::FormatErrorMessage( |
| 514 keys::kPermissionErrorMessage, pref_key); | 514 keys::kPermissionErrorMessage, pref_key); |
| 515 return false; | 515 return false; |
| 516 } | 516 } |
| 517 ExtensionPrefs* prefs = profile_->GetExtensionService()->extension_prefs(); | 517 ExtensionPrefs* prefs = profile_->GetExtensionService()->extension_prefs(); |
| 518 prefs->RemoveExtensionControlledPref(extension_id(), browser_pref, scope); | 518 prefs->RemoveExtensionControlledPref(extension_id(), browser_pref, scope); |
| 519 return true; | 519 return true; |
| 520 } | 520 } |
| OLD | NEW |