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

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

Issue 31008: Coalesce more hardcoded schemes to using predefined constants. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 10 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
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/net/url_fixer_upper.h" 11 #include "chrome/browser/net/url_fixer_upper.h"
12 #include "chrome/browser/profile.h" 12 #include "chrome/browser/profile.h"
13 #include "chrome/browser/search_engines/template_url_model.h" 13 #include "chrome/browser/search_engines/template_url_model.h"
14 #include "chrome/common/json_value_serializer.h" 14 #include "chrome/common/json_value_serializer.h"
15 #include "chrome/common/l10n_util.h" 15 #include "chrome/common/l10n_util.h"
16 #include "chrome/common/pref_names.h" 16 #include "chrome/common/pref_names.h"
17 #include "chrome/common/pref_service.h" 17 #include "chrome/common/pref_service.h"
18 #include "chrome/common/url_constants.h"
18 #include "googleurl/src/url_util.h" 19 #include "googleurl/src/url_util.h"
19 #include "grit/generated_resources.h" 20 #include "grit/generated_resources.h"
20 #include "net/base/escape.h" 21 #include "net/base/escape.h"
21 #include "net/http/http_response_headers.h" 22 #include "net/http/http_response_headers.h"
22 #include "net/url_request/url_request_status.h" 23 #include "net/url_request/url_request_status.h"
23 24
24 using base::Time; 25 using base::Time;
25 using base::TimeDelta; 26 using base::TimeDelta;
26 27
27 const int SearchProvider::kQueryDelayMs = 200; 28 const int SearchProvider::kQueryDelayMs = 200;
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 // TODO(pkasting): http://b/1112879 These should perhaps be 600 // TODO(pkasting): http://b/1112879 These should perhaps be
600 // inline-autocompletable? 601 // inline-autocompletable?
601 602
602 return match; 603 return match;
603 } 604 }
604 605
605 // TODO(kochi): This is duplicate from HistoryURLProvider. 606 // TODO(kochi): This is duplicate from HistoryURLProvider.
606 // static 607 // static
607 size_t SearchProvider::TrimHttpPrefix(std::wstring* url) { 608 size_t SearchProvider::TrimHttpPrefix(std::wstring* url) {
608 url_parse::Component scheme; 609 url_parse::Component scheme;
609 if (!url_util::FindAndCompareScheme(WideToUTF8(*url), "http", &scheme)) 610 if (!url_util::FindAndCompareScheme(WideToUTF8(*url), chrome::kHttpScheme,
611 &scheme))
610 return 0; // Not "http". 612 return 0; // Not "http".
611 613
612 // Erase scheme plus up to two slashes. 614 // Erase scheme plus up to two slashes.
613 size_t prefix_len = scheme.end() + 1; // "http:" 615 size_t prefix_len = scheme.end() + 1; // "http:"
614 const size_t after_slashes = std::min(url->length(), 616 const size_t after_slashes = std::min(url->length(),
615 static_cast<size_t>(scheme.end() + 3)); 617 static_cast<size_t>(scheme.end() + 3));
616 while ((prefix_len < after_slashes) && ((*url)[prefix_len] == L'/')) 618 while ((prefix_len < after_slashes) && ((*url)[prefix_len] == L'/'))
617 ++prefix_len; 619 ++prefix_len;
618 if (prefix_len == url->length()) 620 if (prefix_len == url->length())
619 url->clear(); 621 url->clear();
620 else 622 else
621 url->erase(url->begin(), url->begin() + prefix_len); 623 url->erase(url->begin(), url->begin() + prefix_len);
622 return prefix_len; 624 return prefix_len;
623 } 625 }
OLDNEW
« no previous file with comments | « chrome/browser/autocomplete/history_url_provider.cc ('k') | chrome/browser/back_forward_menu_model_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698