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..4349d56a1bbcc0a85c56182d6ac0e9de5750b75e 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,14 @@ 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 for whether all the necessary files have downloaded to allow for |
// using the extension. |
virtual bool IsServiceAvailable(); |
@@ -62,6 +80,23 @@ class HotwordService : public content::NotificationObserver, |
void StopHotwordSession(HotwordClient* client); |
HotwordClient* client() { return client_; } |
+ // 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 MaybeReinstallHotwordExtension(); |
+ |
+ // Checks based on locale if the current version should be uninstalled so that |
+ // a version with a different language can be installed. |
+ bool ShouldReinstallHotwordExtension(); |
+ |
+ // Helper functions pulled out for testing purposes. |
+ // UninstallHotwordExtension returns true if the extension was uninstalled. |
+ virtual bool UninstallHotwordExtension(ExtensionService* extension_service); |
+ virtual void InstallHotwordExtensionFromWebstore(); |
+ |
+ // Sets the pref value of the previous locale. |
Jered
2014/06/18 21:06:04
locale -> language
rpetterson
2014/06/18 23:45:35
Done.
|
+ void SetPreviousLanguagePref(); |
+ |
// Returns the current error message id. A value of 0 indicates |
// no error. |
int error_message() { return error_message_; } |
@@ -73,8 +108,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 reinstall_pending_; |
+ |
+ base::WeakPtrFactory<HotwordService> weak_factory_; |
DISALLOW_COPY_AND_ASSIGN(HotwordService); |
}; |