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

Side by Side Diff: chrome/browser/instant/instant_controller.cc

Issue 11413018: alternate ntp: implement searchbox api for instant overlay to adopt themes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: addressed scott's comments Created 8 years, 1 month 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 | Annotate | Revision Log
OLDNEW
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 543 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 loader_->OnActiveTabModeChanged(new_mode.is_ntp()); 554 loader_->OnActiveTabModeChanged(new_mode.is_ntp());
555 // On navigation away from the NTP, hide custom content. However keep 555 // On navigation away from the NTP, hide custom content. However keep
556 // the preview shown if searching, since it will soon show a suggestions 556 // the preview shown if searching, since it will soon show a suggestions
557 // dropdown and hiding it would cause flicker. 557 // dropdown and hiding it would cause flicker.
558 if (new_mode.is_default() && 558 if (new_mode.is_default() &&
559 model_.preview_state() == InstantModel::CUSTOM_NTP_CONTENT) 559 model_.preview_state() == InstantModel::CUSTOM_NTP_CONTENT)
560 Hide(); 560 Hide();
561 } 561 }
562 } 562 }
563 563
564 void InstantController::OnThemeChanged(const ThemeBackgroundInfo& theme_info) {
565 if (loader_.get())
sreeram 2012/11/19 18:12:02 Use "if (GetPreviewContents())" instead of "if (lo
kuan 2012/11/19 22:06:07 Done.
566 loader_->SendThemeBackgroundInfo(theme_info);
567 }
568
569 void InstantController::OnThemeAreaHeightChanged(int height) {
570 if (loader_.get())
571 loader_->SendThemeAreaHeight(height);
572 }
573
564 bool InstantController::commit_on_pointer_release() const { 574 bool InstantController::commit_on_pointer_release() const {
565 return GetPreviewContents() && loader_->IsPointerDownFromActivate(); 575 return GetPreviewContents() && loader_->IsPointerDownFromActivate();
566 } 576 }
567 577
568 void InstantController::SetSuggestions( 578 void InstantController::SetSuggestions(
569 InstantLoader* loader, 579 InstantLoader* loader,
570 const std::vector<InstantSuggestion>& suggestions) { 580 const std::vector<InstantSuggestion>& suggestions) {
571 if (loader_ != loader || model_.preview_state() == InstantModel::NOT_READY) 581 if (loader_ != loader || model_.preview_state() == InstantModel::NOT_READY)
572 return; 582 return;
573 583
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
685 695
686 void InstantController::ResetLoader(const std::string& instant_url, 696 void InstantController::ResetLoader(const std::string& instant_url,
687 const TabContents* active_tab) { 697 const TabContents* active_tab) {
688 if (GetPreviewContents() && loader_->instant_url() != instant_url) 698 if (GetPreviewContents() && loader_->instant_url() != instant_url)
689 DeleteLoader(); 699 DeleteLoader();
690 700
691 if (!GetPreviewContents()) { 701 if (!GetPreviewContents()) {
692 loader_.reset(new InstantLoader(this, instant_url, active_tab)); 702 loader_.reset(new InstantLoader(this, instant_url, active_tab));
693 loader_->Init(); 703 loader_->Init();
694 704
695 // Ensure the searchbox API has the correct context. 705 // Ensure the searchbox API has the correct context and theme-related info.
696 loader_->OnActiveTabModeChanged(active_tab_mode_.is_ntp()); 706 loader_->OnActiveTabModeChanged(active_tab_mode_.is_ntp());
707 browser_->UpdateThemeRelatedInfoForPreview();
sreeram 2012/11/19 18:12:02 Nit: "related" seems unnecessary. Just "UpdateThem
kuan 2012/11/19 22:06:07 Done.
697 708
698 // Reset the loader timer. 709 // Reset the loader timer.
699 stale_loader_timer_.Stop(); 710 stale_loader_timer_.Stop();
700 stale_loader_timer_.Start( 711 stale_loader_timer_.Start(
701 FROM_HERE, 712 FROM_HERE,
702 base::TimeDelta::FromMilliseconds(kStaleLoaderTimeoutMS), this, 713 base::TimeDelta::FromMilliseconds(kStaleLoaderTimeoutMS), this,
703 &InstantController::OnStaleLoader); 714 &InstantController::OnStaleLoader);
704 } 715 }
705 } 716 }
706 717
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
854 } 865 }
855 866
856 std::map<std::string, int>::const_iterator iter = 867 std::map<std::string, int>::const_iterator iter =
857 blacklisted_urls_.find(*instant_url); 868 blacklisted_urls_.find(*instant_url);
858 if (iter != blacklisted_urls_.end() && 869 if (iter != blacklisted_urls_.end() &&
859 iter->second > kMaxInstantSupportFailures) 870 iter->second > kMaxInstantSupportFailures)
860 return false; 871 return false;
861 872
862 return true; 873 return true;
863 } 874 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698