OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/chrome_direct_setting_api.h" | 5 #include "chrome/browser/extensions/api/preference/chrome_direct_setting_api.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/containers/hash_tables.h" | 8 #include "base/containers/hash_tables.h" |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "base/prefs/pref_change_registrar.h" | 10 #include "base/prefs/pref_change_registrar.h" |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 scoped_ptr<base::DictionaryValue> result(new base::DictionaryValue); | 138 scoped_ptr<base::DictionaryValue> result(new base::DictionaryValue); |
139 result->Set(preference_api_constants::kValue, value->DeepCopy()); | 139 result->Set(preference_api_constants::kValue, value->DeepCopy()); |
140 base::ListValue args; | 140 base::ListValue args; |
141 args.Append(result.release()); | 141 args.Append(result.release()); |
142 | 142 |
143 for (const scoped_refptr<const extensions::Extension>& extension : | 143 for (const scoped_refptr<const extensions::Extension>& extension : |
144 ExtensionRegistry::Get(profile_)->enabled_extensions()) { | 144 ExtensionRegistry::Get(profile_)->enabled_extensions()) { |
145 const std::string& extension_id = extension->id(); | 145 const std::string& extension_id = extension->id(); |
146 if (router->ExtensionHasEventListener(extension_id, event_name)) { | 146 if (router->ExtensionHasEventListener(extension_id, event_name)) { |
147 scoped_ptr<base::ListValue> args_copy(args.DeepCopy()); | 147 scoped_ptr<base::ListValue> args_copy(args.DeepCopy()); |
| 148 // TODO(kalman): Have a histogram value for each pref type. |
| 149 // This isn't so important for the current use case of these |
| 150 // histograms, which is to track which event types are waking up event |
| 151 // pages, or which are delivered to persistent background pages. Simply |
| 152 // "a setting changed" is enough detail for that. However if we try to |
| 153 // use these histograms for any fine-grained logic (like removing the |
| 154 // string event name altogether), or if we discover this event is |
| 155 // firing a lot and want to understand that better, then this will need |
| 156 // to change. |
| 157 events::HistogramValue histogram_value = |
| 158 events::TYPES_PRIVATE_CHROME_DIRECT_SETTING_ON_CHANGE; |
148 scoped_ptr<Event> event( | 159 scoped_ptr<Event> event( |
149 new Event(events::UNKNOWN, event_name, args_copy.Pass())); | 160 new Event(histogram_value, event_name, args_copy.Pass())); |
150 router->DispatchEventToExtension(extension_id, event.Pass()); | 161 router->DispatchEventToExtension(extension_id, event.Pass()); |
151 } | 162 } |
152 } | 163 } |
153 } | 164 } |
154 } | 165 } |
155 | 166 |
156 } // namespace chromedirectsetting | 167 } // namespace chromedirectsetting |
157 } // namespace extensions | 168 } // namespace extensions |
OLD | NEW |