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

Unified Diff: chrome/browser/ui/title_prefix_matcher.h

Issue 6783015: Improvements to tab title prefix eliding as per email discussions. (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 | « chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm ('k') | chrome/browser/ui/title_prefix_matcher.cc » ('j') | no next file with comments »
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 80442)
+++ chrome/browser/ui/title_prefix_matcher.h (working copy)
@@ -9,6 +9,7 @@
#include <vector>
#include "base/string16.h"
+#include "googleurl/src/gurl.h"
// This class exposes a static method that receives a vector of TitleInfo
// objects so that it can find the length of the common prefixes among all
@@ -26,11 +27,14 @@
class TitlePrefixMatcher {
public:
struct TitleInfo {
- TitleInfo(const string16* title, int caller_value);
+ TitleInfo(const string16* title, const GURL& url, int caller_value);
+ ~TitleInfo();
// We assume the title string will be valid throughout the execution of
// the prefix lengths calculation, and so we use a pointer to avoid an
// unnecessary string copy.
const string16* title;
+ // We only look for common prefix when the URL has the same hostname.
+ GURL url;
// This contains the number of characters at the beginning of title that
// are common with other titles in the TitleInfo vector.
size_t prefix_length;
@@ -39,6 +43,12 @@
};
static void CalculatePrefixLengths(std::vector<TitleInfo>* title_infos);
+ // We want to show the last few common chars of a page title in the tab,
+ // so we only do it if the common prefix is at least kMinElidingLength,
+ // otherwise, we could be replacing less characters than the ellipsis take.
+ static const int kCommonCharsToShow;
+ static const size_t kMinElidingLength;
+
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(TitlePrefixMatcher);
};
« no previous file with comments | « chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm ('k') | chrome/browser/ui/title_prefix_matcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698