| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 bool StartPageService::ShouldEnableSpeechRecognition() const { | 401 bool StartPageService::ShouldEnableSpeechRecognition() const { |
| 402 return microphone_available_ && network_available_; | 402 return microphone_available_ && network_available_; |
| 403 } | 403 } |
| 404 | 404 |
| 405 void StartPageService::AppListShown() { | 405 void StartPageService::AppListShown() { |
| 406 if (!contents_) { | 406 if (!contents_) { |
| 407 LoadContents(); | 407 LoadContents(); |
| 408 } else if (contents_->IsCrashed()) { | 408 } else if (contents_->IsCrashed()) { |
| 409 LoadStartPageURL(); | 409 LoadStartPageURL(); |
| 410 } else if (contents_->GetWebUI()) { | 410 } else if (contents_->GetWebUI()) { |
| 411 contents_->GetWebUI()->CallJavascriptFunction( | 411 contents_->GetWebUI()->CallJavascriptFunctionUnsafe( |
| 412 "appList.startPage.onAppListShown"); | 412 "appList.startPage.onAppListShown"); |
| 413 } | 413 } |
| 414 | 414 |
| 415 #if defined(OS_CHROMEOS) | 415 #if defined(OS_CHROMEOS) |
| 416 audio_status_.reset(new AudioStatus(this)); | 416 audio_status_.reset(new AudioStatus(this)); |
| 417 #endif | 417 #endif |
| 418 } | 418 } |
| 419 | 419 |
| 420 void StartPageService::AppListHidden() { | 420 void StartPageService::AppListHidden() { |
| 421 if (!app_list::switches::IsExperimentalAppListEnabled()) | 421 if (!app_list::switches::IsExperimentalAppListEnabled()) |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 683 // On failure, use expotential backoff. | 683 // On failure, use expotential backoff. |
| 684 backoff_entry_.InformOfRequest(false); | 684 backoff_entry_.InformOfRequest(false); |
| 685 recheck_delay = backoff_entry_.GetTimeUntilRelease(); | 685 recheck_delay = backoff_entry_.GetTimeUntilRelease(); |
| 686 } else { | 686 } else { |
| 687 // If we received information, even if there's no doodle, reset the backoff | 687 // If we received information, even if there's no doodle, reset the backoff |
| 688 // entry and start rechecking for the doodle at the maximum interval. | 688 // entry and start rechecking for the doodle at the maximum interval. |
| 689 backoff_entry_.Reset(); | 689 backoff_entry_.Reset(); |
| 690 recheck_delay = base::TimeDelta::FromMilliseconds(kMaximumRecheckDelayMs); | 690 recheck_delay = base::TimeDelta::FromMilliseconds(kMaximumRecheckDelayMs); |
| 691 | 691 |
| 692 if (contents_ && contents_->GetWebUI()) { | 692 if (contents_ && contents_->GetWebUI()) { |
| 693 contents_->GetWebUI()->CallJavascriptFunction( | 693 contents_->GetWebUI()->CallJavascriptFunctionUnsafe( |
| 694 "appList.startPage.onAppListDoodleUpdated", *doodle_json, | 694 "appList.startPage.onAppListDoodleUpdated", *doodle_json, |
| 695 base::StringValue( | 695 base::StringValue( |
| 696 UIThreadSearchTermsData(profile_).GoogleBaseURLValue())); | 696 UIThreadSearchTermsData(profile_).GoogleBaseURLValue())); |
| 697 } | 697 } |
| 698 } | 698 } |
| 699 | 699 |
| 700 // Check for a new doodle. | 700 // Check for a new doodle. |
| 701 content::BrowserThread::PostDelayedTask( | 701 content::BrowserThread::PostDelayedTask( |
| 702 content::BrowserThread::UI, FROM_HERE, | 702 content::BrowserThread::UI, FROM_HERE, |
| 703 base::Bind(&StartPageService::FetchDoodleJson, | 703 base::Bind(&StartPageService::FetchDoodleJson, |
| 704 weak_factory_.GetWeakPtr()), | 704 weak_factory_.GetWeakPtr()), |
| 705 recheck_delay); | 705 recheck_delay); |
| 706 } | 706 } |
| 707 | 707 |
| 708 } // namespace app_list | 708 } // namespace app_list |
| OLD | NEW |