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

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

Issue 252653002: Rename (Chrome)SyncExtensionFunction::RunImpl to RunSync so that the RunImpl (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix bookmarks Created 6 years, 7 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 | Annotate | Revision Log
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"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 using OnEnabledChanged::kEventName; 58 using OnEnabledChanged::kEventName;
59 59
60 EventRouter* router = EventRouter::Get(profile_); 60 EventRouter* router = EventRouter::Get(profile_);
61 if (!router || !router->HasEventListener(kEventName)) 61 if (!router || !router->HasEventListener(kEventName))
62 return; 62 return;
63 scoped_ptr<base::ListValue> args(new base::ListValue()); 63 scoped_ptr<base::ListValue> args(new base::ListValue());
64 scoped_ptr<Event> event(new Event(kEventName, args.Pass())); 64 scoped_ptr<Event> event(new Event(kEventName, args.Pass()));
65 router->BroadcastEvent(event.Pass()); 65 router->BroadcastEvent(event.Pass());
66 } 66 }
67 67
68 bool HotwordPrivateSetEnabledFunction::RunImpl() { 68 bool HotwordPrivateSetEnabledFunction::RunSync() {
69 scoped_ptr<api::hotword_private::SetEnabled::Params> params( 69 scoped_ptr<api::hotword_private::SetEnabled::Params> params(
70 api::hotword_private::SetEnabled::Params::Create(*args_)); 70 api::hotword_private::SetEnabled::Params::Create(*args_));
71 EXTENSION_FUNCTION_VALIDATE(params.get()); 71 EXTENSION_FUNCTION_VALIDATE(params.get());
72 72
73 PrefService* prefs = GetProfile()->GetPrefs(); 73 PrefService* prefs = GetProfile()->GetPrefs();
74 prefs->SetBoolean(prefs::kHotwordSearchEnabled, params->state); 74 prefs->SetBoolean(prefs::kHotwordSearchEnabled, params->state);
75 return true; 75 return true;
76 } 76 }
77 77
78 bool HotwordPrivateSetAudioLoggingEnabledFunction::RunImpl() { 78 bool HotwordPrivateSetAudioLoggingEnabledFunction::RunSync() {
79 scoped_ptr<api::hotword_private::SetEnabled::Params> params( 79 scoped_ptr<api::hotword_private::SetEnabled::Params> params(
80 api::hotword_private::SetEnabled::Params::Create(*args_)); 80 api::hotword_private::SetEnabled::Params::Create(*args_));
81 EXTENSION_FUNCTION_VALIDATE(params.get()); 81 EXTENSION_FUNCTION_VALIDATE(params.get());
82 82
83 PrefService* prefs = GetProfile()->GetPrefs(); 83 PrefService* prefs = GetProfile()->GetPrefs();
84 prefs->SetBoolean(prefs::kHotwordAudioLoggingEnabled, params->state); 84 prefs->SetBoolean(prefs::kHotwordAudioLoggingEnabled, params->state);
85 return true; 85 return true;
86 } 86 }
87 87
88 bool HotwordPrivateGetStatusFunction::RunImpl() { 88 bool HotwordPrivateGetStatusFunction::RunSync() {
89 api::hotword_private::StatusDetails result; 89 api::hotword_private::StatusDetails result;
90 90
91 HotwordService* hotword_service = 91 HotwordService* hotword_service =
92 HotwordServiceFactory::GetForProfile(GetProfile()); 92 HotwordServiceFactory::GetForProfile(GetProfile());
93 if (!hotword_service) 93 if (!hotword_service)
94 result.available = false; 94 result.available = false;
95 else 95 else
96 result.available = hotword_service->IsServiceAvailable(); 96 result.available = hotword_service->IsServiceAvailable();
97 97
98 PrefService* prefs = GetProfile()->GetPrefs(); 98 PrefService* prefs = GetProfile()->GetPrefs();
99 result.enabled_set = prefs->HasPrefPath(prefs::kHotwordSearchEnabled); 99 result.enabled_set = prefs->HasPrefPath(prefs::kHotwordSearchEnabled);
100 result.enabled = prefs->GetBoolean(prefs::kHotwordSearchEnabled); 100 result.enabled = prefs->GetBoolean(prefs::kHotwordSearchEnabled);
101 result.audio_logging_enabled = false; 101 result.audio_logging_enabled = false;
102 if (hotword_service) 102 if (hotword_service)
103 result.audio_logging_enabled = hotword_service->IsOptedIntoAudioLogging(); 103 result.audio_logging_enabled = hotword_service->IsOptedIntoAudioLogging();
104 104
105 SetResult(result.ToValue().release()); 105 SetResult(result.ToValue().release());
106 return true; 106 return true;
107 } 107 }
108 108
109 } // namespace extensions 109 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/hotword_private/hotword_private_api.h ('k') | chrome/browser/extensions/api/i18n/i18n_api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698