Index: chrome/browser/search/hotword_audio_history_handler.h |
diff --git a/chrome/browser/search/hotword_audio_history_handler.h b/chrome/browser/search/hotword_audio_history_handler.h |
index 2f1616b2ff62d59e975cb38f1e0219fb01babca2..30dbe1e8781938f0255fc183248d6312ed95693f 100644 |
--- a/chrome/browser/search/hotword_audio_history_handler.h |
+++ b/chrome/browser/search/hotword_audio_history_handler.h |
@@ -5,12 +5,17 @@ |
#ifndef CHROME_BROWSER_SEARCH_HOTWORD_AUDIO_HISTORY_HANDLER_H_ |
#define CHROME_BROWSER_SEARCH_HOTWORD_AUDIO_HISTORY_HANDLER_H_ |
+#include "base/memory/ref_counted.h" |
#include "base/memory/weak_ptr.h" |
#include "base/prefs/pref_change_registrar.h" |
#include "content/public/browser/browser_context.h" |
class Profile; |
+namespace base { |
+class SingleThreadTaskRunner; |
+} |
+ |
namespace history { |
class WebHistoryService; |
} |
@@ -23,12 +28,19 @@ class HotwordAudioHistoryHandler { |
typedef base::Callback<void(bool success, bool new_enabled_value)> |
HotwordAudioHistoryCallback; |
- explicit HotwordAudioHistoryHandler(content::BrowserContext* context); |
+ HotwordAudioHistoryHandler( |
+ content::BrowserContext* context, |
+ const scoped_refptr<base::SingleThreadTaskRunner>& task_runner); |
+ |
virtual ~HotwordAudioHistoryHandler(); |
+ // Initiates a call to get the updated audio history state. |
+ void UpdateAudioHistoryState(); |
+ |
// Updates the current preference value based on the user's account info |
// or false if the user is not signed in. |
- void GetAudioHistoryEnabled(const HotwordAudioHistoryCallback& callback); |
+ virtual void GetAudioHistoryEnabled( |
+ const HotwordAudioHistoryCallback& callback); |
// Sets the user's global pref value for enabling audio history. |
void SetAudioHistoryEnabled(const bool enabled, |
@@ -38,6 +50,9 @@ class HotwordAudioHistoryHandler { |
virtual history::WebHistoryService* GetWebHistory(); |
private: |
+ // Helper function used as a callback and to factor out common code. |
+ void UpdateLocalPreference(bool success, bool new_enabled_value); |
+ |
// Called upon completion of web history->GetAudioHistoryEnabled. |
void GetAudioHistoryComplete( |
const HotwordAudioHistoryCallback& callback, |
@@ -53,6 +68,8 @@ class HotwordAudioHistoryHandler { |
bool success, |
bool callback_enabled_value); |
+ scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
+ |
Profile* profile_; |
base::WeakPtrFactory<HotwordAudioHistoryHandler> weak_ptr_factory_; |