OLD | NEW |
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 <algorithm> | 5 #include <algorithm> |
6 | 6 |
7 #include "chrome/browser/autocomplete/autocomplete.h" | 7 #include "chrome/browser/autocomplete/autocomplete.h" |
8 | 8 |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "chrome/browser/autocomplete/history_url_provider.h" | 10 #include "chrome/browser/autocomplete/history_url_provider.h" |
11 #include "chrome/browser/autocomplete/history_contents_provider.h" | 11 #include "chrome/browser/autocomplete/history_contents_provider.h" |
12 #include "chrome/browser/autocomplete/keyword_provider.h" | 12 #include "chrome/browser/autocomplete/keyword_provider.h" |
13 #include "chrome/browser/autocomplete/search_provider.h" | 13 #include "chrome/browser/autocomplete/search_provider.h" |
14 #include "chrome/browser/bookmarks/bookmark_bar_model.h" | 14 #include "chrome/browser/bookmarks/bookmark_model.h" |
15 #include "chrome/browser/external_protocol_handler.h" | 15 #include "chrome/browser/external_protocol_handler.h" |
16 #include "chrome/browser/history_tab_ui.h" | 16 #include "chrome/browser/history_tab_ui.h" |
17 #include "chrome/browser/profile.h" | 17 #include "chrome/browser/profile.h" |
18 #include "chrome/browser/url_fixer_upper.h" | 18 #include "chrome/browser/url_fixer_upper.h" |
19 #include "chrome/common/gfx/url_elider.h" | 19 #include "chrome/common/gfx/url_elider.h" |
20 #include "chrome/common/l10n_util.h" | 20 #include "chrome/common/l10n_util.h" |
21 #include "chrome/common/pref_names.h" | 21 #include "chrome/common/pref_names.h" |
22 #include "chrome/common/pref_service.h" | 22 #include "chrome/common/pref_service.h" |
23 #include "googleurl/src/url_canon_ip.h" | 23 #include "googleurl/src/url_canon_ip.h" |
24 #include "net/base/net_util.h" | 24 #include "net/base/net_util.h" |
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages) : | 387 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages) : |
388 std::wstring()); | 388 std::wstring()); |
389 } | 389 } |
390 | 390 |
391 void AutocompleteProvider::UpdateStarredStateOfMatches() { | 391 void AutocompleteProvider::UpdateStarredStateOfMatches() { |
392 if (matches_.empty()) | 392 if (matches_.empty()) |
393 return; | 393 return; |
394 | 394 |
395 if (!profile_) | 395 if (!profile_) |
396 return; | 396 return; |
397 BookmarkBarModel* bookmark_bar_model = profile_->GetBookmarkBarModel(); | 397 BookmarkModel* bookmark_model = profile_->GetBookmarkModel(); |
398 if (!bookmark_bar_model || !bookmark_bar_model->IsLoaded()) | 398 if (!bookmark_model || !bookmark_model->IsLoaded()) |
399 return; | 399 return; |
400 | 400 |
401 for (ACMatches::iterator i = matches_.begin(); i != matches_.end(); ++i) | 401 for (ACMatches::iterator i = matches_.begin(); i != matches_.end(); ++i) |
402 i->starred = bookmark_bar_model->IsBookmarked(GURL(i->destination_url)); | 402 i->starred = bookmark_model->IsBookmarked(GURL(i->destination_url)); |
403 } | 403 } |
404 | 404 |
405 // AutocompleteResult --------------------------------------------------------- | 405 // AutocompleteResult --------------------------------------------------------- |
406 | 406 |
407 // static | 407 // static |
408 size_t AutocompleteResult::max_matches_ = 6; | 408 size_t AutocompleteResult::max_matches_ = 6; |
409 | 409 |
410 void AutocompleteResult::Selection::Clear() { | 410 void AutocompleteResult::Selection::Clear() { |
411 destination_url.clear(); | 411 destination_url.clear(); |
412 provider_affinity = NULL; | 412 provider_affinity = NULL; |
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
736 ACMatchClassification(keyword_offset + input_.text().size(), | 736 ACMatchClassification(keyword_offset + input_.text().size(), |
737 ACMatchClassification::NONE)); | 737 ACMatchClassification::NONE)); |
738 } | 738 } |
739 match.destination_url = | 739 match.destination_url = |
740 UTF8ToWide(HistoryTabUI::GetHistoryURLWithSearchText( | 740 UTF8ToWide(HistoryTabUI::GetHistoryURLWithSearchText( |
741 input_.text()).spec()); | 741 input_.text()).spec()); |
742 match.transition = PageTransition::AUTO_BOOKMARK; | 742 match.transition = PageTransition::AUTO_BOOKMARK; |
743 match.provider = history_contents_provider_; | 743 match.provider = history_contents_provider_; |
744 result->AddMatch(match); | 744 result->AddMatch(match); |
745 } | 745 } |
OLD | NEW |