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/api/preference/preference_helpers.h" | 5 #include "chrome/browser/extensions/api/preference/preference_helpers.h" |
6 | 6 |
7 #include "base/json/json_writer.h" | 7 #include "base/json/json_writer.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "chrome/browser/extensions/event_router.h" | 9 #include "chrome/browser/extensions/event_router.h" |
10 #include "chrome/browser/extensions/extension_prefs.h" | 10 #include "chrome/browser/extensions/extension_prefs.h" |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 const ExtensionSet* extensions = extension_service->extensions(); | 92 const ExtensionSet* extensions = extension_service->extensions(); |
93 extensions::ExtensionPrefs* extension_prefs = | 93 extensions::ExtensionPrefs* extension_prefs = |
94 extension_service->extension_prefs(); | 94 extension_service->extension_prefs(); |
95 for (ExtensionSet::const_iterator it = extensions->begin(); | 95 for (ExtensionSet::const_iterator it = extensions->begin(); |
96 it != extensions->end(); ++it) { | 96 it != extensions->end(); ++it) { |
97 std::string extension_id = (*it)->id(); | 97 std::string extension_id = (*it)->id(); |
98 // TODO(bauerb): Only iterate over registered event listeners. | 98 // TODO(bauerb): Only iterate over registered event listeners. |
99 if (router->ExtensionHasEventListener(extension_id, event_name) && | 99 if (router->ExtensionHasEventListener(extension_id, event_name) && |
100 (*it)->HasAPIPermission(permission) && | 100 (*it)->HasAPIPermission(permission) && |
101 (!incognito || (*it)->incognito_split_mode() || | 101 (!incognito || (*it)->incognito_split_mode() || |
102 extension_service->CanCrossIncognito(*it))) { | 102 extension_service->CanCrossIncognito(*it.get()))) { |
103 // Inject level of control key-value. | 103 // Inject level of control key-value. |
104 DictionaryValue* dict; | 104 DictionaryValue* dict; |
105 bool rv = args->GetDictionary(0, &dict); | 105 bool rv = args->GetDictionary(0, &dict); |
106 DCHECK(rv); | 106 DCHECK(rv); |
107 std::string level_of_control = | 107 std::string level_of_control = |
108 GetLevelOfControl(profile, extension_id, browser_pref, incognito); | 108 GetLevelOfControl(profile, extension_id, browser_pref, incognito); |
109 dict->SetString(kLevelOfControlKey, level_of_control); | 109 dict->SetString(kLevelOfControlKey, level_of_control); |
110 | 110 |
111 // If the extension is in incognito split mode, | 111 // If the extension is in incognito split mode, |
112 // a) incognito pref changes are visible only to the incognito tabs | 112 // a) incognito pref changes are visible only to the incognito tabs |
(...skipping 17 matching lines...) Expand all Loading... |
130 scoped_ptr<ListValue> args_copy(args->DeepCopy()); | 130 scoped_ptr<ListValue> args_copy(args->DeepCopy()); |
131 router->DispatchEventToExtension( | 131 router->DispatchEventToExtension( |
132 extension_id, event_name, args_copy.Pass(), restrict_to_profile, | 132 extension_id, event_name, args_copy.Pass(), restrict_to_profile, |
133 GURL()); | 133 GURL()); |
134 } | 134 } |
135 } | 135 } |
136 } | 136 } |
137 | 137 |
138 } // namespace preference_helpers | 138 } // namespace preference_helpers |
139 } // namespace extensions | 139 } // namespace extensions |
OLD | NEW |