OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_SEARCH_HOTWORD_AUDIO_HISTORY_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_SEARCH_HOTWORD_AUDIO_HISTORY_HANDLER_H_ |
6 #define CHROME_BROWSER_SEARCH_HOTWORD_AUDIO_HISTORY_HANDLER_H_ | 6 #define CHROME_BROWSER_SEARCH_HOTWORD_AUDIO_HISTORY_HANDLER_H_ |
7 | 7 |
| 8 #include "base/memory/weak_ptr.h" |
8 #include "base/prefs/pref_change_registrar.h" | 9 #include "base/prefs/pref_change_registrar.h" |
9 #include "content/public/browser/browser_context.h" | 10 #include "content/public/browser/browser_context.h" |
10 | 11 |
11 class Profile; | 12 class Profile; |
12 | 13 |
13 // A class which handles the audio history pref for hotwording. This has been | 14 // A class which handles the audio history pref for hotwording. This has been |
14 // pulled into its own class in order to transparently (to the rest of | 15 // pulled into its own class in order to transparently (to the rest of |
15 // hotwording) handle changing user global pref management systems. | 16 // hotwording) handle changing user global pref management systems. |
16 class HotwordAudioHistoryHandler { | 17 class HotwordAudioHistoryHandler { |
17 public: | 18 public: |
18 explicit HotwordAudioHistoryHandler(content::BrowserContext* context); | 19 explicit HotwordAudioHistoryHandler(content::BrowserContext* context); |
19 ~HotwordAudioHistoryHandler(); | 20 ~HotwordAudioHistoryHandler(); |
20 | 21 |
21 // Returns the current preference value based on the user's account info | 22 // Updates the current preference value based on the user's account info |
22 // or false if the user is not signed in. | 23 // or false if the user is not signed in. |
23 // TODO(rlp): Determine return value -- pref value or success? | 24 void GetAudioHistoryEnabled(); |
24 bool GetAudioHistoryEnabled(); | |
25 | 25 |
26 private: | |
27 // Sets the user's global pref value for enabling audio history. | 26 // Sets the user's global pref value for enabling audio history. |
28 void SetAudioHistoryEnabled(const bool enabled); | 27 void SetAudioHistoryEnabled(const bool enabled); |
29 | 28 |
30 void OnAudioHistoryEnabledChanged(const std::string& pref_name); | 29 private: |
| 30 // Callback called upon completion of the web history request. |
| 31 void AudioHistoryComplete(bool success, bool new_enabled_value); |
31 | 32 |
32 Profile* profile_; | 33 Profile* profile_; |
33 PrefChangeRegistrar pref_change_registrar_; | 34 |
| 35 base::WeakPtrFactory<HotwordAudioHistoryHandler> weak_factory_; |
34 | 36 |
35 DISALLOW_COPY_AND_ASSIGN(HotwordAudioHistoryHandler); | 37 DISALLOW_COPY_AND_ASSIGN(HotwordAudioHistoryHandler); |
36 }; | 38 }; |
37 | 39 |
38 #endif // CHROME_BROWSER_SEARCH_HOTWORD_AUDIO_HISTORY_HANDLER_H_ | 40 #endif // CHROME_BROWSER_SEARCH_HOTWORD_AUDIO_HISTORY_HANDLER_H_ |
OLD | NEW |