X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fchrome%2Fbrowser%2Fui%2Fapp_list%2Fstart_page_service.h;h=61e226055de48df5c1ac945ab210ba55c6aaf6d9;hb=1afa4dd80ef85af7c90efaea6959db1d92330844;hp=7bcded28535df1c908e5b8b617557beca6a96cd7;hpb=90762837333c13ccf56f2ad88e4481fc71e8d281;p=platform%2Fframework%2Fweb%2Fcrosswalk.git diff --git a/src/chrome/browser/ui/app_list/start_page_service.h b/src/chrome/browser/ui/app_list/start_page_service.h index 7bcded2..61e2260 100644 --- a/src/chrome/browser/ui/app_list/start_page_service.h +++ b/src/chrome/browser/ui/app_list/start_page_service.h @@ -5,13 +5,17 @@ #ifndef CHROME_BROWSER_UI_APP_LIST_START_PAGE_SERVICE_H_ #define CHROME_BROWSER_UI_APP_LIST_START_PAGE_SERVICE_H_ +#include #include #include "base/basictypes.h" +#include "base/callback.h" #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" +#include "base/memory/weak_ptr.h" #include "base/observer_list.h" #include "base/strings/string16.h" +#include "chrome/browser/ui/app_list/speech_recognizer_delegate.h" #include "components/keyed_service/core/keyed_service.h" #include "content/public/browser/web_contents.h" #include "ui/app_list/speech_ui_model_observer.h" @@ -25,11 +29,13 @@ class Profile; namespace app_list { class RecommendedApps; +class SpeechRecognizer; class StartPageObserver; // StartPageService collects data to be displayed in app list's start page // and hosts the start page contents. -class StartPageService : public KeyedService { +class StartPageService : public KeyedService, + public SpeechRecognizerDelegate { public: typedef std::vector > ExtensionList; @@ -43,6 +49,9 @@ class StartPageService : public KeyedService { void AppListHidden(); void ToggleSpeechRecognition(); + // Called when the WebUI has finished loading. + void WebUILoaded(); + // Returns true if the hotword is enabled in the app-launcher. bool HotwordEnabled(); @@ -54,9 +63,18 @@ class StartPageService : public KeyedService { RecommendedApps* recommended_apps() { return recommended_apps_.get(); } Profile* profile() { return profile_; } SpeechRecognitionState state() { return state_; } - void OnSpeechResult(const base::string16& query, bool is_final); - void OnSpeechSoundLevelChanged(int16 level); - void OnSpeechRecognitionStateChanged(SpeechRecognitionState new_state); + + // Overridden from app_list::SpeechRecognizerDelegate: + void OnSpeechResult(const base::string16& query, bool is_final) override; + void OnSpeechSoundLevelChanged(int16_t level) override; + void OnSpeechRecognitionStateChanged( + SpeechRecognitionState new_state) override; + content::WebContents* GetSpeechContents() override; + + protected: + // Protected for testing. + explicit StartPageService(Profile* profile); + ~StartPageService() override; private: friend class StartPageServiceFactory; @@ -70,14 +88,11 @@ class StartPageService : public KeyedService { // getUserMedia() request from the web contents. class StartPageWebContentsDelegate; - explicit StartPageService(Profile* profile); - virtual ~StartPageService(); - void LoadContents(); void UnloadContents(); // KeyedService overrides: - virtual void Shutdown() OVERRIDE; + void Shutdown() override; Profile* profile_; scoped_ptr contents_; @@ -89,6 +104,13 @@ class StartPageService : public KeyedService { bool speech_button_toggled_manually_; bool speech_result_obtained_; + bool webui_finished_loading_; + std::vector pending_webui_callbacks_; + + scoped_ptr speech_recognizer_; + + base::WeakPtrFactory weak_factory_; + DISALLOW_COPY_AND_ASSIGN(StartPageService); };