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

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

Issue 5787008: Makes instant not suggest string that look like urls. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge and convert active to displayable Created 10 years 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
« no previous file with comments | « chrome/browser/instant/instant_loader.h ('k') | chrome/test/data/instant/suggest_google.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 <utility> 8 #include <utility>
9 9
10 #include "app/l10n_util.h" 10 #include "app/l10n_util.h"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/string_number_conversions.h" 12 #include "base/string_number_conversions.h"
13 #include "base/timer.h" 13 #include "base/timer.h"
14 #include "base/utf_string_conversions.h" 14 #include "base/utf_string_conversions.h"
15 #include "base/values.h" 15 #include "base/values.h"
16 #include "chrome/browser/autocomplete/autocomplete.h"
16 #include "chrome/browser/favicon_service.h" 17 #include "chrome/browser/favicon_service.h"
17 #include "chrome/browser/history/history_marshaling.h" 18 #include "chrome/browser/history/history_marshaling.h"
18 #include "chrome/browser/instant/instant_loader_delegate.h" 19 #include "chrome/browser/instant/instant_loader_delegate.h"
19 #include "chrome/browser/profiles/profile.h" 20 #include "chrome/browser/profiles/profile.h"
20 #include "chrome/browser/renderer_host/render_view_host.h" 21 #include "chrome/browser/renderer_host/render_view_host.h"
21 #include "chrome/browser/renderer_host/render_widget_host.h" 22 #include "chrome/browser/renderer_host/render_widget_host.h"
22 #include "chrome/browser/renderer_host/render_widget_host_view.h" 23 #include "chrome/browser/renderer_host/render_widget_host_view.h"
23 #include "chrome/browser/search_engines/template_url.h" 24 #include "chrome/browser/search_engines/template_url.h"
24 #include "chrome/browser/tab_contents/navigation_controller.h" 25 #include "chrome/browser/tab_contents/navigation_controller.h"
25 #include "chrome/browser/tab_contents/navigation_entry.h" 26 #include "chrome/browser/tab_contents/navigation_entry.h"
(...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after
655 ShowPreview(); 656 ShowPreview();
656 657
657 if (complete_suggested_text == complete_suggested_text_) 658 if (complete_suggested_text == complete_suggested_text_)
658 return; 659 return;
659 660
660 if (verbatim_) { 661 if (verbatim_) {
661 // Don't show suggest results for verbatim queries. 662 // Don't show suggest results for verbatim queries.
662 return; 663 return;
663 } 664 }
664 665
666 AutocompleteInput::Type type =
667 AutocompleteInput::Parse(UTF16ToWide(complete_suggested_text),
668 std::wstring(), NULL, NULL);
669 if (type == AutocompleteInput::URL) {
670 // Ignore suggestions that look like urls. Otherwise the omnibox ends up
671 // showing what looks like a url but the page shows search results.
672 return;
673 }
674
665 string16 user_text_lower = l10n_util::ToLower(user_text_); 675 string16 user_text_lower = l10n_util::ToLower(user_text_);
666 string16 complete_suggested_text_lower = l10n_util::ToLower( 676 string16 complete_suggested_text_lower = l10n_util::ToLower(
667 complete_suggested_text); 677 complete_suggested_text);
668 last_suggestion_.clear(); 678 last_suggestion_.clear();
669 if (user_text_lower.compare(0, user_text_lower.size(), 679 if (user_text_lower.compare(0, user_text_lower.size(),
670 complete_suggested_text_lower, 680 complete_suggested_text_lower,
671 0, user_text_lower.size())) { 681 0, user_text_lower.size())) {
672 // The user text no longer contains the suggested text, ignore it. 682 // The user text no longer contains the suggested text, ignore it.
673 complete_suggested_text_.clear(); 683 complete_suggested_text_.clear();
674 delegate_->SetSuggestedTextFor(this, string16()); 684 delegate_->SetSuggestedTextFor(this, string16());
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
806 Source<NavigationController>(&preview_contents_->controller())); 816 Source<NavigationController>(&preview_contents_->controller()));
807 #endif 817 #endif
808 818
809 registrar_.Add( 819 registrar_.Add(
810 this, 820 this,
811 NotificationType::NAV_ENTRY_COMMITTED, 821 NotificationType::NAV_ENTRY_COMMITTED,
812 Source<NavigationController>(&preview_contents_->controller())); 822 Source<NavigationController>(&preview_contents_->controller()));
813 823
814 preview_contents_->tab_contents()->ShowContents(); 824 preview_contents_->tab_contents()->ShowContents();
815 } 825 }
OLDNEW
« no previous file with comments | « chrome/browser/instant/instant_loader.h ('k') | chrome/test/data/instant/suggest_google.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698