OLD | NEW |
---|---|
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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/instant/instant_controller.h" | 5 #include "chrome/browser/instant/instant_controller.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
519 model_.mode().is_search_suggestions()) | 519 model_.mode().is_search_suggestions()) |
520 Hide(false); | 520 Hide(false); |
521 } | 521 } |
522 | 522 |
523 void InstantController::SetInstantEnabled(bool instant_enabled) { | 523 void InstantController::SetInstantEnabled(bool instant_enabled) { |
524 instant_enabled_ = instant_enabled; | 524 instant_enabled_ = instant_enabled; |
525 if (!extended_enabled_ && !instant_enabled_) | 525 if (!extended_enabled_ && !instant_enabled_) |
526 DeleteLoader(); | 526 DeleteLoader(); |
527 } | 527 } |
528 | 528 |
529 void InstantController::ThemeChanged(const ThemeBackgroundInfo& theme_info) { | |
530 if (GetPreviewContents()) | |
531 loader_->SendThemeBackgroundInfo(theme_info); | |
532 } | |
533 | |
534 void InstantController::ThemeAreaHeightChanged(int height) { | |
535 if (GetPreviewContents()) | |
536 loader_->SendThemeAreaHeight(height); | |
537 } | |
538 | |
529 void InstantController::SetSuggestions( | 539 void InstantController::SetSuggestions( |
530 InstantLoader* loader, | 540 InstantLoader* loader, |
531 const std::vector<InstantSuggestion>& suggestions) { | 541 const std::vector<InstantSuggestion>& suggestions) { |
532 DVLOG(1) << "SetSuggestions"; | 542 DVLOG(1) << "SetSuggestions"; |
533 if (loader_ != loader || !search_mode_.is_search_suggestions()) | 543 if (loader_ != loader || !search_mode_.is_search_suggestions()) |
534 return; | 544 return; |
535 | 545 |
536 InstantSuggestion suggestion; | 546 InstantSuggestion suggestion; |
537 if (!suggestions.empty()) | 547 if (!suggestions.empty()) |
538 suggestion = suggestions[0]; | 548 suggestion = suggestions[0]; |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
638 if (!GetInstantURL(template_url, &instant_url)) | 648 if (!GetInstantURL(template_url, &instant_url)) |
639 return false; | 649 return false; |
640 | 650 |
641 if (GetPreviewContents() && loader_->instant_url() != instant_url) | 651 if (GetPreviewContents() && loader_->instant_url() != instant_url) |
642 DeleteLoader(); | 652 DeleteLoader(); |
643 | 653 |
644 if (!GetPreviewContents()) { | 654 if (!GetPreviewContents()) { |
645 loader_.reset(new InstantLoader(this, instant_url, active_tab)); | 655 loader_.reset(new InstantLoader(this, instant_url, active_tab)); |
646 loader_->Init(); | 656 loader_->Init(); |
647 | 657 |
648 // Ensure the searchbox API has the correct context. | 658 // Ensure the searchbox API has the correct context and theme-related info. |
649 if (extended_enabled_) | 659 if (extended_enabled_) |
650 loader_->OnActiveTabModeChanged(search_mode_.is_ntp()); | 660 loader_->OnActiveTabModeChanged(search_mode_.is_ntp()); |
661 browser_->UpdateThemeInfoForPreview(); | |
sreeram
2012/11/20 18:39:00
Likewise, swap these two lines as well.
kuan
2012/11/20 18:50:48
Done.
| |
651 | 662 |
652 // Reset the loader timer. | 663 // Reset the loader timer. |
653 stale_loader_timer_.Start( | 664 stale_loader_timer_.Start( |
654 FROM_HERE, | 665 FROM_HERE, |
655 base::TimeDelta::FromMilliseconds(kStaleLoaderTimeoutMS), this, | 666 base::TimeDelta::FromMilliseconds(kStaleLoaderTimeoutMS), this, |
656 &InstantController::OnStaleLoader); | 667 &InstantController::OnStaleLoader); |
657 } | 668 } |
658 | 669 |
659 return true; | 670 return true; |
660 } | 671 } |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
827 } | 838 } |
828 | 839 |
829 std::map<std::string, int>::const_iterator iter = | 840 std::map<std::string, int>::const_iterator iter = |
830 blacklisted_urls_.find(*instant_url); | 841 blacklisted_urls_.find(*instant_url); |
831 if (iter != blacklisted_urls_.end() && | 842 if (iter != blacklisted_urls_.end() && |
832 iter->second > kMaxInstantSupportFailures) | 843 iter->second > kMaxInstantSupportFailures) |
833 return false; | 844 return false; |
834 | 845 |
835 return true; | 846 return true; |
836 } | 847 } |
OLD | NEW |