| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_UI_APP_LIST_START_PAGE_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_UI_APP_LIST_START_PAGE_SERVICE_H_ |
| 6 #define CHROME_BROWSER_UI_APP_LIST_START_PAGE_SERVICE_H_ | 6 #define CHROME_BROWSER_UI_APP_LIST_START_PAGE_SERVICE_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 #include <string> |
| 9 #include <vector> | 10 #include <vector> |
| 10 | 11 |
| 11 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 12 #include "base/callback.h" | 13 #include "base/callback.h" |
| 13 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 14 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
| 15 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
| 16 #include "base/observer_list.h" | 17 #include "base/observer_list.h" |
| 17 #include "base/strings/string16.h" | 18 #include "base/strings/string16.h" |
| 19 #include "base/time/default_clock.h" |
| 18 #include "chrome/browser/ui/app_list/speech_recognizer_delegate.h" | 20 #include "chrome/browser/ui/app_list/speech_recognizer_delegate.h" |
| 19 #include "components/keyed_service/core/keyed_service.h" | 21 #include "components/keyed_service/core/keyed_service.h" |
| 20 #include "content/public/browser/web_contents.h" | 22 #include "content/public/browser/web_contents.h" |
| 21 #include "ui/app_list/speech_ui_model_observer.h" | 23 #include "ui/app_list/speech_ui_model_observer.h" |
| 22 | 24 |
| 23 namespace extensions { | 25 namespace extensions { |
| 24 class Extension; | 26 class Extension; |
| 25 } | 27 } |
| 26 | 28 |
| 27 class Profile; | 29 class Profile; |
| 28 | 30 |
| 29 namespace app_list { | 31 namespace app_list { |
| 30 | 32 |
| 31 class RecommendedApps; | 33 class RecommendedApps; |
| 34 class SpeechAuthHelper; |
| 32 class SpeechRecognizer; | 35 class SpeechRecognizer; |
| 33 class StartPageObserver; | 36 class StartPageObserver; |
| 34 | 37 |
| 35 // StartPageService collects data to be displayed in app list's start page | 38 // StartPageService collects data to be displayed in app list's start page |
| 36 // and hosts the start page contents. | 39 // and hosts the start page contents. |
| 37 class StartPageService : public KeyedService, | 40 class StartPageService : public KeyedService, |
| 38 public SpeechRecognizerDelegate { | 41 public SpeechRecognizerDelegate { |
| 39 public: | 42 public: |
| 40 typedef std::vector<scoped_refptr<const extensions::Extension> > | 43 typedef std::vector<scoped_refptr<const extensions::Extension> > |
| 41 ExtensionList; | 44 ExtensionList; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 63 RecommendedApps* recommended_apps() { return recommended_apps_.get(); } | 66 RecommendedApps* recommended_apps() { return recommended_apps_.get(); } |
| 64 Profile* profile() { return profile_; } | 67 Profile* profile() { return profile_; } |
| 65 SpeechRecognitionState state() { return state_; } | 68 SpeechRecognitionState state() { return state_; } |
| 66 | 69 |
| 67 // Overridden from app_list::SpeechRecognizerDelegate: | 70 // Overridden from app_list::SpeechRecognizerDelegate: |
| 68 void OnSpeechResult(const base::string16& query, bool is_final) override; | 71 void OnSpeechResult(const base::string16& query, bool is_final) override; |
| 69 void OnSpeechSoundLevelChanged(int16_t level) override; | 72 void OnSpeechSoundLevelChanged(int16_t level) override; |
| 70 void OnSpeechRecognitionStateChanged( | 73 void OnSpeechRecognitionStateChanged( |
| 71 SpeechRecognitionState new_state) override; | 74 SpeechRecognitionState new_state) override; |
| 72 content::WebContents* GetSpeechContents() override; | 75 content::WebContents* GetSpeechContents() override; |
| 76 void GetSpeechAuthParameters(std::string* auth_scope, |
| 77 std::string* auth_token) override; |
| 73 | 78 |
| 74 protected: | 79 protected: |
| 75 // Protected for testing. | 80 // Protected for testing. |
| 76 explicit StartPageService(Profile* profile); | 81 explicit StartPageService(Profile* profile); |
| 77 ~StartPageService() override; | 82 ~StartPageService() override; |
| 78 | 83 |
| 79 private: | 84 private: |
| 80 friend class StartPageServiceFactory; | 85 friend class StartPageServiceFactory; |
| 81 | 86 |
| 82 // ProfileDestroyObserver to shutdown the service on exiting. WebContents | 87 // ProfileDestroyObserver to shutdown the service on exiting. WebContents |
| (...skipping 23 matching lines...) Expand all Loading... |
| 106 scoped_ptr<ProfileDestroyObserver> profile_destroy_observer_; | 111 scoped_ptr<ProfileDestroyObserver> profile_destroy_observer_; |
| 107 scoped_ptr<RecommendedApps> recommended_apps_; | 112 scoped_ptr<RecommendedApps> recommended_apps_; |
| 108 SpeechRecognitionState state_; | 113 SpeechRecognitionState state_; |
| 109 ObserverList<StartPageObserver> observers_; | 114 ObserverList<StartPageObserver> observers_; |
| 110 bool speech_button_toggled_manually_; | 115 bool speech_button_toggled_manually_; |
| 111 bool speech_result_obtained_; | 116 bool speech_result_obtained_; |
| 112 | 117 |
| 113 bool webui_finished_loading_; | 118 bool webui_finished_loading_; |
| 114 std::vector<base::Closure> pending_webui_callbacks_; | 119 std::vector<base::Closure> pending_webui_callbacks_; |
| 115 | 120 |
| 121 base::DefaultClock clock_; |
| 116 scoped_ptr<SpeechRecognizer> speech_recognizer_; | 122 scoped_ptr<SpeechRecognizer> speech_recognizer_; |
| 123 scoped_ptr<SpeechAuthHelper> speech_auth_helper_; |
| 117 | 124 |
| 118 #if defined(OS_CHROMEOS) | 125 #if defined(OS_CHROMEOS) |
| 119 scoped_ptr<AudioStatus> audio_status_; | 126 scoped_ptr<AudioStatus> audio_status_; |
| 120 #endif | 127 #endif |
| 121 | 128 |
| 122 base::WeakPtrFactory<StartPageService> weak_factory_; | 129 base::WeakPtrFactory<StartPageService> weak_factory_; |
| 123 | 130 |
| 124 DISALLOW_COPY_AND_ASSIGN(StartPageService); | 131 DISALLOW_COPY_AND_ASSIGN(StartPageService); |
| 125 }; | 132 }; |
| 126 | 133 |
| 127 } // namespace app_list | 134 } // namespace app_list |
| 128 | 135 |
| 129 #endif // CHROME_BROWSER_UI_APP_LIST_START_PAGE_SERVICE_H_ | 136 #endif // CHROME_BROWSER_UI_APP_LIST_START_PAGE_SERVICE_H_ |
| OLD | NEW |