OLD | NEW |
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/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/i18n/case_conversion.h" | 8 #include "base/i18n/case_conversion.h" |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
558 loader_->OnActiveTabModeChanged(new_mode.is_ntp()); | 558 loader_->OnActiveTabModeChanged(new_mode.is_ntp()); |
559 // On navigation away from the NTP, hide custom content. However keep | 559 // On navigation away from the NTP, hide custom content. However keep |
560 // the preview shown if searching, since it will soon show a suggestions | 560 // the preview shown if searching, since it will soon show a suggestions |
561 // dropdown and hiding it would cause flicker. | 561 // dropdown and hiding it would cause flicker. |
562 if (new_mode.is_default() && | 562 if (new_mode.is_default() && |
563 model_.preview_state() == InstantModel::CUSTOM_NTP_CONTENT) | 563 model_.preview_state() == InstantModel::CUSTOM_NTP_CONTENT) |
564 Hide(); | 564 Hide(); |
565 } | 565 } |
566 } | 566 } |
567 | 567 |
| 568 void InstantController::OnThemeChanged(const ThemeBackgroundInfo& theme_info) { |
| 569 if (loader_.get()) |
| 570 loader_->SendThemeBackgroundInfo(theme_info); |
| 571 } |
| 572 |
| 573 void InstantController::OnThemeAreaHeightChanged(int height) { |
| 574 if (loader_.get()) |
| 575 loader_->SendThemeAreaHeight(height); |
| 576 } |
| 577 |
568 bool InstantController::commit_on_pointer_release() const { | 578 bool InstantController::commit_on_pointer_release() const { |
569 return GetPreviewContents() && loader_->IsPointerDownFromActivate(); | 579 return GetPreviewContents() && loader_->IsPointerDownFromActivate(); |
570 } | 580 } |
571 | 581 |
572 void InstantController::SetSuggestions( | 582 void InstantController::SetSuggestions( |
573 InstantLoader* loader, | 583 InstantLoader* loader, |
574 const std::vector<InstantSuggestion>& suggestions) { | 584 const std::vector<InstantSuggestion>& suggestions) { |
575 if (loader_ != loader || model_.preview_state() == InstantModel::NOT_READY) | 585 if (loader_ != loader || model_.preview_state() == InstantModel::NOT_READY) |
576 return; | 586 return; |
577 | 587 |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
689 | 699 |
690 void InstantController::ResetLoader(const std::string& instant_url, | 700 void InstantController::ResetLoader(const std::string& instant_url, |
691 const TabContents* active_tab) { | 701 const TabContents* active_tab) { |
692 if (GetPreviewContents() && loader_->instant_url() != instant_url) | 702 if (GetPreviewContents() && loader_->instant_url() != instant_url) |
693 DeleteLoader(); | 703 DeleteLoader(); |
694 | 704 |
695 if (!GetPreviewContents()) { | 705 if (!GetPreviewContents()) { |
696 loader_.reset(new InstantLoader(this, instant_url, active_tab)); | 706 loader_.reset(new InstantLoader(this, instant_url, active_tab)); |
697 loader_->Init(); | 707 loader_->Init(); |
698 | 708 |
699 // Ensure the searchbox API has the correct focus state and context. | 709 // Ensure the searchbox API has the correct focus state, context and theme- |
| 710 // related info. |
700 if (is_omnibox_focused_) | 711 if (is_omnibox_focused_) |
701 loader_->OnAutocompleteGotFocus(); | 712 loader_->OnAutocompleteGotFocus(); |
702 else | 713 else |
703 loader_->OnAutocompleteLostFocus(); | 714 loader_->OnAutocompleteLostFocus(); |
704 loader_->OnActiveTabModeChanged(active_tab_mode_.is_ntp()); | 715 loader_->OnActiveTabModeChanged(active_tab_mode_.is_ntp()); |
| 716 browser_->UpdateThemeRelatedInfoForPreview(); |
705 | 717 |
706 // Reset the loader timer. | 718 // Reset the loader timer. |
707 stale_loader_timer_.Stop(); | 719 stale_loader_timer_.Stop(); |
708 stale_loader_timer_.Start( | 720 stale_loader_timer_.Start( |
709 FROM_HERE, | 721 FROM_HERE, |
710 base::TimeDelta::FromMilliseconds(kStaleLoaderTimeoutMS), this, | 722 base::TimeDelta::FromMilliseconds(kStaleLoaderTimeoutMS), this, |
711 &InstantController::OnStaleLoader); | 723 &InstantController::OnStaleLoader); |
712 } | 724 } |
713 } | 725 } |
714 | 726 |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
862 } | 874 } |
863 | 875 |
864 std::map<std::string, int>::const_iterator iter = | 876 std::map<std::string, int>::const_iterator iter = |
865 blacklisted_urls_.find(*instant_url); | 877 blacklisted_urls_.find(*instant_url); |
866 if (iter != blacklisted_urls_.end() && | 878 if (iter != blacklisted_urls_.end() && |
867 iter->second > kMaxInstantSupportFailures) | 879 iter->second > kMaxInstantSupportFailures) |
868 return false; | 880 return false; |
869 | 881 |
870 return true; | 882 return true; |
871 } | 883 } |
OLD | NEW |