 Chromium Code Reviews
 Chromium Code Reviews Issue 11421079:
  Persist the Instant API to committed search result pages.  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src
    
  
    Issue 11421079:
  Persist the Instant API to committed search result pages.  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src| Index: chrome/browser/instant/instant_tab.cc | 
| diff --git a/chrome/browser/instant/instant_tab.cc b/chrome/browser/instant/instant_tab.cc | 
| new file mode 100644 | 
| index 0000000000000000000000000000000000000000..e042f1a4cf405433711fc64301a983deed70f3c7 | 
| --- /dev/null | 
| +++ b/chrome/browser/instant/instant_tab.cc | 
| @@ -0,0 +1,63 @@ | 
| +// Copyright 2012 The Chromium Authors. All rights reserved. | 
| +// Use of this source code is governed by a BSD-style license that can be | 
| +// found in the LICENSE file. | 
| + | 
| +#include "chrome/browser/instant/instant_tab.h" | 
| + | 
| +#include "chrome/browser/instant/instant_controller.h" | 
| + | 
| +InstantTab::InstantTab(InstantController* controller, | 
| + content::WebContents* contents) | 
| + : client_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), | 
| + controller_(controller), | 
| + contents_(contents), | 
| + supports_instant_(false) { | 
| + client_.SetContents(contents); | 
| + client_.DetermineIfPageSupportsInstant(); | 
| 
Jered
2012/11/29 19:57:05
I am uneasy about Observe() and sending an IPC in
 
sreeram
2012/12/04 08:10:52
Done.
 | 
| +} | 
| + | 
| +InstantTab::~InstantTab() { | 
| +} | 
| + | 
| +void InstantTab::Update(const string16& text, bool verbatim) { | 
| + client_.Update(text, verbatim); | 
| +} | 
| + | 
| +void InstantTab::Submit(const string16& text) { | 
| + client_.Submit(text); | 
| +} | 
| + | 
| +void InstantTab::SendAutocompleteResults( | 
| + const std::vector<InstantAutocompleteResult>& results) { | 
| + client_.SendAutocompleteResults(results); | 
| +} | 
| + | 
| +void InstantTab::UpOrDownKeyPressed(int count) { | 
| + client_.UpOrDownKeyPressed(count); | 
| +} | 
| + | 
| +void InstantTab::SetSuggestions( | 
| + const std::vector<InstantSuggestion>& suggestions) { | 
| + InstantSupportDetermined(true); | 
| + controller_->SetSuggestions(contents_, suggestions); | 
| +} | 
| + | 
| +void InstantTab::InstantSupportDetermined(bool supports_instant) { | 
| + // If we had already determined that the page supports Instant, nothing to do. | 
| + if (supports_instant_) | 
| + return; | 
| + | 
| + supports_instant_ = supports_instant; | 
| + | 
| + // If the page doesn't support Instant, stop communicating with it. | 
| + if (!supports_instant) | 
| + client_.SetContents(NULL); | 
| + | 
| + controller_->InstantSupportDetermined(contents_, supports_instant); | 
| +} | 
| + | 
| +void InstantTab::ShowInstantPreview(InstantShownReason /* reason */, | 
| + int /* height */, | 
| + InstantSizeUnits /* units */) { | 
| + // The page is a committed tab (i.e., always showing), so nothing to do. | 
| +} |