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/extension_preference_helpers.h" | 5 #include "chrome/browser/extensions/extension_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/extension_event_router.h" | 9 #include "chrome/browser/extensions/extension_event_router.h" |
10 #include "chrome/browser/extensions/extension_prefs.h" | 10 #include "chrome/browser/extensions/extension_prefs.h" |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 if (ep->CanExtensionControlPref(extension_id, browser_pref, incognito)) | 65 if (ep->CanExtensionControlPref(extension_id, browser_pref, incognito)) |
66 return kControllableByThisExtension; | 66 return kControllableByThisExtension; |
67 | 67 |
68 return kControlledByOtherExtensions; | 68 return kControlledByOtherExtensions; |
69 } | 69 } |
70 | 70 |
71 void DispatchEventToExtensions( | 71 void DispatchEventToExtensions( |
72 Profile* profile, | 72 Profile* profile, |
73 const std::string& event_name, | 73 const std::string& event_name, |
74 ListValue* args, | 74 ListValue* args, |
75 ExtensionAPIPermission::ID permission, | 75 extensions::APIPermission::ID permission, |
76 bool incognito, | 76 bool incognito, |
77 const std::string& browser_pref) { | 77 const std::string& browser_pref) { |
78 ExtensionEventRouter* router = profile->GetExtensionEventRouter(); | 78 ExtensionEventRouter* router = profile->GetExtensionEventRouter(); |
79 if (!router || !router->HasEventListener(event_name)) | 79 if (!router || !router->HasEventListener(event_name)) |
80 return; | 80 return; |
81 ExtensionService* extension_service = profile->GetExtensionService(); | 81 ExtensionService* extension_service = profile->GetExtensionService(); |
82 const ExtensionSet* extensions = extension_service->extensions(); | 82 const ExtensionSet* extensions = extension_service->extensions(); |
83 for (ExtensionSet::const_iterator it = extensions->begin(); | 83 for (ExtensionSet::const_iterator it = extensions->begin(); |
84 it != extensions->end(); ++it) { | 84 it != extensions->end(); ++it) { |
85 std::string extension_id = (*it)->id(); | 85 std::string extension_id = (*it)->id(); |
(...skipping 11 matching lines...) Expand all Loading... |
97 | 97 |
98 std::string json_args; | 98 std::string json_args; |
99 base::JSONWriter::Write(args, &json_args); | 99 base::JSONWriter::Write(args, &json_args); |
100 router->DispatchEventToExtension( | 100 router->DispatchEventToExtension( |
101 extension_id, event_name, json_args, NULL, GURL()); | 101 extension_id, event_name, json_args, NULL, GURL()); |
102 } | 102 } |
103 } | 103 } |
104 } | 104 } |
105 | 105 |
106 } // namespace extension_preference_helpers | 106 } // namespace extension_preference_helpers |
OLD | NEW |