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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/ui/title_prefix_matcher.cc » ('j') | chrome/browser/ui/title_prefix_matcher.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/title_prefix_matcher.h
===================================================================
--- chrome/browser/ui/title_prefix_matcher.h (revision 0)
+++ chrome/browser/ui/title_prefix_matcher.h (revision 0)
@@ -0,0 +1,47 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_UI_TITLE_PREFIX_MATCHER_H_
+#define CHROME_BROWSER_UI_TITLE_PREFIX_MATCHER_H_
+#pragma once
+
+#include <vector>
+
+#include "base/string16.h"
+
+namespace browser {
sky 2011/03/11 00:00:45 We generally don't use namespaces in cases like th
MAD 2011/03/11 03:01:37 Done.
+
+// This exposes a static method that receives a vector of TitleInfo objects
+// so that it can find the length of the common prefixes among all the titles.
sky 2011/03/11 00:00:45 Imagine if you didn't write this class and went to
MAD 2011/03/11 03:01:37 Done.
+class TitlePrefixMatcher {
+ public:
+ struct TitleInfo {
+ TitleInfo(const string16* title, int caller_value)
+ : title(title), prefix_length(0), caller_value(caller_value) {}
sky 2011/03/11 00:00:45 Since you wrapper, each param should be on its own
MAD 2011/03/11 03:01:37 Done.
+ TitleInfo(const TitleInfo& other)
sky 2011/03/11 00:00:45 How come you wrote copy constructor/assignment ope
MAD 2011/03/11 03:01:37 Done. This was needed in a previous iteration when
+ : title(other.title),
+ prefix_length(other.prefix_length),
+ caller_value(other.caller_value) {
+ }
+ TitleInfo& operator=(const TitleInfo& other) {
+ title = other.title;
+ prefix_length = other.prefix_length;
+ caller_value = other.caller_value;
+ return *this;
+ }
+ // We assume the title string will be valid throughout the execution of
+ // the prefix lengths calculation, and use a pointer to avoid an uncessary
+ // string copy.
+ const string16* title;
+ size_t prefix_length;
+ int caller_value; // Unused by CalculatePrefixLengths.
+ };
+ static void CalculatePrefixLengths(std::vector<TitleInfo>* title_infos);
+
+ DISALLOW_COPY_AND_ASSIGN(TitlePrefixMatcher);
sky 2011/03/11 00:00:45 after private. But you probably want DISALLOW_IMPL
MAD 2011/03/11 03:01:37 Done.
+};
+
+} // namespace browser
+
+#endif // CHROME_BROWSER_UI_TITLE_PREFIX_MATCHER_H_
Property changes on: chrome\browser\ui\title_prefix_matcher.h
___________________________________________________________________
Added: svn:eol-style
+ LF
« no previous file with comments | « no previous file | chrome/browser/ui/title_prefix_matcher.cc » ('j') | chrome/browser/ui/title_prefix_matcher.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698