Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2005)

Unified Diff: chrome/browser/search/hotword_service.h

Issue 330193005: [Hotword] Uninstall and reinstall the extension upon language change. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix unittest compile errors Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/search/hotword_service.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..ece6eba732a08591ef2800612be2c6ccc28d3678 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 language.
+ 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);
};
« no previous file with comments | « no previous file | chrome/browser/search/hotword_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698