Chromium Code Reviews| Index: chrome/browser/search/hotword_service.h |
| diff --git a/chrome/browser/search/hotword_service.h b/chrome/browser/search/hotword_service.h |
| index a30753343ca8983fb6bf66d8215663935ca499d7..7f25bfa1c60a7fce81d79062f473995b24c7d707 100644 |
| --- a/chrome/browser/search/hotword_service.h |
| +++ b/chrome/browser/search/hotword_service.h |
| @@ -6,15 +6,24 @@ |
| #define CHROME_BROWSER_SEARCH_HOTWORD_SERVICE_H_ |
| #include "base/basictypes.h" |
| +#include "base/memory/weak_ptr.h" |
| #include "base/prefs/pref_change_registrar.h" |
| +#include "base/scoped_observer.h" |
| #include "components/keyed_service/core/keyed_service.h" |
| #include "content/public/browser/notification_observer.h" |
| #include "content/public/browser/notification_registrar.h" |
| +#include "extensions/browser/extension_registry.h" |
| +#include "extensions/browser/extension_registry_observer.h" |
| class ExtensionService; |
| class HotwordClient; |
| class Profile; |
| +namespace extensions { |
| +class Extension; |
| +class WebstoreStandaloneInstaller; |
| +} // namespace extensions |
| + |
| namespace hotword_internal { |
| // Constants for the hotword field trial. |
| extern const char kHotwordFieldTrialName[]; |
| @@ -24,6 +33,7 @@ extern const char kHotwordFieldTrialDisabledGroupName[]; |
| // Provides an interface for the Hotword component that does voice triggered |
| // search. |
| class HotwordService : public content::NotificationObserver, |
| + public extensions::ExtensionRegistryObserver, |
| public KeyedService { |
| public: |
| // Returns true if the hotword supports the current system language. |
| @@ -37,6 +47,19 @@ class HotwordService : public content::NotificationObserver, |
| const content::NotificationSource& source, |
| const content::NotificationDetails& details) OVERRIDE; |
| + // Overridden from ExtensionRegisterObserver: |
| + virtual void OnExtensionInstalled( |
| + content::BrowserContext* browser_context, |
| + const extensions::Extension* extension) OVERRIDE; |
| + virtual void OnExtensionUninstalled( |
| + content::BrowserContext* browser_context, |
| + const extensions::Extension* extension) OVERRIDE; |
| + |
| + // Checks if the current version of the hotword extension should be |
| + // uninstalled in order to update to a different language version. |
| + // Returns true if the extension was uninstalled. |
| + bool MaybeUninstallHotwordExtension(); |
| + |
| // Checks for whether all the necessary files have downloaded to allow for |
| // using the extension. |
| virtual bool IsServiceAvailable(); |
| @@ -62,6 +85,23 @@ class HotwordService : public content::NotificationObserver, |
| void StopHotwordSession(HotwordClient* client); |
| HotwordClient* client() { return client_; } |
| + // Checks based on locale if the current version so be uninstalled so that |
|
Yoyo Zhou
2014/06/18 00:33:21
s/so/should/
rpetterson
2014/06/18 02:08:44
Done.
|
| + // a version with a different language can be installed. |
| + bool ShouldUninstallHotwordExtension(); |
| + |
| + // Helper functions pulled out for testing purposes. |
| + // UinstallHotwordExtension returns true if the extension was uninstalled. |
|
Yoyo Zhou
2014/06/18 00:33:22
typo: Uninstall
rpetterson
2014/06/18 02:08:44
Done.
|
| + virtual bool UninstallHotwordExtension(ExtensionService* extension_service); |
| + virtual void InstallHotwordExtensionFromWebstore(); |
| + |
| + // Sets the pref value of the previous locale. |
| + void SetPreviousLocalePref(); |
| + |
| + // Called when the extension is done being installed after a language |
| + // change. |
| + void OnHotwordExtensionInstalled(bool success, |
| + const std::string& error); |
| + |
| // Returns the current error message id. A value of 0 indicates |
| // no error. |
| int error_message() { return error_message_; } |
| @@ -73,8 +113,18 @@ class HotwordService : public content::NotificationObserver, |
| content::NotificationRegistrar registrar_; |
| + // For observing the ExtensionRegistry. |
| + ScopedObserver<extensions::ExtensionRegistry, |
| + extensions::ExtensionRegistryObserver> |
| + extension_registry_observer_; |
| + |
| + scoped_refptr<extensions::WebstoreStandaloneInstaller> installer_; |
| + |
| HotwordClient* client_; |
| int error_message_; |
| + bool uninstall_pending_; |
| + |
| + base::WeakPtrFactory<HotwordService> weak_factory_; |
| DISALLOW_COPY_AND_ASSIGN(HotwordService); |
| }; |