OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/ui/webui/app_list/start_page_handler.h" | 5 #include "chrome/browser/ui/webui/app_list/start_page_handler.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 // TODO(mukai): remove this after everything gets stable. | 137 // TODO(mukai): remove this after everything gets stable. |
138 Profile* profile = Profile::FromWebUI(web_ui()); | 138 Profile* profile = Profile::FromWebUI(web_ui()); |
139 | 139 |
140 extensions::ExtensionRegistry* registry = | 140 extensions::ExtensionRegistry* registry = |
141 extensions::ExtensionRegistry::Get(profile); | 141 extensions::ExtensionRegistry::Get(profile); |
142 const extensions::Extension* hotword_extension = | 142 const extensions::Extension* hotword_extension = |
143 registry->GetExtensionById(extension_misc::kHotwordExtensionId, | 143 registry->GetExtensionById(extension_misc::kHotwordExtensionId, |
144 extensions::ExtensionRegistry::ENABLED); | 144 extensions::ExtensionRegistry::ENABLED); |
145 if (hotword_extension && | 145 if (hotword_extension && |
146 hotword_extension->version()->CompareTo( | 146 hotword_extension->version()->CompareTo( |
147 base::Version(kOldHotwordExtensionVersionString)) <= 0) { | 147 base::Version(kOldHotwordExtensionVersionString)) <= 0 && |
| 148 !HotwordService::IsExperimentalHotwordingEnabled()) { |
148 StartPageService* service = StartPageService::Get(profile); | 149 StartPageService* service = StartPageService::Get(profile); |
149 web_ui()->CallJavascriptFunction( | 150 web_ui()->CallJavascriptFunction( |
150 "appList.startPage.setHotwordEnabled", | 151 "appList.startPage.setHotwordEnabled", |
151 base::FundamentalValue(service->HotwordEnabled())); | 152 base::FundamentalValue(service->HotwordEnabled())); |
152 } | 153 } |
153 } | 154 } |
154 #endif | 155 #endif |
155 | 156 |
156 void StartPageHandler::HandleInitialize(const base::ListValue* args) { | 157 void StartPageHandler::HandleInitialize(const base::ListValue* args) { |
157 Profile* profile = Profile::FromWebUI(web_ui()); | 158 Profile* profile = Profile::FromWebUI(web_ui()); |
(...skipping 28 matching lines...) Expand all Loading... |
186 if (hotword_extension && | 187 if (hotword_extension && |
187 hotword_extension->version()->CompareTo( | 188 hotword_extension->version()->CompareTo( |
188 base::Version(kOldHotwordExtensionVersionString)) <= 0) { | 189 base::Version(kOldHotwordExtensionVersionString)) <= 0) { |
189 web_ui()->CallJavascriptFunction( | 190 web_ui()->CallJavascriptFunction( |
190 "appList.startPage.setNaclArch", | 191 "appList.startPage.setNaclArch", |
191 base::StringValue(omaha_query_params::OmahaQueryParams::GetNaclArch())); | 192 base::StringValue(omaha_query_params::OmahaQueryParams::GetNaclArch())); |
192 } | 193 } |
193 #endif | 194 #endif |
194 | 195 |
195 if (!app_list::switches::IsExperimentalAppListEnabled()) { | 196 if (!app_list::switches::IsExperimentalAppListEnabled()) { |
| 197 // If experimental hotwording is enabled, don't enable hotwording in the |
| 198 // start page, since the hotword extension is taking care of this. |
| 199 bool hotword_enabled = service->HotwordEnabled() && |
| 200 !HotwordService::IsExperimentalHotwordingEnabled(); |
196 web_ui()->CallJavascriptFunction( | 201 web_ui()->CallJavascriptFunction( |
197 "appList.startPage.onAppListShown", | 202 "appList.startPage.onAppListShown", |
198 base::FundamentalValue(service->HotwordEnabled())); | 203 base::FundamentalValue(hotword_enabled)); |
199 } | 204 } |
200 } | 205 } |
201 | 206 |
202 void StartPageHandler::HandleLaunchApp(const base::ListValue* args) { | 207 void StartPageHandler::HandleLaunchApp(const base::ListValue* args) { |
203 std::string app_id; | 208 std::string app_id; |
204 CHECK(args->GetString(0, &app_id)); | 209 CHECK(args->GetString(0, &app_id)); |
205 | 210 |
206 Profile* profile = Profile::FromWebUI(web_ui()); | 211 Profile* profile = Profile::FromWebUI(web_ui()); |
207 const extensions::Extension* app = | 212 const extensions::Extension* app = |
208 extensions::ExtensionRegistry::Get(profile) | 213 extensions::ExtensionRegistry::Get(profile) |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 else if (state_string == "NETWORK_ERROR") | 265 else if (state_string == "NETWORK_ERROR") |
261 new_state = SPEECH_RECOGNITION_NETWORK_ERROR; | 266 new_state = SPEECH_RECOGNITION_NETWORK_ERROR; |
262 | 267 |
263 StartPageService* service = | 268 StartPageService* service = |
264 StartPageService::Get(Profile::FromWebUI(web_ui())); | 269 StartPageService::Get(Profile::FromWebUI(web_ui())); |
265 if (service) | 270 if (service) |
266 service->OnSpeechRecognitionStateChanged(new_state); | 271 service->OnSpeechRecognitionStateChanged(new_state); |
267 } | 272 } |
268 | 273 |
269 } // namespace app_list | 274 } // namespace app_list |
OLD | NEW |