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 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 dict->Set(kValue, transformer->BrowserToExtensionPref(pref->GetValue())); | 302 dict->Set(kValue, transformer->BrowserToExtensionPref(pref->GetValue())); |
303 if (incognito) { | 303 if (incognito) { |
304 ExtensionPrefs* ep = extension_service->extension_prefs(); | 304 ExtensionPrefs* ep = extension_service->extension_prefs(); |
305 dict->SetBoolean(kIncognitoSpecific, | 305 dict->SetBoolean(kIncognitoSpecific, |
306 ep->HasIncognitoPrefValue(browser_pref)); | 306 ep->HasIncognitoPrefValue(browser_pref)); |
307 } | 307 } |
308 | 308 |
309 ExtensionEventRouter* router = profile_->GetExtensionEventRouter(); | 309 ExtensionEventRouter* router = profile_->GetExtensionEventRouter(); |
310 if (!router || !router->HasEventListener(event_name)) | 310 if (!router || !router->HasEventListener(event_name)) |
311 return; | 311 return; |
312 const ExtensionList* extensions = extension_service->extensions(); | 312 const ExtensionSet* extensions = extension_service->extensions(); |
313 for (ExtensionList::const_iterator it = extensions->begin(); | 313 for (ExtensionSet::const_iterator it = extensions->begin(); |
314 it != extensions->end(); ++it) { | 314 it != extensions->end(); ++it) { |
315 std::string extension_id = (*it)->id(); | 315 std::string extension_id = (*it)->id(); |
316 // TODO(bauerb): Only iterate over registered event listeners. | 316 // TODO(bauerb): Only iterate over registered event listeners. |
317 if (router->ExtensionHasEventListener(extension_id, event_name) && | 317 if (router->ExtensionHasEventListener(extension_id, event_name) && |
318 (*it)->HasAPIPermission(permission) && | 318 (*it)->HasAPIPermission(permission) && |
319 (!incognito || extension_service->CanCrossIncognito(*it))) { | 319 (!incognito || extension_service->CanCrossIncognito(*it))) { |
320 std::string level_of_control = | 320 std::string level_of_control = |
321 GetLevelOfControl(profile_, extension_id, browser_pref, incognito); | 321 GetLevelOfControl(profile_, extension_id, browser_pref, incognito); |
322 dict->SetString(kLevelOfControl, level_of_control); | 322 dict->SetString(kLevelOfControl, level_of_control); |
323 | 323 |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
504 pref_key, &browser_pref, &permission)); | 504 pref_key, &browser_pref, &permission)); |
505 if (!GetExtension()->HasAPIPermission(permission)) { | 505 if (!GetExtension()->HasAPIPermission(permission)) { |
506 error_ = ExtensionErrorUtils::FormatErrorMessage( | 506 error_ = ExtensionErrorUtils::FormatErrorMessage( |
507 keys::kPermissionErrorMessage, pref_key); | 507 keys::kPermissionErrorMessage, pref_key); |
508 return false; | 508 return false; |
509 } | 509 } |
510 ExtensionPrefs* prefs = profile_->GetExtensionService()->extension_prefs(); | 510 ExtensionPrefs* prefs = profile_->GetExtensionService()->extension_prefs(); |
511 prefs->RemoveExtensionControlledPref(extension_id(), browser_pref, scope); | 511 prefs->RemoveExtensionControlledPref(extension_id(), browser_pref, scope); |
512 return true; | 512 return true; |
513 } | 513 } |
OLD | NEW |