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

Side by Side Diff: chrome/browser/extensions/api/hotword_private/hotword_private_api.cc

Issue 238633009: cleanup: Use EventRouter instead of ExtensionSystem::Get->event_router() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix compile error for chromeos build. Created 6 years, 8 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/hotword_private/hotword_private_api.h" 5 #include "chrome/browser/extensions/api/hotword_private/hotword_private_api.h"
6 6
7 #include "base/lazy_instance.h" 7 #include "base/lazy_instance.h"
8 #include "base/prefs/pref_service.h" 8 #include "base/prefs/pref_service.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/search/hotword_service.h" 10 #include "chrome/browser/search/hotword_service.h"
11 #include "chrome/browser/search/hotword_service_factory.h" 11 #include "chrome/browser/search/hotword_service_factory.h"
12 #include "chrome/common/pref_names.h" 12 #include "chrome/common/pref_names.h"
13 #include "extensions/browser/event_router.h" 13 #include "extensions/browser/event_router.h"
14 #include "extensions/browser/extension_system.h"
15 14
16 namespace extensions { 15 namespace extensions {
17 16
18 namespace OnEnabledChanged = 17 namespace OnEnabledChanged =
19 api::hotword_private::OnEnabledChanged; 18 api::hotword_private::OnEnabledChanged;
20 19
21 static base::LazyInstance< 20 static base::LazyInstance<
22 BrowserContextKeyedAPIFactory<HotwordPrivateEventService> > g_factory = 21 BrowserContextKeyedAPIFactory<HotwordPrivateEventService> > g_factory =
23 LAZY_INSTANCE_INITIALIZER; 22 LAZY_INSTANCE_INITIALIZER;
24 23
(...skipping 26 matching lines...) Expand all
51 50
52 void HotwordPrivateEventService::OnEnabledChanged( 51 void HotwordPrivateEventService::OnEnabledChanged(
53 const std::string& pref_name) { 52 const std::string& pref_name) {
54 DCHECK_EQ(pref_name, std::string(prefs::kHotwordSearchEnabled)); 53 DCHECK_EQ(pref_name, std::string(prefs::kHotwordSearchEnabled));
55 SignalEvent(); 54 SignalEvent();
56 } 55 }
57 56
58 void HotwordPrivateEventService::SignalEvent() { 57 void HotwordPrivateEventService::SignalEvent() {
59 using OnEnabledChanged::kEventName; 58 using OnEnabledChanged::kEventName;
60 59
61 EventRouter* router = ExtensionSystem::Get(profile_)->event_router(); 60 EventRouter* router = EventRouter::Get(profile_);
62 if (!router || !router->HasEventListener(kEventName)) 61 if (!router || !router->HasEventListener(kEventName))
63 return; 62 return;
64 scoped_ptr<base::ListValue> args(new base::ListValue()); 63 scoped_ptr<base::ListValue> args(new base::ListValue());
65 scoped_ptr<Event> event(new Event(kEventName, args.Pass())); 64 scoped_ptr<Event> event(new Event(kEventName, args.Pass()));
66 router->BroadcastEvent(event.Pass()); 65 router->BroadcastEvent(event.Pass());
67 } 66 }
68 67
69 bool HotwordPrivateSetEnabledFunction::RunImpl() { 68 bool HotwordPrivateSetEnabledFunction::RunImpl() {
70 scoped_ptr<api::hotword_private::SetEnabled::Params> params( 69 scoped_ptr<api::hotword_private::SetEnabled::Params> params(
71 api::hotword_private::SetEnabled::Params::Create(*args_)); 70 api::hotword_private::SetEnabled::Params::Create(*args_));
(...skipping 29 matching lines...) Expand all
101 result.enabled = prefs->GetBoolean(prefs::kHotwordSearchEnabled); 100 result.enabled = prefs->GetBoolean(prefs::kHotwordSearchEnabled);
102 result.audio_logging_enabled = false; 101 result.audio_logging_enabled = false;
103 if (hotword_service) 102 if (hotword_service)
104 result.audio_logging_enabled = hotword_service->IsOptedIntoAudioLogging(); 103 result.audio_logging_enabled = hotword_service->IsOptedIntoAudioLogging();
105 104
106 SetResult(result.ToValue().release()); 105 SetResult(result.ToValue().release());
107 return true; 106 return true;
108 } 107 }
109 108
110 } // namespace extensions 109 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/history/history_api.cc ('k') | chrome/browser/extensions/api/identity/identity_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698