Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / ui / app_list / start_page_service.h
blobbd219675c0f63f6c08497daca4d86128f01a086e
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_UI_APP_LIST_START_PAGE_SERVICE_H_
6 #define CHROME_BROWSER_UI_APP_LIST_START_PAGE_SERVICE_H_
8 #include <vector>
10 #include "base/basictypes.h"
11 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "base/observer_list.h"
14 #include "base/strings/string16.h"
15 #include "components/browser_context_keyed_service/browser_context_keyed_service.h"
16 #include "content/public/browser/web_contents.h"
17 #include "ui/app_list/speech_ui_model_observer.h"
19 namespace extensions {
20 class Extension;
23 class Profile;
25 namespace app_list {
27 class RecommendedApps;
28 class StartPageObserver;
30 // StartPageService collects data to be displayed in app list's start page
31 // and hosts the start page contents.
32 class StartPageService : public BrowserContextKeyedService {
33 public:
34 typedef std::vector<scoped_refptr<const extensions::Extension> >
35 ExtensionList;
36 // Gets the instance for the given profile.
37 static StartPageService* Get(Profile* profile);
39 void AddObserver(StartPageObserver* observer);
40 void RemoveObserver(StartPageObserver* observer);
42 void ToggleSpeechRecognition();
44 // They return essentially the same web contents but might return NULL when
45 // some flag disables the feature.
46 content::WebContents* GetStartPageContents();
47 content::WebContents* GetSpeechRecognitionContents();
49 RecommendedApps* recommended_apps() { return recommended_apps_.get(); }
50 Profile* profile() { return profile_; }
51 void OnSpeechResult(const base::string16& query, bool is_final);
52 void OnSpeechSoundLevelChanged(int16 level);
53 void OnSpeechRecognitionStateChanged(SpeechRecognitionState new_state);
55 private:
56 // A BrowserContextKeyedServiceFactory for this service.
57 class Factory;
59 // ProfileDestroyObserver to shutdown the service on exiting. WebContents
60 // depends on the profile and needs to be closed before the profile and its
61 // keyed service shutdown.
62 class ProfileDestroyObserver;
64 // The WebContentsDelegate implementation for the start page. This allows
65 // getUserMedia() request from the web contents.
66 class StartPageWebContentsDelegate;
68 explicit StartPageService(Profile* profile);
69 virtual ~StartPageService();
71 // BrowserContextKeyedService overrides:
72 virtual void Shutdown() OVERRIDE;
74 Profile* profile_;
75 scoped_ptr<content::WebContents> contents_;
76 scoped_ptr<StartPageWebContentsDelegate> contents_delegate_;
77 scoped_ptr<ProfileDestroyObserver> profile_destroy_observer_;
78 scoped_ptr<RecommendedApps> recommended_apps_;
79 ObserverList<StartPageObserver> observers_;
81 DISALLOW_COPY_AND_ASSIGN(StartPageService);
84 } // namespace app_list
86 #endif // CHROME_BROWSER_UI_APP_LIST_START_PAGE_SERVICE_H_