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

Unified Diff: chrome/browser/extensions/system/system_api.cc

Issue 10911261: chromeos: Stop calling ProfileManager::GetDefaultProfile() from extension event dispatch functions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added function comments Created 8 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/system/system_api.cc
diff --git a/chrome/browser/extensions/system/system_api.cc b/chrome/browser/extensions/system/system_api.cc
index 1e1eff642351709030c7ce181f49759432dc83fe..24ae6e9d97f8fac4aa130bcfa090e2e5c2fd7b37 100644
--- a/chrome/browser/extensions/system/system_api.cc
+++ b/chrome/browser/extensions/system/system_api.cc
@@ -7,6 +7,7 @@
#include "base/json/json_writer.h"
#include "base/values.h"
#include "chrome/browser/extensions/event_router.h"
+#include "chrome/browser/extensions/extension_system.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
@@ -49,12 +50,17 @@ const char kOnScreenUnlocked[] = "systemPrivate.onScreenUnlocked";
const char kOnWokeUp[] = "systemPrivate.onWokeUp";
// Dispatches an extension event with |args|
-void DispatchEvent(const std::string& event_name, base::Value* argument) {
- Profile* profile = ProfileManager::GetDefaultProfile();
- if (!profile)
+void DispatchEvent(Profile* profile,
+ const std::string& event_name,
+ base::Value* argument) {
+ DCHECK(profile);
+
+ extensions::ExtensionSystem* extension_system =
+ extensions::ExtensionSystem::Get(profile);
+ if (!extension_system)
return;
extensions::EventRouter* extension_event_router =
- profile->GetExtensionEventRouter();
+ extension_system->event_router();
if (!extension_event_router)
return;
@@ -142,26 +148,30 @@ bool GetUpdateStatusFunction::RunImpl() {
return true;
}
-void DispatchVolumeChangedEvent(double volume, bool is_volume_muted) {
+void DispatchVolumeChangedEvent(Profile* profile,
+ double volume,
+ bool is_volume_muted) {
DictionaryValue* dict = new DictionaryValue();
dict->SetDouble(kVolumeKey, volume);
dict->SetBoolean(kIsVolumeMutedKey, is_volume_muted);
- DispatchEvent(kOnVolumeChanged, dict);
+ DispatchEvent(profile, kOnVolumeChanged, dict);
}
-void DispatchBrightnessChangedEvent(int brightness, bool user_initiated) {
+void DispatchBrightnessChangedEvent(Profile* profile,
+ int brightness,
+ bool user_initiated) {
DictionaryValue* dict = new DictionaryValue();
dict->SetInteger(kBrightnessKey, brightness);
dict->SetBoolean(kUserInitiatedKey, user_initiated);
- DispatchEvent(kOnBrightnessChanged, dict);
+ DispatchEvent(profile, kOnBrightnessChanged, dict);
}
-void DispatchScreenUnlockedEvent() {
- DispatchEvent(kOnScreenUnlocked, NULL);
+void DispatchScreenUnlockedEvent(Profile* profile) {
+ DispatchEvent(profile, kOnScreenUnlocked, NULL);
}
-void DispatchWokeUpEvent() {
- DispatchEvent(kOnWokeUp, NULL);
+void DispatchWokeUpEvent(Profile* profile) {
+ DispatchEvent(profile, kOnWokeUp, NULL);
}
} // namespace extensions

Powered by Google App Engine
This is Rietveld 408576698