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

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

Issue 2339523004: Remove old (dead) app list code. (Closed)
Patch Set: Address nonbistytftatl review. Created 4 years, 3 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 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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <string> 9 #include <string>
10 10
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 state_(app_list::SPEECH_RECOGNITION_READY), 321 state_(app_list::SPEECH_RECOGNITION_READY),
322 speech_button_toggled_manually_(false), 322 speech_button_toggled_manually_(false),
323 speech_result_obtained_(false), 323 speech_result_obtained_(false),
324 webui_finished_loading_(false), 324 webui_finished_loading_(false),
325 speech_auth_helper_(new SpeechAuthHelper(profile, &clock_)), 325 speech_auth_helper_(new SpeechAuthHelper(profile, &clock_)),
326 network_available_(true), 326 network_available_(true),
327 microphone_available_(true), 327 microphone_available_(true),
328 search_engine_is_google_(false), 328 search_engine_is_google_(false),
329 backoff_entry_(&kDoodleBackoffPolicy), 329 backoff_entry_(&kDoodleBackoffPolicy),
330 weak_factory_(this) { 330 weak_factory_(this) {
331 if (switches::IsExperimentalAppListEnabled()) { 331 TemplateURLService* template_url_service =
332 TemplateURLService* template_url_service = 332 TemplateURLServiceFactory::GetForProfile(profile_);
333 TemplateURLServiceFactory::GetForProfile(profile_); 333 const TemplateURL* default_provider =
334 const TemplateURL* default_provider = 334 template_url_service->GetDefaultSearchProvider();
335 template_url_service->GetDefaultSearchProvider(); 335 search_engine_is_google_ =
336 search_engine_is_google_ = 336 default_provider->GetEngineType(
337 default_provider->GetEngineType( 337 template_url_service->search_terms_data()) == SEARCH_ENGINE_GOOGLE;
338 template_url_service->search_terms_data()) ==
339 SEARCH_ENGINE_GOOGLE;
340 }
341 338
342 network_change_observer_.reset(new NetworkChangeObserver(this)); 339 network_change_observer_.reset(new NetworkChangeObserver(this));
343 } 340 }
344 341
345 StartPageService::~StartPageService() { 342 StartPageService::~StartPageService() {
346 } 343 }
347 344
348 void StartPageService::AddObserver(StartPageObserver* observer) { 345 void StartPageService::AddObserver(StartPageObserver* observer) {
349 observers_.AddObserver(observer); 346 observers_.AddObserver(observer);
350 } 347 }
(...skipping 19 matching lines...) Expand all
370 OnSpeechRecognitionStateChanged(SPEECH_RECOGNITION_READY); 367 OnSpeechRecognitionStateChanged(SPEECH_RECOGNITION_READY);
371 } else { 368 } else {
372 OnSpeechRecognitionStateChanged(network_available_ ? SPEECH_RECOGNITION_OFF 369 OnSpeechRecognitionStateChanged(network_available_ ? SPEECH_RECOGNITION_OFF
373 : SPEECH_RECOGNITION_NETWORK_ERROR); 370 : SPEECH_RECOGNITION_NETWORK_ERROR);
374 } 371 }
375 } 372 }
376 373
377 void StartPageService::Init() { 374 void StartPageService::Init() {
378 // Do not load the start page web contents in tests because many tests assume 375 // Do not load the start page web contents in tests because many tests assume
379 // no WebContents exist except the ones they make. 376 // no WebContents exist except the ones they make.
380 if (switches::IsExperimentalAppListEnabled() && 377 if (base::CommandLine::ForCurrentProcess()->HasSwitch(::switches::kTestType))
381 !base::CommandLine::ForCurrentProcess()->HasSwitch( 378 return;
382 ::switches::kTestType)) { 379
383 content::BrowserThread::PostDelayedTask( 380 content::BrowserThread::PostDelayedTask(
384 content::BrowserThread::UI, FROM_HERE, 381 content::BrowserThread::UI, FROM_HERE,
385 base::Bind(&StartPageService::LoadContentsIfNeeded, 382 base::Bind(&StartPageService::LoadContentsIfNeeded,
386 weak_factory_.GetWeakPtr()), 383 weak_factory_.GetWeakPtr()),
387 base::TimeDelta::FromSeconds(kLoadContentsDelaySeconds)); 384 base::TimeDelta::FromSeconds(kLoadContentsDelaySeconds));
388 }
389 } 385 }
390 386
391 void StartPageService::LoadContentsIfNeeded() { 387 void StartPageService::LoadContentsIfNeeded() {
392 if (!contents_) 388 if (!contents_)
393 LoadContents(); 389 LoadContents();
394 } 390 }
395 391
396 bool StartPageService::ShouldEnableSpeechRecognition() const { 392 bool StartPageService::ShouldEnableSpeechRecognition() const {
397 return microphone_available_ && network_available_; 393 return microphone_available_ && network_available_;
398 } 394 }
399 395
400 void StartPageService::AppListShown() { 396 void StartPageService::AppListShown() {
401 if (!contents_) { 397 if (!contents_) {
402 LoadContents(); 398 LoadContents();
403 } else if (contents_->IsCrashed()) { 399 } else if (contents_->IsCrashed()) {
404 LoadStartPageURL(); 400 LoadStartPageURL();
405 } else if (contents_->GetWebUI()) { 401 } else if (contents_->GetWebUI()) {
406 contents_->GetWebUI()->CallJavascriptFunctionUnsafe( 402 contents_->GetWebUI()->CallJavascriptFunctionUnsafe(
407 "appList.startPage.onAppListShown"); 403 "appList.startPage.onAppListShown");
408 } 404 }
409 405
410 #if defined(OS_CHROMEOS) 406 #if defined(OS_CHROMEOS)
411 audio_status_.reset(new AudioStatus(this)); 407 audio_status_.reset(new AudioStatus(this));
412 #endif 408 #endif
413 } 409 }
414 410
415 void StartPageService::AppListHidden() { 411 void StartPageService::AppListHidden() {
416 if (!app_list::switches::IsExperimentalAppListEnabled())
417 UnloadContents();
418
419 if (speech_recognizer_) { 412 if (speech_recognizer_) {
420 StopSpeechRecognition(); 413 StopSpeechRecognition();
421 } 414 }
422 415
423 #if defined(OS_CHROMEOS) 416 #if defined(OS_CHROMEOS)
424 audio_status_.reset(); 417 audio_status_.reset();
425 #endif 418 #endif
426 } 419 }
427 420
428 void StartPageService::StartSpeechRecognition( 421 void StartPageService::StartSpeechRecognition(
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 return state_ != SPEECH_RECOGNITION_OFF && 460 return state_ != SPEECH_RECOGNITION_OFF &&
468 service && 461 service &&
469 (service->IsSometimesOnEnabled() || service->IsAlwaysOnEnabled()) && 462 (service->IsSometimesOnEnabled() || service->IsAlwaysOnEnabled()) &&
470 service->IsServiceAvailable(); 463 service->IsServiceAvailable();
471 #else 464 #else
472 return false; 465 return false;
473 #endif 466 #endif
474 } 467 }
475 468
476 content::WebContents* StartPageService::GetStartPageContents() { 469 content::WebContents* StartPageService::GetStartPageContents() {
477 return app_list::switches::IsExperimentalAppListEnabled() ? contents_.get() 470 return contents_.get();
478 : NULL;
479 } 471 }
480 472
481 content::WebContents* StartPageService::GetSpeechRecognitionContents() { 473 content::WebContents* StartPageService::GetSpeechRecognitionContents() {
482 if (app_list::switches::IsVoiceSearchEnabled()) { 474 if (app_list::switches::IsVoiceSearchEnabled()) {
483 if (!contents_) 475 if (!contents_)
484 LoadContents(); 476 LoadContents();
485 return contents_.get(); 477 return contents_.get();
486 } 478 }
487 return NULL; 479 return NULL;
488 } 480 }
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
694 686
695 // Check for a new doodle. 687 // Check for a new doodle.
696 content::BrowserThread::PostDelayedTask( 688 content::BrowserThread::PostDelayedTask(
697 content::BrowserThread::UI, FROM_HERE, 689 content::BrowserThread::UI, FROM_HERE,
698 base::Bind(&StartPageService::FetchDoodleJson, 690 base::Bind(&StartPageService::FetchDoodleJson,
699 weak_factory_.GetWeakPtr()), 691 weak_factory_.GetWeakPtr()),
700 recheck_delay); 692 recheck_delay);
701 } 693 }
702 694
703 } // namespace app_list 695 } // namespace app_list
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698