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

Side by Side Diff: chrome/browser/ui/title_prefix_matcher.h

Issue 6579050: Elides the beginning of tab titles that have common prefixes. ... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 9 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 | « no previous file | chrome/browser/ui/title_prefix_matcher.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_UI_TITLE_PREFIX_MATCHER_H_
6 #define CHROME_BROWSER_UI_TITLE_PREFIX_MATCHER_H_
7 #pragma once
8
9 #include <vector>
10
11 #include "base/string16.h"
12
13 // This class exposes a static method that receives a vector of TitleInfo
14 // objects so that it can find the length of the common prefixes among all
15 // the titles. It can be used for tab titles for example so that the common
16 // prefixes can be elided.
17 // First, the caller needs to fill a vector of TitleInfo objects with the titles
18 // for which they want to find the common prefix lengths. They can also provide
19 // an optional caller_value where the index of the tabs could be saved
20 // for example. This way the caller can remember which tab this title belongs
21 // to, if not all tabs are passed into the vector.
22 // When CalculatePrefixLengths returns, the TitleInfo objects in the vector
23 // are set with the prefix_length that is common between this title
24 // and at least one other.
25 // Note that the prefix_length is only calculated at word boundaries.
26 class TitlePrefixMatcher {
27 public:
28 struct TitleInfo {
29 TitleInfo(const string16* title, int caller_value);
30 // We assume the title string will be valid throughout the execution of
31 // the prefix lengths calculation, and so we use a pointer to avoid an
32 // unnecessary string copy.
33 const string16* title;
34 // This contains the number of characters at the beginning of title that
35 // are common with other titles in the TitleInfo vector.
36 size_t prefix_length;
37 // Utility data space for the caller. Unused by CalculatePrefixLengths.
38 int caller_value;
39 };
40 static void CalculatePrefixLengths(std::vector<TitleInfo>* title_infos);
41 private:
sky 2011/03/11 16:32:15 nit: newline between 40 and 41.
MAD 2011/03/11 19:24:41 Done.
42 DISALLOW_IMPLICIT_CONSTRUCTORS(TitlePrefixMatcher);
43 };
44
45 #endif // CHROME_BROWSER_UI_TITLE_PREFIX_MATCHER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/title_prefix_matcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698