diff options
author | rlarocque@chromium.org <rlarocque@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-13 20:41:12 +0000 |
---|---|---|
committer | rlarocque@chromium.org <rlarocque@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-13 20:41:12 +0000 |
commit | 76dea1e68b42374ecf2e4c7063b1494f62dd2c42 (patch) | |
tree | 3ede49818bfd3f9b22d63430dcaa5d51e99c1fd5 /sync | |
parent | 8141b7802e394322d674abb5ab051262e57a4816 (diff) | |
download | chromium_src-76dea1e68b42374ecf2e4c7063b1494f62dd2c42.zip chromium_src-76dea1e68b42374ecf2e4c7063b1494f62dd2c42.tar.gz chromium_src-76dea1e68b42374ecf2e4c7063b1494f62dd2c42.tar.bz2 |
Add full text regex searching to chrome://sync
The search tab of chrome://sync would previously perform a string search
of a select set of fields. This change modifies the search behaviour to
instead perform a regex match against a serialized version of the node.
Part of this change is to move the searching function out of C++ and
into JavaScript. When a search is performed, all nodes are loaded from
the database, marshalled, and sent over the fence to the JavaScript side
of things. This comes with a significant performance cost, but it's not
much worse than a search matching all nodes would have been under the
old system.
While there was no such thing as an invalid search string under the
old system, it is possible to enter an invalid regex. This change adds
some logic to alert the user if their search query is not a valid regex
(ie. if it ends with a backslash).
In order to make it easier to formulate queries, the way we display
results has been changed. The right pane will now display the
serialization of the raw node (which exactly reflects the text that was
searched) rather than the "details" used in the old system. This new
format is a subset of the old, and corresponds to the dictionary value
found under "entry" in the old display.
Finally, this change removes support for some JavaScript calls that are
no longer used.
This change fixes JavaScript style-checker issues in the files that it
touches.
BUG=104574, 122021
TEST=
Review URL: http://codereview.chromium.org/9836100
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@132259 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sync')
-rw-r--r-- | sync/syncable/syncable.cc | 30 | ||||
-rw-r--r-- | sync/syncable/syncable.h | 4 | ||||
-rw-r--r-- | sync/syncable/syncable_id.cc | 7 | ||||
-rw-r--r-- | sync/syncable/syncable_id.h | 3 |
4 files changed, 0 insertions, 44 deletions
diff --git a/sync/syncable/syncable.cc b/sync/syncable/syncable.cc index 7bf1a58..f5dde90 100644 --- a/sync/syncable/syncable.cc +++ b/sync/syncable/syncable.cc @@ -302,36 +302,6 @@ syncable::ModelType EntryKernel::GetServerModelType() const { return UNSPECIFIED; } -bool EntryKernel::ContainsString(const std::string& lowercase_query) const { - // TODO(lipalani) - figure out what to do if the node is encrypted. - const sync_pb::EntitySpecifics& specifics = ref(SPECIFICS); - std::string temp; - // The protobuf serialized string contains the original strings. So - // we will just serialize it and search it. - specifics.SerializeToString(&temp); - - // Now convert to lower case. - StringToLowerASCII(&temp); - - if (temp.find(lowercase_query) != std::string::npos) - return true; - - // Now go through all the string fields to see if the value is there. - for (int i = STRING_FIELDS_BEGIN; i < STRING_FIELDS_END; ++i) { - if (StringToLowerASCII(ref(static_cast<StringField>(i))).find( - lowercase_query) != std::string::npos) - return true; - } - - for (int i = ID_FIELDS_BEGIN; i < ID_FIELDS_END; ++i) { - const Id& id = ref(static_cast<IdField>(i)); - if (id.ContainsStringCaseInsensitive(lowercase_query)) { - return true; - } - } - return false; -} - namespace { // Utility function to loop through a set of enum values and add the diff --git a/sync/syncable/syncable.h b/sync/syncable/syncable.h index 5dc323f..3eb22f4 100644 --- a/sync/syncable/syncable.h +++ b/sync/syncable/syncable.h @@ -379,10 +379,6 @@ struct EntryKernel { syncable::ModelType GetServerModelType() const; - // Does a case in-sensitive search for a given string, which must be - // lower case. - bool ContainsString(const std::string& lowercase_query) const; - // Dumps all kernel info into a DictionaryValue and returns it. // Transfers ownership of the DictionaryValue to the caller. base::DictionaryValue* ToValue() const; diff --git a/sync/syncable/syncable_id.cc b/sync/syncable/syncable_id.cc index f860cb9..92a7411 100644 --- a/sync/syncable/syncable_id.cc +++ b/sync/syncable/syncable_id.cc @@ -6,7 +6,6 @@ #include <iosfwd> -#include "base/string_util.h" #include "base/values.h" using std::ostream; @@ -57,12 +56,6 @@ Id Id::GetLexicographicSuccessor() const { return id; } -bool Id::ContainsStringCaseInsensitive( - const std::string& lowercase_query) const { - DCHECK_EQ(StringToLowerASCII(lowercase_query), lowercase_query); - return StringToLowerASCII(s_).find(lowercase_query) != std::string::npos; -} - // static Id Id::GetLeastIdForLexicographicComparison() { Id id; diff --git a/sync/syncable/syncable_id.h b/sync/syncable/syncable_id.h index 34f4fcc..bcc66f5 100644 --- a/sync/syncable/syncable_id.h +++ b/sync/syncable/syncable_id.h @@ -97,9 +97,6 @@ class Id { // by operator<. Id GetLexicographicSuccessor() const; - // Note: |lowercase_query| should be passed in as lower case. - bool ContainsStringCaseInsensitive(const std::string& lowercase_query) const; - // Dumps the ID as a value and returns it. Transfers ownership of // the StringValue to the caller. base::StringValue* ToValue() const; |