| 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 <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "base/callback.h" | 13 #include "base/callback.h" |
| 14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
| 16 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
| 17 #include "base/observer_list.h" | 17 #include "base/observer_list.h" |
| 18 #include "base/strings/string16.h" | 18 #include "base/strings/string16.h" |
| 19 #include "base/time/default_clock.h" | 19 #include "base/time/default_clock.h" |
| 20 #include "chrome/browser/ui/app_list/speech_recognizer_delegate.h" | 20 #include "chrome/browser/ui/app_list/speech_recognizer_delegate.h" |
| 21 #include "components/keyed_service/core/keyed_service.h" | 21 #include "components/keyed_service/core/keyed_service.h" |
| 22 #include "components/search_engines/template_url_service_observer.h" |
| 22 #include "content/public/browser/web_contents.h" | 23 #include "content/public/browser/web_contents.h" |
| 23 #include "content/public/browser/web_contents_observer.h" | 24 #include "content/public/browser/web_contents_observer.h" |
| 24 #include "net/url_request/url_fetcher_delegate.h" | 25 #include "net/url_request/url_fetcher_delegate.h" |
| 25 #include "ui/app_list/speech_ui_model_observer.h" | 26 #include "ui/app_list/speech_ui_model_observer.h" |
| 26 | 27 |
| 27 namespace content { | 28 namespace content { |
| 28 struct FrameNavigateParams; | 29 struct FrameNavigateParams; |
| 29 struct LoadCommittedDetails; | 30 struct LoadCommittedDetails; |
| 30 struct SpeechRecognitionSessionPreamble; | 31 struct SpeechRecognitionSessionPreamble; |
| 31 } | 32 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 44 | 45 |
| 45 class SpeechAuthHelper; | 46 class SpeechAuthHelper; |
| 46 class SpeechRecognizer; | 47 class SpeechRecognizer; |
| 47 class StartPageObserver; | 48 class StartPageObserver; |
| 48 | 49 |
| 49 // StartPageService collects data to be displayed in app list's start page | 50 // StartPageService collects data to be displayed in app list's start page |
| 50 // and hosts the start page contents. | 51 // and hosts the start page contents. |
| 51 class StartPageService : public KeyedService, | 52 class StartPageService : public KeyedService, |
| 52 public content::WebContentsObserver, | 53 public content::WebContentsObserver, |
| 53 public net::URLFetcherDelegate, | 54 public net::URLFetcherDelegate, |
| 54 public SpeechRecognizerDelegate { | 55 public SpeechRecognizerDelegate, |
| 56 public TemplateURLServiceObserver { |
| 55 public: | 57 public: |
| 56 typedef std::vector<scoped_refptr<const extensions::Extension> > | 58 typedef std::vector<scoped_refptr<const extensions::Extension> > |
| 57 ExtensionList; | 59 ExtensionList; |
| 58 // Gets the instance for the given profile. | 60 // Gets the instance for the given profile. |
| 59 static StartPageService* Get(Profile* profile); | 61 static StartPageService* Get(Profile* profile); |
| 60 | 62 |
| 61 void AddObserver(StartPageObserver* observer); | 63 void AddObserver(StartPageObserver* observer); |
| 62 void RemoveObserver(StartPageObserver* observer); | 64 void RemoveObserver(StartPageObserver* observer); |
| 63 | 65 |
| 64 void AppListShown(); | 66 void AppListShown(); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 81 SpeechRecognitionState state() { return state_; } | 83 SpeechRecognitionState state() { return state_; } |
| 82 | 84 |
| 83 // Overridden from app_list::SpeechRecognizerDelegate: | 85 // Overridden from app_list::SpeechRecognizerDelegate: |
| 84 void OnSpeechResult(const base::string16& query, bool is_final) override; | 86 void OnSpeechResult(const base::string16& query, bool is_final) override; |
| 85 void OnSpeechSoundLevelChanged(int16_t level) override; | 87 void OnSpeechSoundLevelChanged(int16_t level) override; |
| 86 void OnSpeechRecognitionStateChanged( | 88 void OnSpeechRecognitionStateChanged( |
| 87 SpeechRecognitionState new_state) override; | 89 SpeechRecognitionState new_state) override; |
| 88 void GetSpeechAuthParameters(std::string* auth_scope, | 90 void GetSpeechAuthParameters(std::string* auth_scope, |
| 89 std::string* auth_token) override; | 91 std::string* auth_token) override; |
| 90 | 92 |
| 93 // Overridden from TemplateURLServiceObserver: |
| 94 void OnTemplateURLServiceChanged() override; |
| 95 |
| 91 protected: | 96 protected: |
| 92 // Protected for testing. | 97 // Protected for testing. |
| 93 explicit StartPageService(Profile* profile); | 98 explicit StartPageService(Profile* profile); |
| 94 ~StartPageService() override; | 99 ~StartPageService() override; |
| 95 | 100 |
| 96 private: | 101 private: |
| 97 friend class StartPageServiceFactory; | 102 friend class StartPageServiceFactory; |
| 98 | 103 |
| 99 // ProfileDestroyObserver to shutdown the service on exiting. WebContents | 104 // ProfileDestroyObserver to shutdown the service on exiting. WebContents |
| 100 // depends on the profile and needs to be closed before the profile and its | 105 // depends on the profile and needs to be closed before the profile and its |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 scoped_ptr<net::URLFetcher> doodle_fetcher_; | 172 scoped_ptr<net::URLFetcher> doodle_fetcher_; |
| 168 | 173 |
| 169 base::WeakPtrFactory<StartPageService> weak_factory_; | 174 base::WeakPtrFactory<StartPageService> weak_factory_; |
| 170 | 175 |
| 171 DISALLOW_COPY_AND_ASSIGN(StartPageService); | 176 DISALLOW_COPY_AND_ASSIGN(StartPageService); |
| 172 }; | 177 }; |
| 173 | 178 |
| 174 } // namespace app_list | 179 } // namespace app_list |
| 175 | 180 |
| 176 #endif // CHROME_BROWSER_UI_APP_LIST_START_PAGE_SERVICE_H_ | 181 #endif // CHROME_BROWSER_UI_APP_LIST_START_PAGE_SERVICE_H_ |
| OLD | NEW |