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

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

Issue 10809063: Adding Javascript support for the Extended Searchbox API. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Remove test for older API, removed in this CL. Created 8 years, 5 months 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
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_loader.h" 5 #include "chrome/browser/instant/instant_loader.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 const string16& error_description, 266 const string16& error_description,
267 content::RenderViewHost* render_view_host) OVERRIDE; 267 content::RenderViewHost* render_view_host) OVERRIDE;
268 268
269 private: 269 private:
270 typedef std::vector<scoped_refptr<history::HistoryAddPageArgs> > 270 typedef std::vector<scoped_refptr<history::HistoryAddPageArgs> >
271 AddPageVector; 271 AddPageVector;
272 272
273 // Message from renderer indicating the page has suggestions. 273 // Message from renderer indicating the page has suggestions.
274 void OnSetSuggestions( 274 void OnSetSuggestions(
275 int32 page_id, 275 int32 page_id,
276 const std::vector<std::string>& suggestions, 276 const std::vector<InstantSuggestion>& suggestions);
277 InstantCompleteBehavior behavior);
278 277
279 // Messages from the renderer when we've determined whether the page supports 278 // Messages from the renderer when we've determined whether the page supports
280 // instant. 279 // instant.
281 void OnInstantSupportDetermined(int32 page_id, bool result); 280 void OnInstantSupportDetermined(int32 page_id, bool result);
282 281
283 // Commits, if applicable, on mouse is released, or a gesture ends. 282 // Commits, if applicable, on mouse is released, or a gesture ends.
284 void CommitOnPointerReleaseIfNecessary(); 283 void CommitOnPointerReleaseIfNecessary();
285 284
286 InstantLoader* loader_; 285 InstantLoader* loader_;
287 286
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 if (validated_url == loader_->url_) { 590 if (validated_url == loader_->url_) {
592 // This typically happens with downloads (which are disabled with 591 // This typically happens with downloads (which are disabled with
593 // instant active). To ensure the download happens when the user presses 592 // instant active). To ensure the download happens when the user presses
594 // enter we set needs_reload_ to true, which triggers a reload. 593 // enter we set needs_reload_ to true, which triggers a reload.
595 loader_->needs_reload_ = true; 594 loader_->needs_reload_ = true;
596 } 595 }
597 } 596 }
598 597
599 void InstantLoader::WebContentsDelegateImpl::OnSetSuggestions( 598 void InstantLoader::WebContentsDelegateImpl::OnSetSuggestions(
600 int32 page_id, 599 int32 page_id,
601 const std::vector<std::string>& suggestions, 600 const std::vector<InstantSuggestion>& suggestions) {
602 InstantCompleteBehavior behavior) {
603 TabContents* source = loader_->preview_contents(); 601 TabContents* source = loader_->preview_contents();
604 NavigationEntry* entry = 602 NavigationEntry* entry =
605 source->web_contents()->GetController().GetActiveEntry(); 603 source->web_contents()->GetController().GetActiveEntry();
606 if (!entry || page_id != entry->GetPageID()) 604 if (!entry || page_id != entry->GetPageID())
607 return; 605 return;
608 606
609 if (suggestions.empty()) 607 if (suggestions.empty())
610 loader_->SetCompleteSuggestedText(string16(), behavior); 608 loader_->SetCompleteSuggestedText(string16(), INSTANT_COMPLETE_NOW);
611 else 609 else
612 loader_->SetCompleteSuggestedText(UTF8ToUTF16(suggestions[0]), behavior); 610 loader_->SetCompleteSuggestedText(UTF8ToUTF16(suggestions[0].text),
611 suggestions[0].behavior);
613 } 612 }
614 613
615 void InstantLoader::WebContentsDelegateImpl::OnInstantSupportDetermined( 614 void InstantLoader::WebContentsDelegateImpl::OnInstantSupportDetermined(
616 int32 page_id, 615 int32 page_id,
617 bool result) { 616 bool result) {
618 WebContents* source = loader_->preview_contents()->web_contents(); 617 WebContents* source = loader_->preview_contents()->web_contents();
619 if (!source->GetController().GetActiveEntry() || 618 if (!source->GetController().GetActiveEntry() ||
620 page_id != source->GetController().GetActiveEntry()->GetPageID()) 619 page_id != source->GetController().GetActiveEntry()->GetPageID())
621 return; 620 return;
622 621
(...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after
1193 host->Send(new ChromeViewMsg_SearchBoxResize( 1192 host->Send(new ChromeViewMsg_SearchBoxResize(
1194 host->GetRoutingID(), GetOmniboxBoundsInTermsOfPreview())); 1193 host->GetRoutingID(), GetOmniboxBoundsInTermsOfPreview()));
1195 } else { 1194 } else {
1196 host->Send(new ChromeViewMsg_SearchBoxChange( 1195 host->Send(new ChromeViewMsg_SearchBoxChange(
1197 host->GetRoutingID(), user_text, verbatim, 0, 0)); 1196 host->GetRoutingID(), user_text, verbatim, 0, 0));
1198 } 1197 }
1199 1198
1200 frame_load_observer_.reset(new FrameLoadObserver( 1199 frame_load_observer_.reset(new FrameLoadObserver(
1201 this, preview_contents()->web_contents(), user_text, verbatim)); 1200 this, preview_contents()->web_contents(), user_text, verbatim));
1202 } 1201 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698