Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1159)

Unified Diff: chrome/browser/ui/app_list/start_page_service.cc

Issue 158143002: Fine tuned availability of hotword plugin. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cleanup Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/app_list/start_page_service.cc
diff --git a/chrome/browser/ui/app_list/start_page_service.cc b/chrome/browser/ui/app_list/start_page_service.cc
index 151bd658cc2eb1ab06793d1e7805fbc9cc6b5ec8..6c897bf5f6c73bf7d2df6b63eefa888ce76a981c 100644
--- a/chrome/browser/ui/app_list/start_page_service.cc
+++ b/chrome/browser/ui/app_list/start_page_service.cc
@@ -9,16 +9,13 @@
#include "base/command_line.h"
#include "base/memory/singleton.h"
#include "chrome/browser/chrome_notification_types.h"
-#include "chrome/browser/extensions/extension_system_factory.h"
-#include "chrome/browser/extensions/install_tracker_factory.h"
#include "chrome/browser/media/media_stream_infobar_delegate.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/app_list/recommended_apps.h"
#include "chrome/browser/ui/app_list/start_page_observer.h"
+#include "chrome/browser/ui/app_list/start_page_service_factory.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/url_constants.h"
-#include "components/browser_context_keyed_service/browser_context_dependency_manager.h"
-#include "components/browser_context_keyed_service/browser_context_keyed_service_factory.h"
#include "content/public/browser/notification_details.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
@@ -31,46 +28,6 @@
namespace app_list {
-class StartPageService::Factory : public BrowserContextKeyedServiceFactory {
- public:
- static StartPageService* GetForProfile(Profile* profile) {
- if (!CommandLine::ForCurrentProcess()->HasSwitch(
- ::switches::kShowAppListStartPage) &&
- !app_list::switches::IsVoiceSearchEnabled()) {
- return NULL;
- }
-
- return static_cast<StartPageService*>(
- GetInstance()->GetServiceForBrowserContext(profile, true));
- }
-
- static Factory* GetInstance() {
- return Singleton<Factory>::get();
- }
-
- private:
- friend struct DefaultSingletonTraits<Factory>;
-
- Factory()
- : BrowserContextKeyedServiceFactory(
- "AppListStartPageService",
- BrowserContextDependencyManager::GetInstance()) {
- DependsOn(extensions::ExtensionSystemFactory::GetInstance());
- DependsOn(extensions::InstallTrackerFactory::GetInstance());
- }
-
- virtual ~Factory() {}
-
- // BrowserContextKeyedServiceFactory overrides:
- virtual BrowserContextKeyedService* BuildServiceInstanceFor(
- content::BrowserContext* context) const OVERRIDE {
- Profile* profile = static_cast<Profile*>(context);
- return new StartPageService(profile);
- }
-
- DISALLOW_COPY_AND_ASSIGN(Factory);
-};
-
class StartPageService::ProfileDestroyObserver
: public content::NotificationObserver {
public:
@@ -118,13 +75,22 @@ class StartPageService::StartPageWebContentsDelegate
// static
StartPageService* StartPageService::Get(Profile* profile) {
- return Factory::GetForProfile(profile);
+ return StartPageServiceFactory::GetForProfile(profile);
}
StartPageService::StartPageService(Profile* profile)
: profile_(profile),
profile_destroy_observer_(new ProfileDestroyObserver(this)),
- recommended_apps_(new RecommendedApps(profile)) {
+ recommended_apps_(new RecommendedApps(profile)),
+ state_(app_list::SPEECH_RECOGNITION_OFF) {
+#if defined(OS_CHROMEOS)
+ // Updates the default state to hotword listening, because this is
+ // the default behavior. This will be updated when the page is loaded and
+ // the nacl module is loaded.
+ if (app_list::switches::IsVoiceSearchEnabled())
+ state_ = app_list::SPEECH_RECOGNITION_HOTWORD_LISTENING;
+#endif
+
contents_.reset(content::WebContents::Create(
content::WebContents::CreateParams(profile_)));
contents_delegate_.reset(new StartPageWebContentsDelegate());
@@ -183,6 +149,7 @@ void StartPageService::OnSpeechSoundLevelChanged(int16 level) {
void StartPageService::OnSpeechRecognitionStateChanged(
SpeechRecognitionState new_state) {
+ state_ = new_state;
FOR_EACH_OBSERVER(StartPageObserver,
observers_,
OnSpeechRecognitionStateChanged(new_state));

Powered by Google App Engine
This is Rietveld 408576698