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

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

Issue 3012001: Move implementation from header to source. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: blank line Created 10 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) 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/autocomplete/autocomplete.h" 5 #include "chrome/browser/autocomplete/autocomplete.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "app/l10n_util.h" 9 #include "app/l10n_util.h"
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 18 matching lines...) Expand all
29 #include "grit/generated_resources.h" 29 #include "grit/generated_resources.h"
30 #include "grit/theme_resources.h" 30 #include "grit/theme_resources.h"
31 #include "net/base/net_util.h" 31 #include "net/base/net_util.h"
32 #include "net/base/registry_controlled_domain.h" 32 #include "net/base/registry_controlled_domain.h"
33 #include "net/url_request/url_request.h" 33 #include "net/url_request/url_request.h"
34 34
35 using base::TimeDelta; 35 using base::TimeDelta;
36 36
37 // AutocompleteInput ---------------------------------------------------------- 37 // AutocompleteInput ----------------------------------------------------------
38 38
39 AutocompleteInput::AutocompleteInput()
40 : type_(INVALID),
41 prevent_inline_autocomplete_(false),
42 prefer_keyword_(false),
43 synchronous_only_(false) {
44 }
45
39 AutocompleteInput::AutocompleteInput(const std::wstring& text, 46 AutocompleteInput::AutocompleteInput(const std::wstring& text,
40 const std::wstring& desired_tld, 47 const std::wstring& desired_tld,
41 bool prevent_inline_autocomplete, 48 bool prevent_inline_autocomplete,
42 bool prefer_keyword, 49 bool prefer_keyword,
43 bool synchronous_only) 50 bool synchronous_only)
44 : desired_tld_(desired_tld), 51 : desired_tld_(desired_tld),
45 prevent_inline_autocomplete_(prevent_inline_autocomplete), 52 prevent_inline_autocomplete_(prevent_inline_autocomplete),
46 prefer_keyword_(prefer_keyword), 53 prefer_keyword_(prefer_keyword),
47 synchronous_only_(synchronous_only) { 54 synchronous_only_(synchronous_only) {
48 // Trim whitespace from edges of input; don't inline autocomplete if there 55 // Trim whitespace from edges of input; don't inline autocomplete if there
(...skipping 12 matching lines...) Expand all
61 if (canonicalized_url.is_valid() && 68 if (canonicalized_url.is_valid() &&
62 (!canonicalized_url.IsStandard() || canonicalized_url.SchemeIsFile() || 69 (!canonicalized_url.IsStandard() || canonicalized_url.SchemeIsFile() ||
63 !canonicalized_url.host().empty())) 70 !canonicalized_url.host().empty()))
64 canonicalized_url_ = canonicalized_url; 71 canonicalized_url_ = canonicalized_url;
65 } 72 }
66 73
67 if (type_ == FORCED_QUERY && text_[0] == L'?') 74 if (type_ == FORCED_QUERY && text_[0] == L'?')
68 text_.erase(0, 1); 75 text_.erase(0, 1);
69 } 76 }
70 77
78 AutocompleteInput::~AutocompleteInput() {
79 }
80
71 // static 81 // static
72 std::string AutocompleteInput::TypeToString(Type type) { 82 std::string AutocompleteInput::TypeToString(Type type) {
73 switch (type) { 83 switch (type) {
74 case INVALID: return "invalid"; 84 case INVALID: return "invalid";
75 case UNKNOWN: return "unknown"; 85 case UNKNOWN: return "unknown";
76 case REQUESTED_URL: return "requested-url"; 86 case REQUESTED_URL: return "requested-url";
77 case URL: return "url"; 87 case URL: return "url";
78 case QUERY: return "query"; 88 case QUERY: return "query";
79 case FORCED_QUERY: return "forced-query"; 89 case FORCED_QUERY: return "forced-query";
80 90
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 relevance(relevance), 410 relevance(relevance),
401 deletable(deletable), 411 deletable(deletable),
402 inline_autocomplete_offset(std::wstring::npos), 412 inline_autocomplete_offset(std::wstring::npos),
403 transition(PageTransition::TYPED), 413 transition(PageTransition::TYPED),
404 is_history_what_you_typed_match(false), 414 is_history_what_you_typed_match(false),
405 type(type), 415 type(type),
406 template_url(NULL), 416 template_url(NULL),
407 starred(false) { 417 starred(false) {
408 } 418 }
409 419
420 AutocompleteMatch::~AutocompleteMatch() {
421 }
422
410 // static 423 // static
411 std::string AutocompleteMatch::TypeToString(Type type) { 424 std::string AutocompleteMatch::TypeToString(Type type) {
412 const char* strings[NUM_TYPES] = { 425 const char* strings[NUM_TYPES] = {
413 "url-what-you-typed", 426 "url-what-you-typed",
414 "history-url", 427 "history-url",
415 "history-title", 428 "history-title",
416 "history-body", 429 "history-body",
417 "history-keyword", 430 "history-keyword",
418 "navsuggest", 431 "navsuggest",
419 "search-what-you-typed", 432 "search-what-you-typed",
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 last_offset = i->offset; 567 last_offset = i->offset;
555 } 568 }
556 } 569 }
557 #endif 570 #endif
558 571
559 // AutocompleteProvider ------------------------------------------------------- 572 // AutocompleteProvider -------------------------------------------------------
560 573
561 // static 574 // static
562 const size_t AutocompleteProvider::kMaxMatches = 3; 575 const size_t AutocompleteProvider::kMaxMatches = 3;
563 576
564 AutocompleteProvider::~AutocompleteProvider() { 577 AutocompleteProvider::ACProviderListener::~ACProviderListener() {
565 Stop(); 578 }
579
580 AutocompleteProvider::AutocompleteProvider(ACProviderListener* listener,
581 Profile* profile,
582 const char* name)
583 : profile_(profile),
584 listener_(listener),
585 done_(true),
586 name_(name) {
566 } 587 }
567 588
568 void AutocompleteProvider::SetProfile(Profile* profile) { 589 void AutocompleteProvider::SetProfile(Profile* profile) {
569 DCHECK(profile); 590 DCHECK(profile);
570 DCHECK(done_); // The controller should have already stopped us. 591 DCHECK(done_); // The controller should have already stopped us.
571 profile_ = profile; 592 profile_ = profile;
572 } 593 }
573 594
595 void AutocompleteProvider::Stop() {
596 done_ = true;
597 }
598
599 void AutocompleteProvider::DeleteMatch(const AutocompleteMatch& match) {
600 }
601
602 AutocompleteProvider::~AutocompleteProvider() {
603 Stop();
604 }
605
574 // static 606 // static
575 bool AutocompleteProvider::HasHTTPScheme(const std::wstring& input) { 607 bool AutocompleteProvider::HasHTTPScheme(const std::wstring& input) {
576 std::string utf8_input(WideToUTF8(input)); 608 std::string utf8_input(WideToUTF8(input));
577 url_parse::Component scheme; 609 url_parse::Component scheme;
578 if (url_util::FindAndCompareScheme(utf8_input, chrome::kViewSourceScheme, 610 if (url_util::FindAndCompareScheme(utf8_input, chrome::kViewSourceScheme,
579 &scheme)) 611 &scheme))
580 utf8_input.erase(0, scheme.end() + 1); 612 utf8_input.erase(0, scheme.end() + 1);
581 return url_util::FindAndCompareScheme(utf8_input, chrome::kHttpScheme, NULL); 613 return url_util::FindAndCompareScheme(utf8_input, chrome::kHttpScheme, NULL);
582 } 614 }
583 615
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after
1022 void AutocompleteController::CheckIfDone() { 1054 void AutocompleteController::CheckIfDone() {
1023 for (ACProviders::const_iterator i(providers_.begin()); i != providers_.end(); 1055 for (ACProviders::const_iterator i(providers_.begin()); i != providers_.end();
1024 ++i) { 1056 ++i) {
1025 if (!(*i)->done()) { 1057 if (!(*i)->done()) {
1026 done_ = false; 1058 done_ = false;
1027 return; 1059 return;
1028 } 1060 }
1029 } 1061 }
1030 done_ = true; 1062 done_ = true;
1031 } 1063 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698