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/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 StartPageService::StartPageService(Profile* profile) | 261 StartPageService::StartPageService(Profile* profile) |
262 : profile_(profile), | 262 : profile_(profile), |
263 profile_destroy_observer_(new ProfileDestroyObserver(this)), | 263 profile_destroy_observer_(new ProfileDestroyObserver(this)), |
264 state_(app_list::SPEECH_RECOGNITION_OFF), | 264 state_(app_list::SPEECH_RECOGNITION_OFF), |
265 speech_button_toggled_manually_(false), | 265 speech_button_toggled_manually_(false), |
266 speech_result_obtained_(false), | 266 speech_result_obtained_(false), |
267 webui_finished_loading_(false), | 267 webui_finished_loading_(false), |
268 speech_auth_helper_(new SpeechAuthHelper(profile, &clock_)), | 268 speech_auth_helper_(new SpeechAuthHelper(profile, &clock_)), |
269 network_available_(true), | 269 network_available_(true), |
270 microphone_available_(true), | 270 microphone_available_(true), |
| 271 doodle_enabled_(true), |
271 weak_factory_(this) { | 272 weak_factory_(this) { |
272 // If experimental hotwording is enabled, then we're always "ready". | 273 // If experimental hotwording is enabled, then we're always "ready". |
273 // Transitioning into the "hotword recognizing" state is handled by the | 274 // Transitioning into the "hotword recognizing" state is handled by the |
274 // hotword extension. | 275 // hotword extension. |
275 if (HotwordService::IsExperimentalHotwordingEnabled()) { | 276 if (HotwordService::IsExperimentalHotwordingEnabled()) { |
276 state_ = app_list::SPEECH_RECOGNITION_READY; | 277 state_ = app_list::SPEECH_RECOGNITION_READY; |
277 } | 278 } |
278 | 279 |
279 if (app_list::switches::IsExperimentalAppListEnabled()) | 280 if (app_list::switches::IsExperimentalAppListEnabled()) |
280 LoadContents(); | 281 LoadContents(); |
281 | 282 |
282 network_change_observer_.reset(new NetworkChangeObserver(this)); | 283 network_change_observer_.reset(new NetworkChangeObserver(this)); |
283 } | 284 } |
284 | 285 |
285 StartPageService::~StartPageService() {} | 286 StartPageService::~StartPageService() { |
| 287 } |
286 | 288 |
287 void StartPageService::AddObserver(StartPageObserver* observer) { | 289 void StartPageService::AddObserver(StartPageObserver* observer) { |
288 observers_.AddObserver(observer); | 290 observers_.AddObserver(observer); |
289 } | 291 } |
290 | 292 |
291 void StartPageService::RemoveObserver(StartPageObserver* observer) { | 293 void StartPageService::RemoveObserver(StartPageObserver* observer) { |
292 observers_.RemoveObserver(observer); | 294 observers_.RemoveObserver(observer); |
293 } | 295 } |
294 | 296 |
295 void StartPageService::OnMicrophoneChanged(bool available) { | 297 void StartPageService::OnMicrophoneChanged(bool available) { |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
552 ui::PAGE_TRANSITION_AUTO_TOPLEVEL, | 554 ui::PAGE_TRANSITION_AUTO_TOPLEVEL, |
553 std::string()); | 555 std::string()); |
554 } | 556 } |
555 | 557 |
556 void StartPageService::UnloadContents() { | 558 void StartPageService::UnloadContents() { |
557 contents_.reset(); | 559 contents_.reset(); |
558 webui_finished_loading_ = false; | 560 webui_finished_loading_ = false; |
559 } | 561 } |
560 | 562 |
561 void StartPageService::FetchDoodleJson() { | 563 void StartPageService::FetchDoodleJson() { |
| 564 if (!doodle_enabled_) |
| 565 return; |
| 566 |
562 GURL::Replacements replacements; | 567 GURL::Replacements replacements; |
563 replacements.SetPathStr(kDoodleJsonPath); | 568 replacements.SetPathStr(kDoodleJsonPath); |
564 | 569 |
565 GURL google_base_url(UIThreadSearchTermsData(profile_).GoogleBaseURLValue()); | 570 GURL google_base_url(UIThreadSearchTermsData(profile_).GoogleBaseURLValue()); |
566 GURL doodle_url = google_base_url.ReplaceComponents(replacements); | 571 GURL doodle_url = google_base_url.ReplaceComponents(replacements); |
567 doodle_fetcher_.reset( | 572 doodle_fetcher_.reset( |
568 net::URLFetcher::Create(0, doodle_url, net::URLFetcher::GET, this)); | 573 net::URLFetcher::Create(0, doodle_url, net::URLFetcher::GET, this)); |
569 doodle_fetcher_->SetRequestContext(profile_->GetRequestContext()); | 574 doodle_fetcher_->SetRequestContext(profile_->GetRequestContext()); |
570 doodle_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SAVE_COOKIES); | 575 doodle_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SAVE_COOKIES); |
571 doodle_fetcher_->Start(); | 576 doodle_fetcher_->Start(); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
609 | 614 |
610 // Check for a new doodle. | 615 // Check for a new doodle. |
611 content::BrowserThread::PostDelayedTask( | 616 content::BrowserThread::PostDelayedTask( |
612 content::BrowserThread::UI, FROM_HERE, | 617 content::BrowserThread::UI, FROM_HERE, |
613 base::Bind(&StartPageService::FetchDoodleJson, | 618 base::Bind(&StartPageService::FetchDoodleJson, |
614 weak_factory_.GetWeakPtr()), | 619 weak_factory_.GetWeakPtr()), |
615 recheck_delay); | 620 recheck_delay); |
616 } | 621 } |
617 | 622 |
618 } // namespace app_list | 623 } // namespace app_list |
OLD | NEW |