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

Side by Side Diff: sync/syncable/syncable.cc

Issue 9836100: Add full text regex searching to chrome://sync (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix typo Created 8 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « sync/syncable/syncable.h ('k') | sync/syncable/syncable_id.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "sync/syncable/syncable.h" 5 #include "sync/syncable/syncable.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cstring> 8 #include <cstring>
9 #include <functional> 9 #include <functional>
10 #include <iomanip> 10 #include <iomanip>
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 if (ref(ID).IsRoot()) 295 if (ref(ID).IsRoot())
296 return TOP_LEVEL_FOLDER; 296 return TOP_LEVEL_FOLDER;
297 // Loose check for server-created top-level folders that aren't 297 // Loose check for server-created top-level folders that aren't
298 // bound to a particular model type. 298 // bound to a particular model type.
299 if (!ref(UNIQUE_SERVER_TAG).empty() && ref(SERVER_IS_DIR)) 299 if (!ref(UNIQUE_SERVER_TAG).empty() && ref(SERVER_IS_DIR))
300 return TOP_LEVEL_FOLDER; 300 return TOP_LEVEL_FOLDER;
301 301
302 return UNSPECIFIED; 302 return UNSPECIFIED;
303 } 303 }
304 304
305 bool EntryKernel::ContainsString(const std::string& lowercase_query) const {
306 // TODO(lipalani) - figure out what to do if the node is encrypted.
307 const sync_pb::EntitySpecifics& specifics = ref(SPECIFICS);
308 std::string temp;
309 // The protobuf serialized string contains the original strings. So
310 // we will just serialize it and search it.
311 specifics.SerializeToString(&temp);
312
313 // Now convert to lower case.
314 StringToLowerASCII(&temp);
315
316 if (temp.find(lowercase_query) != std::string::npos)
317 return true;
318
319 // Now go through all the string fields to see if the value is there.
320 for (int i = STRING_FIELDS_BEGIN; i < STRING_FIELDS_END; ++i) {
321 if (StringToLowerASCII(ref(static_cast<StringField>(i))).find(
322 lowercase_query) != std::string::npos)
323 return true;
324 }
325
326 for (int i = ID_FIELDS_BEGIN; i < ID_FIELDS_END; ++i) {
327 const Id& id = ref(static_cast<IdField>(i));
328 if (id.ContainsStringCaseInsensitive(lowercase_query)) {
329 return true;
330 }
331 }
332 return false;
333 }
334
335 namespace { 305 namespace {
336 306
337 // Utility function to loop through a set of enum values and add the 307 // Utility function to loop through a set of enum values and add the
338 // field keys/values in the kernel to the given dictionary. 308 // field keys/values in the kernel to the given dictionary.
339 // 309 //
340 // V should be convertible to Value. 310 // V should be convertible to Value.
341 template <class T, class U, class V> 311 template <class T, class U, class V>
342 void SetFieldValues(const EntryKernel& kernel, 312 void SetFieldValues(const EntryKernel& kernel,
343 DictionaryValue* dictionary_value, 313 DictionaryValue* dictionary_value,
344 const char* (*enum_key_fn)(T), 314 const char* (*enum_key_fn)(T),
(...skipping 2051 matching lines...) Expand 10 before | Expand all | Expand 10 after
2396 if (entry->ref(NEXT_ID).IsRoot() || 2366 if (entry->ref(NEXT_ID).IsRoot() ||
2397 entry->ref(NEXT_ID) != entry->ref(PREV_ID)) { 2367 entry->ref(NEXT_ID) != entry->ref(PREV_ID)) {
2398 return entry; 2368 return entry;
2399 } 2369 }
2400 } 2370 }
2401 // There were no children in the linked list. 2371 // There were no children in the linked list.
2402 return NULL; 2372 return NULL;
2403 } 2373 }
2404 2374
2405 } // namespace syncable 2375 } // namespace syncable
OLDNEW
« no previous file with comments | « sync/syncable/syncable.h ('k') | sync/syncable/syncable_id.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698