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

Side by Side Diff: chrome/browser/autocomplete/history_quick_provider.cc

Issue 77453007: Omnibox: Make HistoryURL Highlight Titles like HistoryQuick Provider (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years 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
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 "chrome/browser/autocomplete/history_quick_provider.h" 5 #include "chrome/browser/autocomplete/history_quick_provider.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 if (index_for_testing_.get()) 309 if (index_for_testing_.get())
310 return index_for_testing_.get(); 310 return index_for_testing_.get();
311 311
312 HistoryService* const history_service = 312 HistoryService* const history_service =
313 HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); 313 HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS);
314 if (!history_service) 314 if (!history_service)
315 return NULL; 315 return NULL;
316 316
317 return history_service->InMemoryIndex(); 317 return history_service->InMemoryIndex();
318 } 318 }
319
320 // static
321 ACMatchClassifications HistoryQuickProvider::SpansFromTermMatch(
322 const history::TermMatches& matches,
323 size_t text_length,
324 bool is_url) {
325 ACMatchClassification::Style url_style =
326 is_url ? ACMatchClassification::URL : ACMatchClassification::NONE;
327 ACMatchClassifications spans;
328 if (matches.empty()) {
329 if (text_length)
330 spans.push_back(ACMatchClassification(0, url_style));
331 return spans;
332 }
333 if (matches[0].offset)
334 spans.push_back(ACMatchClassification(0, url_style));
335 size_t match_count = matches.size();
336 for (size_t i = 0; i < match_count;) {
337 size_t offset = matches[i].offset;
338 spans.push_back(ACMatchClassification(offset,
339 ACMatchClassification::MATCH | url_style));
340 // Skip all adjacent matches.
341 do {
342 offset += matches[i].length;
343 ++i;
344 } while ((i < match_count) && (offset == matches[i].offset));
345 if (offset < text_length)
346 spans.push_back(ACMatchClassification(offset, url_style));
347 }
348
349 return spans;
350 }
OLDNEW
« no previous file with comments | « chrome/browser/autocomplete/history_quick_provider.h ('k') | chrome/browser/autocomplete/history_url_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698