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

Side by Side Diff: chrome/browser/autocomplete/search_provider.cc

Issue 16503: Fix issue 5806. If the suggest server returns a NAVIGATION... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 11 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/autocomplete/search_provider.h" 5 #include "chrome/browser/autocomplete/search_provider.h"
6 6
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "chrome/browser/browser_process.h" 9 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/google_util.h" 10 #include "chrome/browser/google_util.h"
11 #include "chrome/browser/profile.h" 11 #include "chrome/browser/profile.h"
12 #include "chrome/browser/template_url_model.h" 12 #include "chrome/browser/template_url_model.h"
13 #include "chrome/browser/url_fixer_upper.h"
13 #include "chrome/common/json_value_serializer.h" 14 #include "chrome/common/json_value_serializer.h"
14 #include "chrome/common/l10n_util.h" 15 #include "chrome/common/l10n_util.h"
15 #include "chrome/common/pref_names.h" 16 #include "chrome/common/pref_names.h"
16 #include "chrome/common/pref_service.h" 17 #include "chrome/common/pref_service.h"
17 #include "googleurl/src/url_util.h" 18 #include "googleurl/src/url_util.h"
18 #include "net/base/escape.h" 19 #include "net/base/escape.h"
19 20
20 #include "generated_resources.h" 21 #include "generated_resources.h"
21 22
22 using base::Time; 23 using base::Time;
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 Value* type_val; 315 Value* type_val;
315 std::wstring type_str; 316 std::wstring type_str;
316 if (type_list && type_list->Get(i, &type_val) && 317 if (type_list && type_list->Get(i, &type_val) &&
317 type_val->GetAsString(&type_str) && (type_str == L"NAVIGATION")) { 318 type_val->GetAsString(&type_str) && (type_str == L"NAVIGATION")) {
318 Value* site_val; 319 Value* site_val;
319 std::wstring site_name; 320 std::wstring site_name;
320 if (navigation_results_.size() < max_matches() && 321 if (navigation_results_.size() < max_matches() &&
321 description_list && description_list->Get(i, &site_val) && 322 description_list && description_list->Get(i, &site_val) &&
322 site_val->IsType(Value::TYPE_STRING) && 323 site_val->IsType(Value::TYPE_STRING) &&
323 site_val->GetAsString(&site_name)) { 324 site_val->GetAsString(&site_name)) {
324 navigation_results_.push_back(NavigationResult(GURL(suggestion_str), 325 // Navigation links might not be valid URLs. For example, the Google
325 site_name)); 326 // suggest server returns navigation links without a scheme if the
327 // scheme is http. Fix the URL, and verify that it's valid before
328 // adding it to the list.
329 GURL result_url = GURL(URLFixerUpper::FixupURL(suggestion_str, L""));
330 if (result_url.is_valid()) {
331 navigation_results_.push_back(NavigationResult(result_url,
332 site_name));
333 }
326 } 334 }
327 } else { 335 } else {
328 // TODO(kochi): Currently we treat a calculator result as a query, but it 336 // TODO(kochi): Currently we treat a calculator result as a query, but it
329 // is better to have better presentation for caluculator results. 337 // is better to have better presentation for caluculator results.
330 if (suggest_results_.size() < max_matches()) 338 if (suggest_results_.size() < max_matches())
331 suggest_results_.push_back(suggestion_str); 339 suggest_results_.push_back(suggestion_str);
332 } 340 }
333 } 341 }
334 342
335 return true; 343 return true;
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
605 const size_t after_slashes = std::min(url->length(), 613 const size_t after_slashes = std::min(url->length(),
606 static_cast<size_t>(scheme.end() + 3)); 614 static_cast<size_t>(scheme.end() + 3));
607 while ((prefix_len < after_slashes) && ((*url)[prefix_len] == L'/')) 615 while ((prefix_len < after_slashes) && ((*url)[prefix_len] == L'/'))
608 ++prefix_len; 616 ++prefix_len;
609 if (prefix_len == url->length()) 617 if (prefix_len == url->length())
610 url->clear(); 618 url->clear();
611 else 619 else
612 url->erase(url->begin(), url->begin() + prefix_len); 620 url->erase(url->begin(), url->begin() + prefix_len);
613 return prefix_len; 621 return prefix_len;
614 } 622 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698