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 <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/observer_list.h" |
| 14 #include "base/strings/string16.h" |
13 #include "components/browser_context_keyed_service/browser_context_keyed_service
.h" | 15 #include "components/browser_context_keyed_service/browser_context_keyed_service
.h" |
14 #include "content/public/browser/web_contents.h" | 16 #include "content/public/browser/web_contents.h" |
15 | 17 |
16 namespace extensions { | 18 namespace extensions { |
17 class Extension; | 19 class Extension; |
18 } | 20 } |
19 | 21 |
20 class Profile; | 22 class Profile; |
21 | 23 |
22 namespace app_list { | 24 namespace app_list { |
23 | 25 |
24 class RecommendedApps; | 26 class RecommendedApps; |
25 | 27 |
26 // StartPageService collects data to be displayed in app list's start page | 28 // StartPageService collects data to be displayed in app list's start page |
27 // and hosts the start page contents. | 29 // and hosts the start page contents. |
28 class StartPageService : public BrowserContextKeyedService { | 30 class StartPageService : public BrowserContextKeyedService { |
29 public: | 31 public: |
30 typedef std::vector<scoped_refptr<const extensions::Extension> > | 32 typedef std::vector<scoped_refptr<const extensions::Extension> > |
31 ExtensionList; | 33 ExtensionList; |
32 // Gets the instance for the given profile. | 34 // Gets the instance for the given profile. |
33 static StartPageService* Get(Profile* profile); | 35 static StartPageService* Get(Profile* profile); |
34 | 36 |
| 37 void AddObserver(StartPageObserver* observer); |
| 38 void RemoveObserver(StartPageObserver* observer); |
| 39 |
35 content::WebContents* contents() { return contents_.get(); } | 40 content::WebContents* contents() { return contents_.get(); } |
36 RecommendedApps* recommended_apps() { return recommended_apps_.get(); } | 41 RecommendedApps* recommended_apps() { return recommended_apps_.get(); } |
| 42 void OnSearch(const base::string16& query); |
37 | 43 |
38 private: | 44 private: |
39 // A BrowserContextKeyedServiceFactory for this service. | 45 // A BrowserContextKeyedServiceFactory for this service. |
40 class Factory; | 46 class Factory; |
41 | 47 |
42 // ExitObserver to shutdown the service on exiting. WebContents depends | 48 // ExitObserver to shutdown the service on exiting. WebContents depends |
43 // on the profile and needs to be closed before the profile and its | 49 // on the profile and needs to be closed before the profile and its |
44 // keyed service shutdown. | 50 // keyed service shutdown. |
45 class ExitObserver; | 51 class ExitObserver; |
46 | 52 |
47 // The WebContentsDelegate implementation for the start page. This allows | 53 // The WebContentsDelegate implementation for the start page. This allows |
48 // getUserMedia() request from the web contents. | 54 // getUserMedia() request from the web contents. |
49 class StartPageWebContentsDelegate; | 55 class StartPageWebContentsDelegate; |
50 | 56 |
51 explicit StartPageService(Profile* profile); | 57 explicit StartPageService(Profile* profile); |
52 virtual ~StartPageService(); | 58 virtual ~StartPageService(); |
53 | 59 |
54 // BrowserContextKeyedService overrides: | 60 // BrowserContextKeyedService overrides: |
55 virtual void Shutdown() OVERRIDE; | 61 virtual void Shutdown() OVERRIDE; |
56 | 62 |
57 Profile* profile_; | 63 Profile* profile_; |
58 scoped_ptr<content::WebContents> contents_; | 64 scoped_ptr<content::WebContents> contents_; |
59 scoped_ptr<StartPageWebContentsDelegate> contents_delegate_; | 65 scoped_ptr<StartPageWebContentsDelegate> contents_delegate_; |
60 scoped_ptr<ExitObserver> exit_observer_; | 66 scoped_ptr<ExitObserver> exit_observer_; |
61 scoped_ptr<RecommendedApps> recommended_apps_; | 67 scoped_ptr<RecommendedApps> recommended_apps_; |
| 68 ObserverList<StartPageObserver> observers_; |
62 | 69 |
63 DISALLOW_COPY_AND_ASSIGN(StartPageService); | 70 DISALLOW_COPY_AND_ASSIGN(StartPageService); |
64 }; | 71 }; |
65 | 72 |
66 } // namespace app_list | 73 } // namespace app_list |
67 | 74 |
68 #endif // CHROME_BROWSER_UI_APP_LIST_START_PAGE_SERVICE_H_ | 75 #endif // CHROME_BROWSER_UI_APP_LIST_START_PAGE_SERVICE_H_ |
OLD | NEW |