Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(210)

Side by Side Diff: chrome/browser/extensions/api/preference/preference_helpers.cc

Issue 1236493004: Final batch adding real histogram values for extension events. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments, rebase, dcheck, etc Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/prefs/pref_service.h" 8 #include "base/prefs/pref_service.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "chrome/browser/extensions/api/preference/preference_api.h" 10 #include "chrome/browser/extensions/api/preference/preference_api.h"
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 75
76 if (PreferenceAPI::Get(profile)->CanExtensionControlPref(extension_id, 76 if (PreferenceAPI::Get(profile)->CanExtensionControlPref(extension_id,
77 browser_pref, 77 browser_pref,
78 incognito)) { 78 incognito)) {
79 return kControllableByThisExtension; 79 return kControllableByThisExtension;
80 } 80 }
81 81
82 return kControlledByOtherExtensions; 82 return kControlledByOtherExtensions;
83 } 83 }
84 84
85 void DispatchEventToExtensions( 85 void DispatchEventToExtensions(Profile* profile,
86 Profile* profile, 86 events::HistogramValue histogram_value,
87 const std::string& event_name, 87 const std::string& event_name,
88 base::ListValue* args, 88 base::ListValue* args,
89 APIPermission::ID permission, 89 APIPermission::ID permission,
90 bool incognito, 90 bool incognito,
91 const std::string& browser_pref) { 91 const std::string& browser_pref) {
92 EventRouter* router = EventRouter::Get(profile); 92 EventRouter* router = EventRouter::Get(profile);
93 if (!router || !router->HasEventListener(event_name)) 93 if (!router || !router->HasEventListener(event_name))
94 return; 94 return;
95 95
96 for (const scoped_refptr<const extensions::Extension>& extension : 96 for (const scoped_refptr<const extensions::Extension>& extension :
97 ExtensionRegistry::Get(profile)->enabled_extensions()) { 97 ExtensionRegistry::Get(profile)->enabled_extensions()) {
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 extension->permissions_data()->HasAPIPermission(permission) && 100 extension->permissions_data()->HasAPIPermission(permission) &&
101 (!incognito || IncognitoInfo::IsSplitMode(extension.get()) || 101 (!incognito || IncognitoInfo::IsSplitMode(extension.get()) ||
(...skipping 18 matching lines...) Expand all
120 } else if (!incognito && 120 } else if (!incognito &&
121 PreferenceAPI::Get(profile)->DoesExtensionControlPref( 121 PreferenceAPI::Get(profile)->DoesExtensionControlPref(
122 extension->id(), browser_pref, &from_incognito) && 122 extension->id(), browser_pref, &from_incognito) &&
123 from_incognito) { 123 from_incognito) {
124 restrict_to_profile = profile; 124 restrict_to_profile = profile;
125 } 125 }
126 } 126 }
127 127
128 scoped_ptr<base::ListValue> args_copy(args->DeepCopy()); 128 scoped_ptr<base::ListValue> args_copy(args->DeepCopy());
129 scoped_ptr<Event> event( 129 scoped_ptr<Event> event(
130 new Event(events::UNKNOWN, event_name, args_copy.Pass())); 130 new Event(histogram_value, event_name, args_copy.Pass()));
131 event->restrict_to_browser_context = restrict_to_profile; 131 event->restrict_to_browser_context = restrict_to_profile;
132 router->DispatchEventToExtension(extension->id(), event.Pass()); 132 router->DispatchEventToExtension(extension->id(), event.Pass());
133 } 133 }
134 } 134 }
135 } 135 }
136 136
137 } // namespace preference_helpers 137 } // namespace preference_helpers
138 } // namespace extensions 138 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698