| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/ui/app_list/search/history.h" | 5 #include "chrome/browser/ui/app_list/search/history.h" |
| 6 | 6 |
| 7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "chrome/browser/ui/app_list/search/history_data.h" | 10 #include "chrome/browser/ui/app_list/search/history_data.h" |
| 11 #include "chrome/browser/ui/app_list/search/history_data_store.h" | 11 #include "chrome/browser/ui/app_list/search/history_data_store.h" |
| 12 #include "chrome/browser/ui/app_list/search/tokenized_string.h" | 12 #include "chrome/browser/ui/app_list/search/tokenized_string.h" |
| 13 #include "content/public/browser/browser_context.h" | 13 #include "content/public/browser/browser_context.h" |
| 14 | 14 |
| 15 namespace app_list { | 15 namespace app_list { |
| 16 | 16 |
| 17 namespace { | 17 namespace { |
| 18 | 18 |
| 19 // Normalize the given string by joining all its tokens with a space. | 19 // Normalize the given string by joining all its tokens with a space. |
| 20 std::string NormalizeString(const std::string& utf8) { | 20 std::string NormalizeString(const std::string& utf8) { |
| 21 TokenizedString tokenized(UTF8ToUTF16(utf8)); | 21 TokenizedString tokenized(base::UTF8ToUTF16(utf8)); |
| 22 return UTF16ToUTF8(JoinString(tokenized.tokens(), ' ')); | 22 return base::UTF16ToUTF8(JoinString(tokenized.tokens(), ' ')); |
| 23 } | 23 } |
| 24 | 24 |
| 25 } // namespace | 25 } // namespace |
| 26 | 26 |
| 27 History::History(content::BrowserContext* context) | 27 History::History(content::BrowserContext* context) |
| 28 : browser_context_(context), | 28 : browser_context_(context), |
| 29 data_loaded_(false) { | 29 data_loaded_(false) { |
| 30 const char kStoreDataFileName[] = "App Launcher Search"; | 30 const char kStoreDataFileName[] = "App Launcher Search"; |
| 31 const size_t kMaxQueryEntries = 1000; | 31 const size_t kMaxQueryEntries = 1000; |
| 32 const size_t kMaxSecondaryQueries = 5; | 32 const size_t kMaxSecondaryQueries = 5; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 57 const std::string& query) const { | 57 const std::string& query) const { |
| 58 DCHECK(IsReady()); | 58 DCHECK(IsReady()); |
| 59 return data_->GetKnownResults(NormalizeString(query)).Pass(); | 59 return data_->GetKnownResults(NormalizeString(query)).Pass(); |
| 60 } | 60 } |
| 61 | 61 |
| 62 void History::OnHistoryDataLoadedFromStore() { | 62 void History::OnHistoryDataLoadedFromStore() { |
| 63 data_loaded_ = true; | 63 data_loaded_ = true; |
| 64 } | 64 } |
| 65 | 65 |
| 66 } // namespace app_list | 66 } // namespace app_list |
| OLD | NEW |