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

Side by Side Diff: chrome/browser/ui/app_list/app_list_view_delegate.cc

Issue 2787693002: Remove more dead app list code. (Closed)
Patch Set: trim Created 3 years, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/app_list_view_delegate.h" 5 #include "chrome/browser/ui/app_list/app_list_view_delegate.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/callback.h"
12 #include "base/command_line.h" 11 #include "base/command_line.h"
13 #include "base/files/file_path.h"
14 #include "base/metrics/user_metrics.h" 12 #include "base/metrics/user_metrics.h"
15 #include "base/profiler/scoped_tracker.h" 13 #include "base/profiler/scoped_tracker.h"
16 #include "base/stl_util.h"
17 #include "build/build_config.h" 14 #include "build/build_config.h"
18 #include "chrome/browser/browser_process.h"
19 #include "chrome/browser/chrome_notification_types.h" 15 #include "chrome/browser/chrome_notification_types.h"
20 #include "chrome/browser/lifetime/scoped_keep_alive.h" 16 #include "chrome/browser/profiles/profile.h"
21 #include "chrome/browser/profiles/profile_attributes_entry.h"
22 #include "chrome/browser/profiles/profile_attributes_storage.h"
23 #include "chrome/browser/profiles/profile_manager.h"
24 #include "chrome/browser/search/hotword_service.h" 17 #include "chrome/browser/search/hotword_service.h"
25 #include "chrome/browser/search/hotword_service_factory.h" 18 #include "chrome/browser/search/hotword_service_factory.h"
26 #include "chrome/browser/search_engines/template_url_service_factory.h" 19 #include "chrome/browser/search_engines/template_url_service_factory.h"
27 #include "chrome/browser/ui/app_list/app_list_controller_delegate.h" 20 #include "chrome/browser/ui/app_list/app_list_controller_delegate.h"
28 #include "chrome/browser/ui/app_list/app_list_service.h"
29 #include "chrome/browser/ui/app_list/app_list_syncable_service.h" 21 #include "chrome/browser/ui/app_list/app_list_syncable_service.h"
30 #include "chrome/browser/ui/app_list/app_list_syncable_service_factory.h" 22 #include "chrome/browser/ui/app_list/app_list_syncable_service_factory.h"
31 #include "chrome/browser/ui/app_list/custom_launcher_page_contents.h" 23 #include "chrome/browser/ui/app_list/custom_launcher_page_contents.h"
32 #include "chrome/browser/ui/app_list/launcher_page_event_dispatcher.h" 24 #include "chrome/browser/ui/app_list/launcher_page_event_dispatcher.h"
33 #include "chrome/browser/ui/app_list/search/search_controller_factory.h" 25 #include "chrome/browser/ui/app_list/search/search_controller_factory.h"
34 #include "chrome/browser/ui/app_list/search/search_resource_manager.h" 26 #include "chrome/browser/ui/app_list/search/search_resource_manager.h"
35 #include "chrome/browser/ui/app_list/start_page_service.h" 27 #include "chrome/browser/ui/app_list/start_page_service.h"
36 #include "chrome/browser/ui/apps/chrome_app_delegate.h" 28 #include "chrome/browser/ui/apps/chrome_app_delegate.h"
37 #include "chrome/browser/ui/browser_finder.h" 29 #include "chrome/browser/ui/ash/app_list/app_sync_ui_state_watcher.h"
38 #include "chrome/browser/ui/chrome_pages.h" 30 #include "chrome/browser/ui/chrome_pages.h"
39 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h"
40 #include "chrome/browser/web_applications/web_app.h"
41 #include "chrome/common/chrome_switches.h"
42 #include "chrome/common/extensions/extension_constants.h"
43 #include "chrome/common/pref_names.h" 31 #include "chrome/common/pref_names.h"
44 #include "chrome/common/url_constants.h"
45 #include "chrome/grit/theme_resources.h" 32 #include "chrome/grit/theme_resources.h"
46 #include "components/prefs/pref_service.h" 33 #include "components/prefs/pref_service.h"
47 #include "components/signin/core/browser/signin_manager.h"
48 #include "components/user_prefs/user_prefs.h" 34 #include "components/user_prefs/user_prefs.h"
49 #include "content/public/browser/browser_thread.h"
50 #include "content/public/browser/notification_service.h" 35 #include "content/public/browser/notification_service.h"
51 #include "content/public/browser/page_navigator.h"
52 #include "content/public/browser/render_view_host.h" 36 #include "content/public/browser/render_view_host.h"
53 #include "content/public/browser/render_widget_host.h" 37 #include "content/public/browser/render_widget_host.h"
54 #include "content/public/browser/render_widget_host_view.h" 38 #include "content/public/browser/render_widget_host_view.h"
55 #include "content/public/browser/speech_recognition_session_preamble.h" 39 #include "content/public/browser/speech_recognition_session_preamble.h"
56 #include "content/public/browser/web_contents.h" 40 #include "content/public/browser/web_contents.h"
57 #include "extensions/browser/extension_registry.h" 41 #include "extensions/browser/extension_registry.h"
58 #include "extensions/common/constants.h" 42 #include "extensions/common/constants.h"
59 #include "extensions/common/extension_set.h" 43 #include "extensions/common/extension_set.h"
60 #include "extensions/common/manifest_constants.h" 44 #include "extensions/common/manifest_constants.h"
61 #include "extensions/common/manifest_handlers/launcher_page_info.h" 45 #include "extensions/common/manifest_handlers/launcher_page_info.h"
62 #include "ui/app_list/app_list_switches.h" 46 #include "ui/app_list/app_list_switches.h"
63 #include "ui/app_list/search_box_model.h" 47 #include "ui/app_list/search_box_model.h"
64 #include "ui/app_list/search_controller.h" 48 #include "ui/app_list/search_controller.h"
65 #include "ui/app_list/speech_ui_model.h" 49 #include "ui/app_list/speech_ui_model.h"
66 #include "ui/base/resource/resource_bundle.h" 50 #include "ui/base/resource/resource_bundle.h"
51 #include "ui/keyboard/keyboard_util.h"
67 #include "ui/views/controls/webview/webview.h" 52 #include "ui/views/controls/webview/webview.h"
68 53
69 #if defined(USE_AURA)
70 #include "ui/keyboard/keyboard_util.h"
71 #endif
72
73 #if defined(USE_ASH)
74 #include "chrome/browser/ui/ash/app_list/app_sync_ui_state_watcher.h"
75 #endif
76
77 namespace chrome {
78 const char kAppLauncherCategoryTag[] = "AppLauncher";
79 } // namespace chrome
80
81 namespace { 54 namespace {
82 55
83 const int kAutoLaunchDefaultTimeoutMilliSec = 50; 56 const int kAutoLaunchDefaultTimeoutMilliSec = 50;
84 57
85 void PopulateUsers(const base::FilePath& active_profile_path,
86 app_list::AppListViewDelegate::Users* users) {
87 users->clear();
88 std::vector<ProfileAttributesEntry*> entries = g_browser_process->
89 profile_manager()->GetProfileAttributesStorage().
90 GetAllProfilesAttributesSortedByName();
91 for (const auto* entry : entries) {
92 app_list::AppListViewDelegate::User user;
93 user.name = entry->GetName();
94 user.email = entry->GetUserName();
95 user.profile_path = entry->GetPath();
96 user.active = active_profile_path == user.profile_path;
97 users->push_back(user);
98 }
99 }
100
101 // Gets a list of URLs of the custom launcher pages to show in the launcher. 58 // Gets a list of URLs of the custom launcher pages to show in the launcher.
102 // Returns a URL for each installed launcher page. If --custom-launcher-page is 59 // Returns a URL for each installed launcher page. If --custom-launcher-page is
103 // specified and valid, also includes that URL. 60 // specified and valid, also includes that URL.
104 void GetCustomLauncherPageUrls(content::BrowserContext* browser_context, 61 void GetCustomLauncherPageUrls(content::BrowserContext* browser_context,
105 std::vector<GURL>* urls) { 62 std::vector<GURL>* urls) {
106 // First, check the command line. 63 // First, check the command line.
107 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); 64 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
108 if (command_line->HasSwitch(app_list::switches::kCustomLauncherPage)) { 65 if (command_line->HasSwitch(app_list::switches::kCustomLauncherPage)) {
109 GURL custom_launcher_page_url(command_line->GetSwitchValueASCII( 66 GURL custom_launcher_page_url(command_line->GetSwitchValueASCII(
110 app_list::switches::kCustomLauncherPage)); 67 app_list::switches::kCustomLauncherPage));
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 } 101 }
145 } 102 }
146 103
147 } // namespace 104 } // namespace
148 105
149 AppListViewDelegate::AppListViewDelegate(AppListControllerDelegate* controller) 106 AppListViewDelegate::AppListViewDelegate(AppListControllerDelegate* controller)
150 : controller_(controller), 107 : controller_(controller),
151 profile_(NULL), 108 profile_(NULL),
152 model_(NULL), 109 model_(NULL),
153 is_voice_query_(false), 110 is_voice_query_(false),
154 template_url_service_observer_(this), 111 template_url_service_observer_(this) {
155 scoped_observer_(this) {
156 CHECK(controller_); 112 CHECK(controller_);
157 // The SigninManagerFactor and the SigninManagers are observed to keep the
158 // profile switcher menu up to date, with the correct list of profiles and the
159 // correct email address (or none for signed out users) for each.
160 SigninManagerFactory::GetInstance()->AddObserver(this);
161
162 // Start observing all already-created SigninManagers.
163 ProfileManager* profile_manager = g_browser_process->profile_manager();
164 std::vector<Profile*> profiles = profile_manager->GetLoadedProfiles();
165
166 for (std::vector<Profile*>::iterator i = profiles.begin();
167 i != profiles.end();
168 ++i) {
169 SigninManagerBase* manager =
170 SigninManagerFactory::GetForProfileIfExists(*i);
171 if (manager) {
172 DCHECK(!scoped_observer_.IsObserving(manager));
173 scoped_observer_.Add(manager);
174 }
175 }
176
177 profile_manager->GetProfileAttributesStorage().AddObserver(this);
178 speech_ui_.reset(new app_list::SpeechUIModel); 113 speech_ui_.reset(new app_list::SpeechUIModel);
179 114
180 #if defined(GOOGLE_CHROME_BUILD) 115 #if defined(GOOGLE_CHROME_BUILD)
181 gfx::ImageSkia* image; 116 gfx::ImageSkia* image;
182 { 117 {
183 // TODO(tapted): Remove ScopedTracker below once crbug.com/431326 is fixed. 118 // TODO(tapted): Remove ScopedTracker below once crbug.com/431326 is fixed.
184 tracked_objects::ScopedTracker tracking_profile( 119 tracked_objects::ScopedTracker tracking_profile(
185 FROM_HERE_WITH_EXPLICIT_FUNCTION("431326 GetImageSkiaNamed()")); 120 FROM_HERE_WITH_EXPLICIT_FUNCTION("431326 GetImageSkiaNamed()"));
186 image = ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( 121 image = ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
187 IDR_APP_LIST_GOOGLE_LOGO_VOICE_SEARCH); 122 IDR_APP_LIST_GOOGLE_LOGO_VOICE_SEARCH);
188 } 123 }
189 124
190 speech_ui_->set_logo(*image); 125 speech_ui_->set_logo(*image);
191 #endif 126 #endif
192 127
193 registrar_.Add(this, 128 registrar_.Add(this,
194 chrome::NOTIFICATION_APP_TERMINATING, 129 chrome::NOTIFICATION_APP_TERMINATING,
195 content::NotificationService::AllSources()); 130 content::NotificationService::AllSources());
196 } 131 }
197 132
198 AppListViewDelegate::~AppListViewDelegate() { 133 AppListViewDelegate::~AppListViewDelegate() {
199 // Note that the destructor is not always called. E.g. on Mac, this is owned 134 // Note that the destructor is not always called. Essential shutdown work must
Matt Giuca 2017/03/31 05:29:20 Is this no longer true? (If the only example provi
tapted 2017/03/31 05:55:25 So.. I *think* is is no longer true. Pretty sure t
tapted 2017/03/31 10:59:23 Poked around - it looks like AppListServiceAsh is
200 // by a leaky singleton. Essential shutdown work must be done by observing 135 // be done by observing chrome::NOTIFICATION_APP_TERMINATING.
201 // chrome::NOTIFICATION_APP_TERMINATING.
202 SetProfile(NULL); 136 SetProfile(NULL);
203 g_browser_process->profile_manager()->GetProfileAttributesStorage().
204 RemoveObserver(this);
205
206 SigninManagerFactory* factory = SigninManagerFactory::GetInstance();
207 if (factory)
208 factory->RemoveObserver(this);
209 } 137 }
210 138
211 void AppListViewDelegate::SetProfile(Profile* new_profile) { 139 void AppListViewDelegate::SetProfile(Profile* new_profile) {
212 if (profile_ == new_profile) 140 if (profile_ == new_profile)
213 return; 141 return;
214 142
215 if (profile_) { 143 if (profile_) {
216 // Note: |search_resource_manager_| has a reference to |speech_ui_| so must 144 // Note: |search_resource_manager_| has a reference to |speech_ui_| so must
217 // be destroyed first. 145 // be destroyed first.
218 search_resource_manager_.reset(); 146 search_resource_manager_.reset();
219 search_controller_.reset(); 147 search_controller_.reset();
220 launcher_page_event_dispatcher_.reset(); 148 launcher_page_event_dispatcher_.reset();
221 custom_page_contents_.clear(); 149 custom_page_contents_.clear();
222 app_list::StartPageService* start_page_service = 150 app_list::StartPageService* start_page_service =
223 app_list::StartPageService::Get(profile_); 151 app_list::StartPageService::Get(profile_);
224 if (start_page_service) 152 if (start_page_service)
225 start_page_service->RemoveObserver(this); 153 start_page_service->RemoveObserver(this);
226 #if defined(USE_ASH)
227 app_sync_ui_state_watcher_.reset(); 154 app_sync_ui_state_watcher_.reset();
228 #endif
229 model_ = NULL; 155 model_ = NULL;
230 } 156 }
231 157
232 template_url_service_observer_.RemoveAll(); 158 template_url_service_observer_.RemoveAll();
233 159
234 profile_ = new_profile; 160 profile_ = new_profile;
235 if (!profile_) { 161 if (!profile_) {
236 speech_ui_->SetSpeechRecognitionState(app_list::SPEECH_RECOGNITION_OFF, 162 speech_ui_->SetSpeechRecognitionState(app_list::SPEECH_RECOGNITION_OFF,
237 false); 163 false);
238 return; 164 return;
(...skipping 11 matching lines...) Expand all
250 tracked_objects::ScopedTracker tracking_profile( 176 tracked_objects::ScopedTracker tracking_profile(
251 FROM_HERE_WITH_EXPLICIT_FUNCTION( 177 FROM_HERE_WITH_EXPLICIT_FUNCTION(
252 "431326 AppListViewDelegate TemplateURL etc.")); 178 "431326 AppListViewDelegate TemplateURL etc."));
253 TemplateURLService* template_url_service = 179 TemplateURLService* template_url_service =
254 TemplateURLServiceFactory::GetForProfile(profile_); 180 TemplateURLServiceFactory::GetForProfile(profile_);
255 template_url_service_observer_.Add(template_url_service); 181 template_url_service_observer_.Add(template_url_service);
256 182
257 model_ = app_list::AppListSyncableServiceFactory::GetForProfile(profile_) 183 model_ = app_list::AppListSyncableServiceFactory::GetForProfile(profile_)
258 ->GetModel(); 184 ->GetModel();
259 185
260 #if defined(USE_ASH)
261 app_sync_ui_state_watcher_.reset( 186 app_sync_ui_state_watcher_.reset(
262 new AppSyncUIStateWatcher(profile_, model_)); 187 new AppSyncUIStateWatcher(profile_, model_));
263 #endif
264 188
265 SetUpSearchUI(); 189 SetUpSearchUI();
266 SetUpProfileSwitcher();
267 SetUpCustomLauncherPages(); 190 SetUpCustomLauncherPages();
268 OnTemplateURLServiceChanged(); 191 OnTemplateURLServiceChanged();
269 } 192 }
270 193
271 // Clear search query. 194 // Clear search query.
272 model_->search_box()->SetText(base::string16()); 195 model_->search_box()->SetText(base::string16());
273 } 196 }
274 197
275 void AppListViewDelegate::SetUpSearchUI() { 198 void AppListViewDelegate::SetUpSearchUI() {
276 app_list::StartPageService* start_page_service = 199 app_list::StartPageService* start_page_service =
277 app_list::StartPageService::Get(profile_); 200 app_list::StartPageService::Get(profile_);
278 if (start_page_service) 201 if (start_page_service)
279 start_page_service->AddObserver(this); 202 start_page_service->AddObserver(this);
280 203
281 speech_ui_->SetSpeechRecognitionState(start_page_service 204 speech_ui_->SetSpeechRecognitionState(start_page_service
282 ? start_page_service->state() 205 ? start_page_service->state()
283 : app_list::SPEECH_RECOGNITION_OFF, 206 : app_list::SPEECH_RECOGNITION_OFF,
284 false); 207 false);
285 208
286 search_resource_manager_.reset(new app_list::SearchResourceManager( 209 search_resource_manager_.reset(new app_list::SearchResourceManager(
287 profile_, 210 profile_,
288 model_->search_box(), 211 model_->search_box(),
289 speech_ui_.get())); 212 speech_ui_.get()));
290 213
291 search_controller_ = CreateSearchController(profile_, model_, controller_); 214 search_controller_ = CreateSearchController(profile_, model_, controller_);
292 } 215 }
293 216
294 void AppListViewDelegate::SetUpProfileSwitcher() {
295 // If a profile change is observed when there is no app list, there is nothing
296 // to update until SetProfile() calls this function again.
297 if (!profile_)
298 return;
299
300 #if defined(USE_ASH)
301 // Don't populate the app list users if we are on the ash desktop.
302 return;
303 #endif // USE_ASH
304
305 // Populate the app list users.
306 PopulateUsers(profile_->GetPath(), &users_);
307 }
308
309 void AppListViewDelegate::SetUpCustomLauncherPages() { 217 void AppListViewDelegate::SetUpCustomLauncherPages() {
310 std::vector<GURL> custom_launcher_page_urls; 218 std::vector<GURL> custom_launcher_page_urls;
311 GetCustomLauncherPageUrls(profile_, &custom_launcher_page_urls); 219 GetCustomLauncherPageUrls(profile_, &custom_launcher_page_urls);
312 if (custom_launcher_page_urls.empty()) 220 if (custom_launcher_page_urls.empty())
313 return; 221 return;
314 222
315 for (auto it = custom_launcher_page_urls.begin(); 223 for (auto it = custom_launcher_page_urls.begin();
316 it != custom_launcher_page_urls.end(); ++it) { 224 it != custom_launcher_page_urls.end(); ++it) {
317 std::string extension_id = it->host(); 225 std::string extension_id = it->host();
318 auto page_contents = base::MakeUnique<app_list::CustomLauncherPageContents>( 226 auto page_contents = base::MakeUnique<app_list::CustomLauncherPageContents>(
(...skipping 26 matching lines...) Expand all
345 } 253 }
346 } 254 }
347 255
348 void AppListViewDelegate::OnHotwordRecognized( 256 void AppListViewDelegate::OnHotwordRecognized(
349 const scoped_refptr<content::SpeechRecognitionSessionPreamble>& preamble) { 257 const scoped_refptr<content::SpeechRecognitionSessionPreamble>& preamble) {
350 DCHECK_EQ(app_list::SPEECH_RECOGNITION_HOTWORD_LISTENING, 258 DCHECK_EQ(app_list::SPEECH_RECOGNITION_HOTWORD_LISTENING,
351 speech_ui_->state()); 259 speech_ui_->state());
352 StartSpeechRecognitionForHotword(preamble); 260 StartSpeechRecognitionForHotword(preamble);
353 } 261 }
354 262
355 void AppListViewDelegate::SigninManagerCreated(SigninManagerBase* manager) {
356 scoped_observer_.Add(manager);
357 }
358
359 void AppListViewDelegate::SigninManagerShutdown(SigninManagerBase* manager) {
360 if (scoped_observer_.IsObserving(manager))
361 scoped_observer_.Remove(manager);
362 }
363
364 void AppListViewDelegate::GoogleSigninFailed(
365 const GoogleServiceAuthError& error) {
366 SetUpProfileSwitcher();
367 }
368
369 void AppListViewDelegate::GoogleSigninSucceeded(const std::string& account_id,
370 const std::string& username,
371 const std::string& password) {
372 SetUpProfileSwitcher();
373 }
374
375 void AppListViewDelegate::GoogleSignedOut(const std::string& account_id,
376 const std::string& username) {
377 SetUpProfileSwitcher();
378 }
379
380 void AppListViewDelegate::OnProfileAdded(const base::FilePath& profile_path) {
381 SetUpProfileSwitcher();
382 }
383
384 void AppListViewDelegate::OnProfileWasRemoved(
385 const base::FilePath& profile_path,
386 const base::string16& profile_name) {
387 SetUpProfileSwitcher();
388 }
389
390 void AppListViewDelegate::OnProfileNameChanged(
391 const base::FilePath& profile_path,
392 const base::string16& old_profile_name) {
393 SetUpProfileSwitcher();
394 }
395
396 bool AppListViewDelegate::ForceNativeDesktop() const {
397 return controller_->ForceNativeDesktop();
398 }
399
400 void AppListViewDelegate::SetProfileByPath(const base::FilePath& profile_path) {
401 DCHECK(model_);
402 // The profile must be loaded before this is called.
403 SetProfile(
404 g_browser_process->profile_manager()->GetProfileByPath(profile_path));
405 }
406
407 app_list::AppListModel* AppListViewDelegate::GetModel() { 263 app_list::AppListModel* AppListViewDelegate::GetModel() {
408 return model_; 264 return model_;
409 } 265 }
410 266
411 app_list::SpeechUIModel* AppListViewDelegate::GetSpeechUI() { 267 app_list::SpeechUIModel* AppListViewDelegate::GetSpeechUI() {
412 return speech_ui_.get(); 268 return speech_ui_.get();
413 } 269 }
414 270
415 void AppListViewDelegate::StartSearch() { 271 void AppListViewDelegate::StartSearch() {
416 if (search_controller_) { 272 if (search_controller_) {
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 // the launcher to open. 355 // the launcher to open.
500 // TODO(amistry): This only works on ChromeOS since Chrome hides the 356 // TODO(amistry): This only works on ChromeOS since Chrome hides the
501 // launcher instead of destroying it. Make this work on Chrome. 357 // launcher instead of destroying it. Make this work on Chrome.
502 if (hotword_service->IsAlwaysOnEnabled()) 358 if (hotword_service->IsAlwaysOnEnabled())
503 hotword_service->RequestHotwordSession(nullptr); 359 hotword_service->RequestHotwordSession(nullptr);
504 } 360 }
505 } 361 }
506 } 362 }
507 } 363 }
508 364
509 void AppListViewDelegate::OpenHelp() {
510 chrome::ScopedTabbedBrowserDisplayer displayer(profile_);
511 content::OpenURLParams params(GURL(chrome::kAppLauncherHelpURL),
512 content::Referrer(),
513 WindowOpenDisposition::NEW_FOREGROUND_TAB,
514 ui::PAGE_TRANSITION_LINK, false);
515 displayer.browser()->OpenURL(params);
516 }
517
518 void AppListViewDelegate::OpenFeedback() {
519 Browser* browser = chrome::FindTabbedBrowser(profile_, false);
520 chrome::ShowFeedbackPage(browser, std::string(),
521 chrome::kAppLauncherCategoryTag);
522 }
523
524 void AppListViewDelegate::StartSpeechRecognition() { 365 void AppListViewDelegate::StartSpeechRecognition() {
525 StartSpeechRecognitionForHotword(nullptr); 366 StartSpeechRecognitionForHotword(nullptr);
526 } 367 }
527 368
528 void AppListViewDelegate::StopSpeechRecognition() { 369 void AppListViewDelegate::StopSpeechRecognition() {
529 app_list::StartPageService* service = 370 app_list::StartPageService* service =
530 app_list::StartPageService::Get(profile_); 371 app_list::StartPageService::Get(profile_);
531 if (service) 372 if (service)
532 service->StopSpeechRecognition(); 373 service->StopSpeechRecognition();
533 } 374 }
(...skipping 24 matching lines...) Expand all
558 // To get around this, always stop the session when switching to speech 399 // To get around this, always stop the session when switching to speech
559 // recognition. 400 // recognition.
560 if (service && service->HotwordEnabled()) { 401 if (service && service->HotwordEnabled()) {
561 HotwordService* hotword_service = 402 HotwordService* hotword_service =
562 HotwordServiceFactory::GetForProfile(profile_); 403 HotwordServiceFactory::GetForProfile(profile_);
563 if (hotword_service) 404 if (hotword_service)
564 hotword_service->StopHotwordSession(this); 405 hotword_service->StopHotwordSession(this);
565 } 406 }
566 } 407 }
567 408
568 void AppListViewDelegate::ShowForProfileByPath(
569 const base::FilePath& profile_path) {
570 controller_->ShowForProfileByPath(profile_path);
571 }
572
573 void AppListViewDelegate::OnSpeechResult(const base::string16& result, 409 void AppListViewDelegate::OnSpeechResult(const base::string16& result,
574 bool is_final) { 410 bool is_final) {
575 speech_ui_->SetSpeechResult(result, is_final); 411 speech_ui_->SetSpeechResult(result, is_final);
576 if (is_final) { 412 if (is_final) {
577 auto_launch_timeout_ = base::TimeDelta::FromMilliseconds( 413 auto_launch_timeout_ = base::TimeDelta::FromMilliseconds(
578 kAutoLaunchDefaultTimeoutMilliSec); 414 kAutoLaunchDefaultTimeoutMilliSec);
579 is_voice_query_ = true; 415 is_voice_query_ = true;
580 model_->search_box()->SetText(result); 416 model_->search_box()->SetText(result);
581 } 417 }
582 } 418 }
(...skipping 15 matching lines...) Expand all
598 service && service->HotwordEnabled() && 434 service && service->HotwordEnabled() &&
599 controller_->GetAppListWindow()) { 435 controller_->GetAppListWindow()) {
600 HotwordService* hotword_service = 436 HotwordService* hotword_service =
601 HotwordServiceFactory::GetForProfile(profile_); 437 HotwordServiceFactory::GetForProfile(profile_);
602 if (hotword_service) { 438 if (hotword_service) {
603 hotword_service->RequestHotwordSession(this); 439 hotword_service->RequestHotwordSession(this);
604 } 440 }
605 } 441 }
606 } 442 }
607 443
608 #if defined(TOOLKIT_VIEWS)
609 views::View* AppListViewDelegate::CreateStartPageWebView( 444 views::View* AppListViewDelegate::CreateStartPageWebView(
610 const gfx::Size& size) { 445 const gfx::Size& size) {
611 app_list::StartPageService* service = 446 app_list::StartPageService* service =
612 app_list::StartPageService::Get(profile_); 447 app_list::StartPageService::Get(profile_);
613 if (!service) 448 if (!service)
614 return NULL; 449 return NULL;
615 450
616 service->LoadContentsIfNeeded(); 451 service->LoadContentsIfNeeded();
617 452
618 content::WebContents* web_contents = service->GetStartPageContents(); 453 content::WebContents* web_contents = service->GetStartPageContents();
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
658 493
659 void AppListViewDelegate::CustomLauncherPageAnimationChanged(double progress) { 494 void AppListViewDelegate::CustomLauncherPageAnimationChanged(double progress) {
660 if (launcher_page_event_dispatcher_) 495 if (launcher_page_event_dispatcher_)
661 launcher_page_event_dispatcher_->ProgressChanged(progress); 496 launcher_page_event_dispatcher_->ProgressChanged(progress);
662 } 497 }
663 498
664 void AppListViewDelegate::CustomLauncherPagePopSubpage() { 499 void AppListViewDelegate::CustomLauncherPagePopSubpage() {
665 if (launcher_page_event_dispatcher_) 500 if (launcher_page_event_dispatcher_)
666 launcher_page_event_dispatcher_->PopSubpage(); 501 launcher_page_event_dispatcher_->PopSubpage();
667 } 502 }
668 #endif
669 503
670 bool AppListViewDelegate::IsSpeechRecognitionEnabled() { 504 bool AppListViewDelegate::IsSpeechRecognitionEnabled() {
671 app_list::StartPageService* service = 505 app_list::StartPageService* service =
672 app_list::StartPageService::Get(profile_); 506 app_list::StartPageService::Get(profile_);
673 return service && service->GetSpeechRecognitionContents(); 507 return service && service->GetSpeechRecognitionContents();
674 } 508 }
675 509
676 const app_list::AppListViewDelegate::Users&
677 AppListViewDelegate::GetUsers() const {
678 return users_;
679 }
680
681 void AppListViewDelegate::OnTemplateURLServiceChanged() { 510 void AppListViewDelegate::OnTemplateURLServiceChanged() {
682 TemplateURLService* template_url_service = 511 TemplateURLService* template_url_service =
683 TemplateURLServiceFactory::GetForProfile(profile_); 512 TemplateURLServiceFactory::GetForProfile(profile_);
684 const TemplateURL* default_provider = 513 const TemplateURL* default_provider =
685 template_url_service->GetDefaultSearchProvider(); 514 template_url_service->GetDefaultSearchProvider();
686 bool is_google = 515 bool is_google =
687 default_provider->GetEngineType( 516 default_provider->GetEngineType(
688 template_url_service->search_terms_data()) == 517 template_url_service->search_terms_data()) ==
689 SEARCH_ENGINE_GOOGLE; 518 SEARCH_ENGINE_GOOGLE;
690 519
691 model_->SetSearchEngineIsGoogle(is_google); 520 model_->SetSearchEngineIsGoogle(is_google);
692 521
693 app_list::StartPageService* start_page_service = 522 app_list::StartPageService* start_page_service =
694 app_list::StartPageService::Get(profile_); 523 app_list::StartPageService::Get(profile_);
695 if (start_page_service) 524 if (start_page_service)
696 start_page_service->set_search_engine_is_google(is_google); 525 start_page_service->set_search_engine_is_google(is_google);
697 } 526 }
698 527
699 void AppListViewDelegate::Observe(int type, 528 void AppListViewDelegate::Observe(int type,
700 const content::NotificationSource& source, 529 const content::NotificationSource& source,
701 const content::NotificationDetails& details) { 530 const content::NotificationDetails& details) {
702 DCHECK_EQ(chrome::NOTIFICATION_APP_TERMINATING, type); 531 DCHECK_EQ(chrome::NOTIFICATION_APP_TERMINATING, type);
703 532
704 SetProfile(nullptr); // Ensures launcher page web contents are torn down. 533 SetProfile(nullptr); // Ensures launcher page web contents are torn down.
705
706 // SigninManagerFactory is not a leaky singleton (unlike this class), and
707 // its destructor will check that it has no remaining observers.
708 scoped_observer_.RemoveAll();
709 SigninManagerFactory::GetInstance()->RemoveObserver(this);
710 } 534 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/app_list/app_list_view_delegate.h ('k') | chrome/browser/ui/app_list/extension_app_item.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698