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

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

Issue 631913004: Open the launcher when hotword is triggered in always-on mode. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@hotword-google-com-ntp
Patch Set: Fix android build Created 6 years, 2 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
« no previous file with comments | « no previous file | chrome/browser/search/hotword_service.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/command_line.h" 7 #include "base/command_line.h"
8 #include "base/lazy_instance.h" 8 #include "base/lazy_instance.h"
9 #include "base/prefs/pref_service.h" 9 #include "base/prefs/pref_service.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
11 #include "chrome/browser/search/hotword_client.h" 11 #include "chrome/browser/search/hotword_client.h"
12 #include "chrome/browser/search/hotword_service.h" 12 #include "chrome/browser/search/hotword_service.h"
13 #include "chrome/browser/search/hotword_service_factory.h" 13 #include "chrome/browser/search/hotword_service_factory.h"
14 #include "chrome/browser/ui/app_list/app_list_service.h"
15 #include "chrome/browser/ui/browser.h"
14 #include "chrome/common/chrome_switches.h" 16 #include "chrome/common/chrome_switches.h"
15 #include "chrome/common/pref_names.h" 17 #include "chrome/common/pref_names.h"
16 #include "extensions/browser/event_router.h" 18 #include "extensions/browser/event_router.h"
17 19
18 namespace extensions { 20 namespace extensions {
19 21
20 namespace hotword_private_constants { 22 namespace hotword_private_constants {
21 const char kHotwordServiceUnavailable[] = "Hotword Service is unavailable."; 23 const char kHotwordServiceUnavailable[] = "Hotword Service is unavailable.";
22 } // hotword_private_constants 24 } // hotword_private_constants
23 25
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 HotwordService* hotword_service = 152 HotwordService* hotword_service =
151 HotwordServiceFactory::GetForProfile(GetProfile()); 153 HotwordServiceFactory::GetForProfile(GetProfile());
152 if (hotword_service && hotword_service->client()) 154 if (hotword_service && hotword_service->client())
153 hotword_service->client()->OnHotwordStateChanged(params->started); 155 hotword_service->client()->OnHotwordStateChanged(params->started);
154 return true; 156 return true;
155 } 157 }
156 158
157 bool HotwordPrivateNotifyHotwordRecognitionFunction::RunSync() { 159 bool HotwordPrivateNotifyHotwordRecognitionFunction::RunSync() {
158 HotwordService* hotword_service = 160 HotwordService* hotword_service =
159 HotwordServiceFactory::GetForProfile(GetProfile()); 161 HotwordServiceFactory::GetForProfile(GetProfile());
160 if (hotword_service && hotword_service->client()) 162 if (hotword_service) {
161 hotword_service->client()->OnHotwordRecognized(); 163 if (hotword_service->client()) {
164 hotword_service->client()->OnHotwordRecognized();
165 } else if (HotwordService::IsExperimentalHotwordingEnabled() &&
166 hotword_service->IsAlwaysOnEnabled()) {
167 Browser* browser = GetCurrentBrowser();
168 // If a Browser does not exist, fall back to the universally available,
169 // but not recommended, way.
170 AppListService* app_list_service = AppListService::Get(
171 browser ? browser->host_desktop_type() : chrome::GetActiveDesktop());
172 CHECK(app_list_service);
173 app_list_service->ShowForVoiceSearch(GetProfile());
174 }
175 }
162 return true; 176 return true;
163 } 177 }
164 178
165 bool HotwordPrivateGetLaunchStateFunction::RunSync() { 179 bool HotwordPrivateGetLaunchStateFunction::RunSync() {
166 api::hotword_private::LaunchState result; 180 api::hotword_private::LaunchState result;
167 181
168 HotwordService* hotword_service = 182 HotwordService* hotword_service =
169 HotwordServiceFactory::GetForProfile(GetProfile()); 183 HotwordServiceFactory::GetForProfile(GetProfile());
170 if (!hotword_service) { 184 if (!hotword_service) {
171 error_ = hotword_private_constants::kHotwordServiceUnavailable; 185 error_ = hotword_private_constants::kHotwordServiceUnavailable;
172 return false; 186 return false;
173 } else { 187 } else {
174 result.launch_mode = 188 result.launch_mode =
175 hotword_service->GetHotwordAudioVerificationLaunchMode(); 189 hotword_service->GetHotwordAudioVerificationLaunchMode();
176 } 190 }
177 191
178 SetResult(result.ToValue().release()); 192 SetResult(result.ToValue().release());
179 return true; 193 return true;
180 } 194 }
181 195
182 } // namespace extensions 196 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/search/hotword_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698