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 #ifndef CHROME_BROWSER_UI_WEBUI_APP_LIST_START_PAGE_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_APP_LIST_START_PAGE_HANDLER_H_ |
6 #define CHROME_BROWSER_UI_WEBUI_APP_LIST_START_PAGE_HANDLER_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_APP_LIST_START_PAGE_HANDLER_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/prefs/pref_change_registrar.h" | 10 #include "base/prefs/pref_change_registrar.h" |
11 #include "chrome/browser/ui/app_list/hotword_background_activity_delegate.h" | |
12 #include "chrome/browser/ui/app_list/recommended_apps_observer.h" | 11 #include "chrome/browser/ui/app_list/recommended_apps_observer.h" |
13 #include "content/public/browser/notification_observer.h" | 12 #include "content/public/browser/notification_observer.h" |
14 #include "content/public/browser/notification_registrar.h" | 13 #include "content/public/browser/notification_registrar.h" |
15 #include "content/public/browser/web_ui_message_handler.h" | 14 #include "content/public/browser/web_ui_message_handler.h" |
16 #include "ui/app_list/speech_ui_model_observer.h" | |
17 | 15 |
18 namespace base { | 16 namespace base { |
19 class ListValue; | 17 class ListValue; |
20 } | 18 } |
21 | 19 |
22 namespace app_list { | 20 namespace app_list { |
23 | 21 |
24 class HotwordBackgroundActivityMonitor; | |
25 class RecommendedApps; | 22 class RecommendedApps; |
26 | 23 |
27 // Handler for the app launcher start page. | 24 // Handler for the app launcher start page. |
28 class StartPageHandler : public content::WebUIMessageHandler, | 25 class StartPageHandler : public content::WebUIMessageHandler, |
29 public content::NotificationObserver, | 26 public content::NotificationObserver, |
30 public HotwordBackgroundActivityDelegate, | |
31 public RecommendedAppsObserver { | 27 public RecommendedAppsObserver { |
32 public: | 28 public: |
33 StartPageHandler(); | 29 StartPageHandler(); |
34 virtual ~StartPageHandler(); | 30 virtual ~StartPageHandler(); |
35 | 31 |
36 private: | 32 private: |
37 // content::WebUIMessageHandler overrides: | 33 // content::WebUIMessageHandler overrides: |
38 virtual void RegisterMessages() OVERRIDE; | 34 virtual void RegisterMessages() OVERRIDE; |
39 | 35 |
40 // content::NotificationObserver overrides: | 36 // Overridden from content::NotificationObserver: |
41 virtual void Observe(int type, | 37 virtual void Observe(int type, |
42 const content::NotificationSource& source, | 38 const content::NotificationSource& source, |
43 const content::NotificationDetails& details) OVERRIDE; | 39 const content::NotificationDetails& details) OVERRIDE; |
44 | 40 |
45 // HotwordBackgroundActivityDelegate overrides: | |
46 virtual int GetRenderProcessID() OVERRIDE; | |
47 virtual void OnHotwordBackgroundActivityChanged() OVERRIDE; | |
48 | |
49 // RecommendedAppsObserver overrdies: | 41 // RecommendedAppsObserver overrdies: |
50 virtual void OnRecommendedAppsChanged() OVERRIDE; | 42 virtual void OnRecommendedAppsChanged() OVERRIDE; |
51 | 43 |
52 // Creates a ListValue for the recommended apps and sends it to js side. | 44 // Creates a ListValue for the recommended apps and sends it to js side. |
53 void SendRecommendedApps(); | 45 void SendRecommendedApps(); |
54 | 46 |
55 #if defined(OS_CHROMEOS) | 47 #if defined(OS_CHROMEOS) |
56 // Returns true if the hotword is enabled. | 48 // Returns true if the hotword is enabled. |
57 bool HotwordEnabled(); | 49 bool HotwordEnabled(); |
58 | 50 |
59 // Called when the pref has been changed. | 51 // Called when the pref has been changed. |
60 void OnHotwordEnabledChanged(); | 52 void OnHotwordEnabledChanged(); |
61 #endif | 53 #endif |
62 | 54 |
63 // Returns true if the hotword recognizer should run background. | |
64 bool ShouldRunHotwordBackground(); | |
65 | |
66 // JS callbacks. | 55 // JS callbacks. |
67 void HandleInitialize(const base::ListValue* args); | 56 void HandleInitialize(const base::ListValue* args); |
68 void HandleLaunchApp(const base::ListValue* args); | 57 void HandleLaunchApp(const base::ListValue* args); |
69 void HandleHotwordRecognizerState(const base::ListValue* args); | |
70 void HandleSpeechResult(const base::ListValue* args); | 58 void HandleSpeechResult(const base::ListValue* args); |
71 void HandleSpeechSoundLevel(const base::ListValue* args); | 59 void HandleSpeechSoundLevel(const base::ListValue* args); |
72 void HandleSpeechRecognition(const base::ListValue* args); | 60 void HandleSpeechRecognition(const base::ListValue* args); |
73 | 61 |
74 RecommendedApps* recommended_apps_; // Not owned. | 62 RecommendedApps* recommended_apps_; // Not owned. |
75 bool has_hotword_recognizer_; | |
76 scoped_ptr<HotwordBackgroundActivityMonitor> hotword_monitor_; | |
77 SpeechRecognitionState last_state_; | |
78 PrefChangeRegistrar pref_change_registrar_; | 63 PrefChangeRegistrar pref_change_registrar_; |
79 content::NotificationRegistrar registrar_; | 64 content::NotificationRegistrar registrar_; |
80 | 65 |
81 DISALLOW_COPY_AND_ASSIGN(StartPageHandler); | 66 DISALLOW_COPY_AND_ASSIGN(StartPageHandler); |
82 }; | 67 }; |
83 | 68 |
84 } // namespace app_list | 69 } // namespace app_list |
85 | 70 |
86 #endif // CHROME_BROWSER_UI_WEBUI_APP_LIST_START_PAGE_HANDLER_H_ | 71 #endif // CHROME_BROWSER_UI_WEBUI_APP_LIST_START_PAGE_HANDLER_H_ |
OLD | NEW |