| Index: chrome/browser/ui/search/instant_page.cc
|
| diff --git a/chrome/browser/ui/search/instant_page.cc b/chrome/browser/ui/search/instant_page.cc
|
| index 8568d2e6298bcf02a1ae43fd57b2e04d30197168..d886566d46a32a30da7eb9306199b3814f459891 100644
|
| --- a/chrome/browser/ui/search/instant_page.cc
|
| +++ b/chrome/browser/ui/search/instant_page.cc
|
| @@ -5,6 +5,7 @@
|
| #include "chrome/browser/ui/search/instant_page.h"
|
|
|
| #include "base/strings/utf_string_conversions.h"
|
| +#include "chrome/browser/ui/search/search_tab_helper.h"
|
| #include "chrome/common/render_messages.h"
|
| #include "chrome/common/url_constants.h"
|
| #include "content/public/browser/navigation_controller.h"
|
| @@ -19,6 +20,8 @@ InstantPage::Delegate::~Delegate() {
|
| }
|
|
|
| InstantPage::~InstantPage() {
|
| + if (contents())
|
| + GetSearchModel()->RemoveObserver(this);
|
| }
|
|
|
| bool InstantPage::supports_instant() const {
|
| @@ -138,8 +141,17 @@ InstantPage::InstantPage(Delegate* delegate, const std::string& instant_url)
|
| instant_support_determined_(false) {
|
| }
|
|
|
| -void InstantPage::SetContents(content::WebContents* contents) {
|
| - Observe(contents);
|
| +void InstantPage::SetContents(content::WebContents* web_contents) {
|
| + if (contents())
|
| + GetSearchModel()->RemoveObserver(this);
|
| +
|
| + Observe(web_contents);
|
| +
|
| + if (!web_contents)
|
| + return;
|
| +
|
| + SearchModel* model = GetSearchModel();
|
| + model->AddObserver(this);
|
| }
|
|
|
| bool InstantPage::ShouldProcessRenderViewCreated() {
|
| @@ -158,6 +170,10 @@ bool InstantPage::ShouldProcessSetSuggestions() {
|
| return false;
|
| }
|
|
|
| +bool InstantPage::ShouldProcessSetVoiceSearchSupported() {
|
| + return false;
|
| +}
|
| +
|
| bool InstantPage::ShouldProcessShowInstantOverlay() {
|
| return false;
|
| }
|
| @@ -254,6 +270,19 @@ void InstantPage::DidFailProvisionalLoad(
|
| delegate_->InstantPageLoadFailed(contents());
|
| }
|
|
|
| +void InstantPage::ModelChanged(const SearchModel::State& old_state,
|
| + const SearchModel::State& new_state) {
|
| + if (ShouldProcessSetVoiceSearchSupported() &&
|
| + old_state.voice_search_supported != new_state.voice_search_supported)
|
| + delegate_->SetVoiceSearchSupported(
|
| + contents(), new_state.voice_search_supported);
|
| +}
|
| +
|
| +SearchModel* InstantPage::GetSearchModel() {
|
| + return contents() ?
|
| + SearchTabHelper::FromWebContents(contents())->model() : NULL;
|
| +}
|
| +
|
| void InstantPage::OnSetSuggestions(
|
| int page_id,
|
| const std::vector<InstantSuggestion>& suggestions) {
|
|
|