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 #include "chrome/browser/ui/app_list/start_page_service.h" | 5 #include "chrome/browser/ui/app_list/start_page_service.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/memory/singleton.h" | 10 #include "base/memory/singleton.h" |
11 #include "chrome/browser/chrome_notification_types.h" | 11 #include "chrome/browser/chrome_notification_types.h" |
12 #include "chrome/browser/extensions/extension_system_factory.h" | 12 #include "chrome/browser/extensions/extension_system_factory.h" |
13 #include "chrome/browser/extensions/install_tracker_factory.h" | 13 #include "chrome/browser/extensions/install_tracker_factory.h" |
14 #include "chrome/browser/media/media_stream_infobar_delegate.h" | 14 #include "chrome/browser/media/media_stream_infobar_delegate.h" |
15 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
16 #include "chrome/browser/ui/app_list/recommended_apps.h" | 16 #include "chrome/browser/ui/app_list/recommended_apps.h" |
17 #include "chrome/common/chrome_switches.h" | 17 #include "chrome/common/chrome_switches.h" |
18 #include "chrome/common/extensions/extension.h" | 18 #include "chrome/common/extensions/extension.h" |
19 #include "chrome/common/url_constants.h" | 19 #include "chrome/common/url_constants.h" |
20 #include "components/browser_context_keyed_service/browser_context_dependency_ma
nager.h" | 20 #include "components/browser_context_keyed_service/browser_context_dependency_ma
nager.h" |
21 #include "components/browser_context_keyed_service/browser_context_keyed_service
_factory.h" | 21 #include "components/browser_context_keyed_service/browser_context_keyed_service
_factory.h" |
22 #include "content/public/browser/notification_observer.h" | 22 #include "content/public/browser/notification_observer.h" |
23 #include "content/public/browser/notification_registrar.h" | 23 #include "content/public/browser/notification_registrar.h" |
24 #include "content/public/browser/notification_service.h" | 24 #include "content/public/browser/notification_service.h" |
25 #include "content/public/browser/web_contents.h" | 25 #include "content/public/browser/web_contents.h" |
26 #include "content/public/browser/web_contents_delegate.h" | 26 #include "content/public/browser/web_contents_delegate.h" |
| 27 #include "ui/app_list/app_list_model.h" |
| 28 #include "ui/app_list/search_box_model.h" |
27 | 29 |
28 namespace app_list { | 30 namespace app_list { |
29 | 31 |
30 class StartPageService::Factory : public BrowserContextKeyedServiceFactory { | 32 class StartPageService::Factory : public BrowserContextKeyedServiceFactory { |
31 public: | 33 public: |
32 static StartPageService* GetForProfile(Profile* profile) { | 34 static StartPageService* GetForProfile(Profile* profile) { |
33 if (!CommandLine::ForCurrentProcess()->HasSwitch( | 35 if (!CommandLine::ForCurrentProcess()->HasSwitch( |
34 switches::kShowAppListStartPage)) { | 36 switches::kShowAppListStartPage)) { |
35 return NULL; | 37 return NULL; |
36 } | 38 } |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 DISALLOW_COPY_AND_ASSIGN(StartPageWebContentsDelegate); | 110 DISALLOW_COPY_AND_ASSIGN(StartPageWebContentsDelegate); |
109 }; | 111 }; |
110 | 112 |
111 // static | 113 // static |
112 StartPageService* StartPageService::Get(Profile* profile) { | 114 StartPageService* StartPageService::Get(Profile* profile) { |
113 return Factory::GetForProfile(profile); | 115 return Factory::GetForProfile(profile); |
114 } | 116 } |
115 | 117 |
116 StartPageService::StartPageService(Profile* profile) | 118 StartPageService::StartPageService(Profile* profile) |
117 : profile_(profile), | 119 : profile_(profile), |
| 120 model_(NULL), |
118 exit_observer_(new ExitObserver(this)), | 121 exit_observer_(new ExitObserver(this)), |
119 recommended_apps_(new RecommendedApps(profile)) { | 122 recommended_apps_(new RecommendedApps(profile)) { |
120 contents_.reset(content::WebContents::Create( | 123 contents_.reset(content::WebContents::Create( |
121 content::WebContents::CreateParams(profile_))); | 124 content::WebContents::CreateParams(profile_))); |
122 contents_delegate_.reset(new StartPageWebContentsDelegate()); | 125 contents_delegate_.reset(new StartPageWebContentsDelegate()); |
123 contents_->SetDelegate(contents_delegate_.get()); | 126 contents_->SetDelegate(contents_delegate_.get()); |
124 | 127 |
125 GURL url(chrome::kChromeUIAppListStartPageURL); | 128 GURL url(chrome::kChromeUIAppListStartPageURL); |
126 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 129 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
127 if (command_line->HasSwitch(switches::kAppListStartPageURL)) { | 130 if (command_line->HasSwitch(switches::kAppListStartPageURL)) { |
128 url = GURL( | 131 url = GURL( |
129 command_line->GetSwitchValueASCII(switches::kAppListStartPageURL)); | 132 command_line->GetSwitchValueASCII(switches::kAppListStartPageURL)); |
130 } | 133 } |
131 | 134 |
132 contents_->GetController().LoadURL( | 135 contents_->GetController().LoadURL( |
133 url, | 136 url, |
134 content::Referrer(), | 137 content::Referrer(), |
135 content::PAGE_TRANSITION_AUTO_TOPLEVEL, | 138 content::PAGE_TRANSITION_AUTO_TOPLEVEL, |
136 std::string()); | 139 std::string()); |
137 } | 140 } |
138 | 141 |
139 StartPageService::~StartPageService() {} | 142 StartPageService::~StartPageService() {} |
140 | 143 |
141 void StartPageService::Shutdown() { | 144 void StartPageService::Shutdown() { |
142 contents_.reset(); | 145 contents_.reset(); |
143 } | 146 } |
144 | 147 |
| 148 void StartPageService::SetAppListModel(AppListModel* model) { |
| 149 DCHECK(model == NULL || model_ == NULL); |
| 150 model_ = model; |
| 151 } |
| 152 |
| 153 void StartPageService::OnSearch(const base::string16& query) { |
| 154 if (!model_) |
| 155 return; |
| 156 |
| 157 model_->search_box()->SetText(query); |
| 158 } |
| 159 |
145 } // namespace app_list | 160 } // namespace app_list |
OLD | NEW |