| 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 "content/public/browser/web_contents.h" | 22 #include "content/public/browser/web_contents.h" |
| 23 #include "content/public/browser/web_contents_observer.h" | 23 #include "content/public/browser/web_contents_observer.h" |
| 24 #include "net/url_request/url_fetcher_delegate.h" |
| 24 #include "ui/app_list/speech_ui_model_observer.h" | 25 #include "ui/app_list/speech_ui_model_observer.h" |
| 25 | 26 |
| 26 namespace content { | 27 namespace content { |
| 27 struct FrameNavigateParams; | 28 struct FrameNavigateParams; |
| 28 struct LoadCommittedDetails; | 29 struct LoadCommittedDetails; |
| 29 struct SpeechRecognitionSessionPreamble; | 30 struct SpeechRecognitionSessionPreamble; |
| 30 } | 31 } |
| 31 | 32 |
| 32 namespace extensions { | 33 namespace extensions { |
| 33 class Extension; | 34 class Extension; |
| 34 } | 35 } |
| 35 | 36 |
| 37 namespace net { |
| 38 class URLFetcher; |
| 39 } |
| 40 |
| 36 class Profile; | 41 class Profile; |
| 37 | 42 |
| 38 namespace app_list { | 43 namespace app_list { |
| 39 | 44 |
| 40 class SpeechAuthHelper; | 45 class SpeechAuthHelper; |
| 41 class SpeechRecognizer; | 46 class SpeechRecognizer; |
| 42 class StartPageObserver; | 47 class StartPageObserver; |
| 43 | 48 |
| 44 // StartPageService collects data to be displayed in app list's start page | 49 // StartPageService collects data to be displayed in app list's start page |
| 45 // and hosts the start page contents. | 50 // and hosts the start page contents. |
| 46 class StartPageService : public KeyedService, | 51 class StartPageService : public KeyedService, |
| 47 public content::WebContentsObserver, | 52 public content::WebContentsObserver, |
| 53 public net::URLFetcherDelegate, |
| 48 public SpeechRecognizerDelegate { | 54 public SpeechRecognizerDelegate { |
| 49 public: | 55 public: |
| 50 typedef std::vector<scoped_refptr<const extensions::Extension> > | 56 typedef std::vector<scoped_refptr<const extensions::Extension> > |
| 51 ExtensionList; | 57 ExtensionList; |
| 52 // Gets the instance for the given profile. | 58 // Gets the instance for the given profile. |
| 53 static StartPageService* Get(Profile* profile); | 59 static StartPageService* Get(Profile* profile); |
| 54 | 60 |
| 55 void AddObserver(StartPageObserver* observer); | 61 void AddObserver(StartPageObserver* observer); |
| 56 void RemoveObserver(StartPageObserver* observer); | 62 void RemoveObserver(StartPageObserver* observer); |
| 57 | 63 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 class AudioStatus; | 111 class AudioStatus; |
| 106 #endif | 112 #endif |
| 107 | 113 |
| 108 // This class observes network change events and disables/enables voice search | 114 // This class observes network change events and disables/enables voice search |
| 109 // based on network connectivity. | 115 // based on network connectivity. |
| 110 class NetworkChangeObserver; | 116 class NetworkChangeObserver; |
| 111 | 117 |
| 112 void LoadContents(); | 118 void LoadContents(); |
| 113 void UnloadContents(); | 119 void UnloadContents(); |
| 114 | 120 |
| 121 // Fetch the Google Doodle JSON data and update the app list start page. |
| 122 void FetchDoodleJson(); |
| 123 |
| 124 // net::URLFetcherDelegate overrides: |
| 125 void OnURLFetchComplete(const net::URLFetcher* source) override; |
| 126 |
| 115 // KeyedService overrides: | 127 // KeyedService overrides: |
| 116 void Shutdown() override; | 128 void Shutdown() override; |
| 117 | 129 |
| 118 // contents::WebContentsObserver overrides; | 130 // contents::WebContentsObserver overrides; |
| 119 void DidNavigateMainFrame( | 131 void DidNavigateMainFrame( |
| 120 const content::LoadCommittedDetails& details, | 132 const content::LoadCommittedDetails& details, |
| 121 const content::FrameNavigateParams& params) override; | 133 const content::FrameNavigateParams& params) override; |
| 122 | 134 |
| 123 // Change the known microphone availability. |available| should be true if | 135 // Change the known microphone availability. |available| should be true if |
| 124 // the microphone exists and is available for use. | 136 // the microphone exists and is available for use. |
| (...skipping 20 matching lines...) Expand all Loading... |
| 145 scoped_ptr<SpeechRecognizer> speech_recognizer_; | 157 scoped_ptr<SpeechRecognizer> speech_recognizer_; |
| 146 scoped_ptr<SpeechAuthHelper> speech_auth_helper_; | 158 scoped_ptr<SpeechAuthHelper> speech_auth_helper_; |
| 147 | 159 |
| 148 bool network_available_; | 160 bool network_available_; |
| 149 bool microphone_available_; | 161 bool microphone_available_; |
| 150 #if defined(OS_CHROMEOS) | 162 #if defined(OS_CHROMEOS) |
| 151 scoped_ptr<AudioStatus> audio_status_; | 163 scoped_ptr<AudioStatus> audio_status_; |
| 152 #endif | 164 #endif |
| 153 scoped_ptr<NetworkChangeObserver> network_change_observer_; | 165 scoped_ptr<NetworkChangeObserver> network_change_observer_; |
| 154 | 166 |
| 167 scoped_ptr<net::URLFetcher> doodle_fetcher_; |
| 168 |
| 155 base::WeakPtrFactory<StartPageService> weak_factory_; | 169 base::WeakPtrFactory<StartPageService> weak_factory_; |
| 156 | 170 |
| 157 DISALLOW_COPY_AND_ASSIGN(StartPageService); | 171 DISALLOW_COPY_AND_ASSIGN(StartPageService); |
| 158 }; | 172 }; |
| 159 | 173 |
| 160 } // namespace app_list | 174 } // namespace app_list |
| 161 | 175 |
| 162 #endif // CHROME_BROWSER_UI_APP_LIST_START_PAGE_SERVICE_H_ | 176 #endif // CHROME_BROWSER_UI_APP_LIST_START_PAGE_SERVICE_H_ |
| OLD | NEW |