| 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 "base/scoped_observer.h" |
| 11 #include "chrome/browser/ui/app_list/recommended_apps_observer.h" | 12 #include "chrome/browser/ui/app_list/recommended_apps_observer.h" |
| 12 #include "content/public/browser/notification_observer.h" | |
| 13 #include "content/public/browser/notification_registrar.h" | |
| 14 #include "content/public/browser/web_ui_message_handler.h" | 13 #include "content/public/browser/web_ui_message_handler.h" |
| 14 #include "extensions/browser/extension_registry_observer.h" |
| 15 | 15 |
| 16 namespace base { | 16 namespace base { |
| 17 class ListValue; | 17 class ListValue; |
| 18 } | 18 } |
| 19 | 19 |
| 20 namespace extensions { |
| 21 class ExtensionRegistry; |
| 22 } |
| 23 |
| 20 namespace app_list { | 24 namespace app_list { |
| 21 | 25 |
| 22 class RecommendedApps; | 26 class RecommendedApps; |
| 23 | 27 |
| 24 // Handler for the app launcher start page. | 28 // Handler for the app launcher start page. |
| 25 class StartPageHandler : public content::WebUIMessageHandler, | 29 class StartPageHandler : public content::WebUIMessageHandler, |
| 26 public content::NotificationObserver, | 30 public extensions::ExtensionRegistryObserver, |
| 27 public RecommendedAppsObserver { | 31 public RecommendedAppsObserver { |
| 28 public: | 32 public: |
| 29 StartPageHandler(); | 33 StartPageHandler(); |
| 30 virtual ~StartPageHandler(); | 34 virtual ~StartPageHandler(); |
| 31 | 35 |
| 32 private: | 36 private: |
| 33 // content::WebUIMessageHandler overrides: | 37 // content::WebUIMessageHandler overrides: |
| 34 virtual void RegisterMessages() OVERRIDE; | 38 virtual void RegisterMessages() OVERRIDE; |
| 35 | 39 |
| 36 // Overridden from content::NotificationObserver: | 40 // extensions::ExtensionRegistryObserver implementation. |
| 37 virtual void Observe(int type, | 41 virtual void OnExtensionLoaded( |
| 38 const content::NotificationSource& source, | 42 content::BrowserContext* browser_context, |
| 39 const content::NotificationDetails& details) OVERRIDE; | 43 const extensions::Extension* extension) OVERRIDE; |
| 44 virtual void OnExtensionUnloaded( |
| 45 content::BrowserContext* browser_context, |
| 46 const extensions::Extension* extension, |
| 47 extensions::UnloadedExtensionInfo::Reason reason) OVERRIDE; |
| 40 | 48 |
| 41 // RecommendedAppsObserver overrdies: | 49 // RecommendedAppsObserver overrdies: |
| 42 virtual void OnRecommendedAppsChanged() OVERRIDE; | 50 virtual void OnRecommendedAppsChanged() OVERRIDE; |
| 43 | 51 |
| 44 // Creates a ListValue for the recommended apps and sends it to js side. | 52 // Creates a ListValue for the recommended apps and sends it to js side. |
| 45 void SendRecommendedApps(); | 53 void SendRecommendedApps(); |
| 46 | 54 |
| 47 #if defined(OS_CHROMEOS) | 55 #if defined(OS_CHROMEOS) |
| 48 // Called when the pref has been changed. | 56 // Called when the pref has been changed. |
| 49 void OnHotwordEnabledChanged(); | 57 void OnHotwordEnabledChanged(); |
| 50 #endif | 58 #endif |
| 51 | 59 |
| 52 // JS callbacks. | 60 // JS callbacks. |
| 53 void HandleInitialize(const base::ListValue* args); | 61 void HandleInitialize(const base::ListValue* args); |
| 54 void HandleLaunchApp(const base::ListValue* args); | 62 void HandleLaunchApp(const base::ListValue* args); |
| 55 void HandleSpeechResult(const base::ListValue* args); | 63 void HandleSpeechResult(const base::ListValue* args); |
| 56 void HandleSpeechSoundLevel(const base::ListValue* args); | 64 void HandleSpeechSoundLevel(const base::ListValue* args); |
| 57 void HandleSpeechRecognition(const base::ListValue* args); | 65 void HandleSpeechRecognition(const base::ListValue* args); |
| 58 | 66 |
| 59 RecommendedApps* recommended_apps_; // Not owned. | 67 RecommendedApps* recommended_apps_; // Not owned. |
| 60 PrefChangeRegistrar pref_change_registrar_; | 68 PrefChangeRegistrar pref_change_registrar_; |
| 61 content::NotificationRegistrar registrar_; | 69 |
| 70 ScopedObserver<extensions::ExtensionRegistry, |
| 71 extensions::ExtensionRegistryObserver> |
| 72 extension_registry_observer_; |
| 62 | 73 |
| 63 DISALLOW_COPY_AND_ASSIGN(StartPageHandler); | 74 DISALLOW_COPY_AND_ASSIGN(StartPageHandler); |
| 64 }; | 75 }; |
| 65 | 76 |
| 66 } // namespace app_list | 77 } // namespace app_list |
| 67 | 78 |
| 68 #endif // CHROME_BROWSER_UI_WEBUI_APP_LIST_START_PAGE_HANDLER_H_ | 79 #endif // CHROME_BROWSER_UI_WEBUI_APP_LIST_START_PAGE_HANDLER_H_ |
| OLD | NEW |