Skip to content

Commit

Permalink
Move basic string operations to ui/app_list/search
Browse files Browse the repository at this point in the history
BUG=380875
R=xiyuan@chromium.org
TEST=build succeeds

Review URL: https://codereview.chromium.org/522683003

Cr-Commit-Position: refs/heads/master@{#292990}
  • Loading branch information
jmuk authored and Commit bot committed Sep 2, 2014
1 parent d5753cc commit 1a85132
Show file tree
Hide file tree
Showing 19 changed files with 64 additions and 45 deletions.
4 changes: 2 additions & 2 deletions chrome/browser/ui/app_list/search/app_result.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/app_list/app_context_menu.h"
#include "chrome/browser/ui/app_list/app_list_controller_delegate.h"
#include "chrome/browser/ui/app_list/search/tokenized_string.h"
#include "chrome/browser/ui/app_list/search/tokenized_string_match.h"
#include "chrome/browser/ui/extensions/extension_enable_flow.h"
#include "chrome/browser/ui/webui/ntp/core_app_launcher_handler.h"
#include "content/public/browser/user_metrics.h"
Expand All @@ -24,6 +22,8 @@
#include "extensions/common/extension_icon_set.h"
#include "extensions/common/manifest_handlers/icons_handler.h"
#include "ui/app_list/app_list_switches.h"
#include "ui/app_list/search/tokenized_string.h"
#include "ui/app_list/search/tokenized_string_match.h"
#include "ui/gfx/color_utils.h"
#include "ui/gfx/image/image_skia_operations.h"

Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/ui/app_list/search/app_search_provider.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
#include "chrome/browser/extensions/extension_util.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/app_list/search/app_result.h"
#include "chrome/browser/ui/app_list/search/tokenized_string.h"
#include "chrome/browser/ui/app_list/search/tokenized_string_match.h"
#include "extensions/browser/extension_prefs.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/browser/extension_system.h"
#include "extensions/common/extension.h"
#include "extensions/common/extension_set.h"
#include "ui/app_list/search/tokenized_string.h"
#include "ui/app_list/search/tokenized_string_match.h"

using extensions::ExtensionRegistry;

Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/ui/app_list/search/history.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/ui/app_list/search/history_data.h"
#include "chrome/browser/ui/app_list/search/history_data_store.h"
#include "chrome/browser/ui/app_list/search/tokenized_string.h"
#include "content/public/browser/browser_context.h"
#include "ui/app_list/search/tokenized_string.h"

namespace app_list {

Expand Down
8 changes: 0 additions & 8 deletions chrome/chrome_browser_ui.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -1232,14 +1232,6 @@
'browser/ui/app_list/search/search_controller.h',
'browser/ui/app_list/search/search_webstore_result.cc',
'browser/ui/app_list/search/search_webstore_result.h',
'browser/ui/app_list/search/term_break_iterator.cc',
'browser/ui/app_list/search/term_break_iterator.h',
'browser/ui/app_list/search/tokenized_string.cc',
'browser/ui/app_list/search/tokenized_string.h',
'browser/ui/app_list/search/tokenized_string_char_iterator.cc',
'browser/ui/app_list/search/tokenized_string_char_iterator.h',
'browser/ui/app_list/search/tokenized_string_match.cc',
'browser/ui/app_list/search/tokenized_string_match.h',
'browser/ui/app_list/search/webstore/webstore_installer.cc',
'browser/ui/app_list/search/webstore/webstore_installer.h',
'browser/ui/app_list/search/webstore/webstore_provider.cc',
Expand Down
4 changes: 0 additions & 4 deletions chrome/chrome_tests_unit.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -2122,10 +2122,6 @@
'browser/ui/app_list/search/history_unittest.cc',
'browser/ui/app_list/search/history_data_store_unittest.cc',
'browser/ui/app_list/search/mixer_unittest.cc',
'browser/ui/app_list/search/term_break_iterator_unittest.cc',
'browser/ui/app_list/search/tokenized_string_char_iterator_unittest.cc',
'browser/ui/app_list/search/tokenized_string_match_unittest.cc',
'browser/ui/app_list/search/tokenized_string_unittest.cc',
],
'dependencies': [
'../ash/ash.gyp:ash_test_support',
Expand Down
15 changes: 14 additions & 1 deletion ui/app_list/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ component("app_list") {
"search_provider.h",
"search_result.cc",
"search_result.h",
"search/term_break_iterator.cc",
"search/term_break_iterator.h",
"search/tokenized_string.cc",
"search/tokenized_string.h",
"search/tokenized_string_char_iterator.cc",
"search/tokenized_string_char_iterator.h",
"search/tokenized_string_match.cc",
"search/tokenized_string_match.h",
"speech_ui_model.cc",
"speech_ui_model.h",
"speech_ui_model_observer.h",
Expand All @@ -50,6 +58,7 @@ component("app_list") {
"//base:i18n",
"//base/third_party/dynamic_annotations",
"//skia",
"//third_party/icu",
"//ui/accessibility",
"//ui/base",
"//ui/compositor",
Expand Down Expand Up @@ -158,7 +167,7 @@ component("app_list") {
"cocoa/scroll_view_with_no_scrollbars.mm",
]
deps += [
#'../../third_party/google_toolbox_for_mac/google_toolbox_for_mac.gyp:google_toolbox_for_mac', TODO(GYP)
#"../../third_party/google_toolbox_for_mac/google_toolbox_for_mac.gyp:google_toolbox_for_mac", TODO(GYP)
]
libs = [ "QuartzCore.framework" ]
}
Expand Down Expand Up @@ -186,6 +195,10 @@ test("app_list_unittests") {
"app_list_item_list_unittest.cc",
"app_list_model_unittest.cc",
"pagination_model_unittest.cc",
"search/term_break_iterator_unittest.cc",
"search/tokenized_string_char_iterator_unittest.cc",
"search/tokenized_string_match_unittest.cc",
"search/tokenized_string_unittest.cc",
"test/run_all_unittests.cc",
]

Expand Down
13 changes: 13 additions & 0 deletions ui/app_list/app_list.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
'../gfx/gfx.gyp:gfx_geometry',
'../resources/ui_resources.gyp:ui_resources',
'../strings/ui_strings.gyp:ui_strings',
'../../third_party/icu/icu.gyp:icuuc',
],
'defines': [
'APP_LIST_IMPLEMENTATION',
Expand Down Expand Up @@ -84,6 +85,14 @@
'search_provider.h',
'search_result.cc',
'search_result.h',
'search/term_break_iterator.cc',
'search/term_break_iterator.h',
'search/tokenized_string.cc',
'search/tokenized_string.h',
'search/tokenized_string_char_iterator.cc',
'search/tokenized_string_char_iterator.h',
'search/tokenized_string_match.cc',
'search/tokenized_string_match.h',
'speech_ui_model.cc',
'speech_ui_model.h',
'speech_ui_model_observer.h',
Expand Down Expand Up @@ -225,6 +234,10 @@
'cocoa/apps_search_results_controller_unittest.mm',
'cocoa/test/apps_grid_controller_test_helper.h',
'cocoa/test/apps_grid_controller_test_helper.mm',
'search/term_break_iterator_unittest.cc',
'search/tokenized_string_char_iterator_unittest.cc',
'search/tokenized_string_match_unittest.cc',
'search/tokenized_string_unittest.cc',
'test/run_all_unittests.cc',
'views/app_list_main_view_unittest.cc',
'views/app_list_view_unittest.cc',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/ui/app_list/search/term_break_iterator.h"
#include "ui/app_list/search/term_break_iterator.h"

#include "base/i18n/char_iterator.h"
#include "base/logging.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_BROWSER_UI_APP_LIST_SEARCH_TERM_BREAK_ITERATOR_H_
#define CHROME_BROWSER_UI_APP_LIST_SEARCH_TERM_BREAK_ITERATOR_H_
#ifndef UI_APP_LIST_SEARCH_TERM_BREAK_ITERATOR_H_
#define UI_APP_LIST_SEARCH_TERM_BREAK_ITERATOR_H_

#include "base/basictypes.h"
#include "base/memory/scoped_ptr.h"
#include "base/strings/string16.h"
#include "ui/app_list/app_list_export.h"

namespace base {
namespace i18n {
Expand All @@ -23,7 +24,7 @@ namespace app_list {
// e.g.
// CamelCase -> Camel, Case
// Python2.7 -> Python, 2.7
class TermBreakIterator {
class APP_LIST_EXPORT TermBreakIterator {
public:
// Note that |word| must out live this iterator.
explicit TermBreakIterator(const base::string16& word);
Expand Down Expand Up @@ -66,4 +67,4 @@ class TermBreakIterator {

} // namespace app_list

#endif // CHROME_BROWSER_UI_APP_LIST_SEARCH_TERM_BREAK_ITERATOR_H_
#endif // UI_APP_LIST_SEARCH_TERM_BREAK_ITERATOR_H_
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/ui/app_list/search/term_break_iterator.h"
#include "ui/app_list/search/term_break_iterator.h"

#include "base/strings/utf_string_conversions.h"
#include "testing/gtest/include/gtest/gtest.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/ui/app_list/search/tokenized_string.h"
#include "ui/app_list/search/tokenized_string.h"

#include "base/i18n/break_iterator.h"
#include "base/i18n/case_conversion.h"
#include "base/logging.h"
#include "chrome/browser/ui/app_list/search/term_break_iterator.h"
#include "ui/app_list/search/term_break_iterator.h"

using base::i18n::BreakIterator;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,22 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_BROWSER_UI_APP_LIST_SEARCH_TOKENIZED_STRING_H_
#define CHROME_BROWSER_UI_APP_LIST_SEARCH_TOKENIZED_STRING_H_
#ifndef UI_APP_LIST_SEARCH_TOKENIZED_STRING_H_
#define UI_APP_LIST_SEARCH_TOKENIZED_STRING_H_

#include <vector>

#include "base/basictypes.h"
#include "base/strings/string16.h"
#include "ui/app_list/app_list_export.h"
#include "ui/gfx/range/range.h"

namespace app_list {

// TokenizedString takes a string and breaks it down into token words. It
// first breaks using BreakIterator to get all the words. Then it breaks
// the words again at camel case boundaries and alpha/number boundaries.
class TokenizedString {
class APP_LIST_EXPORT TokenizedString {
public:
typedef std::vector<base::string16> Tokens;
typedef std::vector<gfx::Range> Mappings;
Expand All @@ -43,4 +44,4 @@ class TokenizedString {

} // namespace app_list

#endif // CHROME_BROWSER_UI_APP_LIST_SEARCH_TOKENIZED_STRING_H_
#endif // UI_APP_LIST_SEARCH_TOKENIZED_STRING_H_
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/ui/app_list/search/tokenized_string_char_iterator.h"
#include "ui/app_list/search/tokenized_string_char_iterator.h"

#include "base/i18n/char_iterator.h"
#include "base/logging.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_BROWSER_UI_APP_LIST_SEARCH_TOKENIZED_STRING_CHAR_ITERATOR_H_
#define CHROME_BROWSER_UI_APP_LIST_SEARCH_TOKENIZED_STRING_CHAR_ITERATOR_H_
#ifndef UI_APP_LIST_SEARCH_TOKENIZED_STRING_CHAR_ITERATOR_H_
#define UI_APP_LIST_SEARCH_TOKENIZED_STRING_CHAR_ITERATOR_H_

#include "base/basictypes.h"
#include "base/memory/scoped_ptr.h"
#include "chrome/browser/ui/app_list/search/tokenized_string.h"
#include "ui/app_list/app_list_export.h"
#include "ui/app_list/search/tokenized_string.h"

namespace base {
namespace i18n {
Expand All @@ -18,7 +19,7 @@ class UTF16CharIterator;
namespace app_list {

// An UTF16 char iterator for a TokenizedString.
class TokenizedStringCharIterator {
class APP_LIST_EXPORT TokenizedStringCharIterator {
public:
struct State {
State();
Expand Down Expand Up @@ -73,4 +74,4 @@ class TokenizedStringCharIterator {

} // namespace app_list

#endif // CHROME_BROWSER_UI_APP_LIST_SEARCH_TOKENIZED_STRING_CHAR_ITERATOR_H_
#endif // UI_APP_LIST_SEARCH_TOKENIZED_STRING_CHAR_ITERATOR_H_
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/ui/app_list/search/tokenized_string_char_iterator.h"
#include "ui/app_list/search/tokenized_string_char_iterator.h"

#include <string>
#include <vector>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/ui/app_list/search/tokenized_string_match.h"
#include "ui/app_list/search/tokenized_string_match.h"

#include "base/i18n/string_search.h"
#include "base/logging.h"
#include "chrome/browser/ui/app_list/search/tokenized_string_char_iterator.h"
#include "ui/app_list/search/tokenized_string_char_iterator.h"

namespace app_list {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_BROWSER_UI_APP_LIST_SEARCH_TOKENIZED_STRING_MATCH_H_
#define CHROME_BROWSER_UI_APP_LIST_SEARCH_TOKENIZED_STRING_MATCH_H_
#ifndef UI_APP_LIST_SEARCH_TOKENIZED_STRING_MATCH_H_
#define UI_APP_LIST_SEARCH_TOKENIZED_STRING_MATCH_H_

#include <vector>

#include "base/basictypes.h"
#include "base/strings/string16.h"
#include "ui/app_list/app_list_export.h"
#include "ui/gfx/range/range.h"

namespace app_list {
Expand All @@ -21,7 +22,7 @@ class TokenizedString;
// of text. A relevance of zero means the two are completely different to each
// other. The higher the relevance score, the better the two strings are
// matched. Matched portions of text are stored as index ranges.
class TokenizedStringMatch {
class APP_LIST_EXPORT TokenizedStringMatch {
public:
typedef std::vector<gfx::Range> Hits;

Expand Down Expand Up @@ -50,4 +51,4 @@ class TokenizedStringMatch {

} // namespace app_list

#endif // CHROME_BROWSER_UI_APP_LIST_SEARCH_TOKENIZED_STRING_MATCH_H_
#endif // UI_APP_LIST_SEARCH_TOKENIZED_STRING_MATCH_H_
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "ui/app_list/search/tokenized_string_match.h"

#include <string>

#include "base/basictypes.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/ui/app_list/search/tokenized_string_match.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace app_list {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/ui/app_list/search/tokenized_string.h"
#include "ui/app_list/search/tokenized_string.h"

#include "base/strings/utf_string_conversions.h"
#include "testing/gtest/include/gtest/gtest.h"
Expand Down

0 comments on commit 1a85132

Please sign in to comment.