Chromium Code Reviews| Index: chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm |
| =================================================================== |
| --- chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm (revision 78685) |
| +++ chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm (working copy) |
| @@ -1,4 +1,4 @@ |
| -// Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| +// 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. |
| @@ -37,6 +37,7 @@ |
| #import "chrome/browser/ui/cocoa/tracking_area.h" |
| #include "chrome/browser/ui/find_bar/find_bar.h" |
| #include "chrome/browser/ui/find_bar/find_bar_controller.h" |
| +#include "chrome/browser/ui/title_prefix_matcher.h" |
| #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| #include "content/browser/tab_contents/navigation_controller.h" |
| #include "content/browser/tab_contents/navigation_entry.h" |
| @@ -143,6 +144,7 @@ |
| givesIndex:(NSInteger*)index |
| disposition:(WindowOpenDisposition*)disposition; |
| - (void)setNewTabButtonHoverState:(BOOL)showHover; |
| +- (void)updateCommonTitlePrefix; |
| @end |
| // A simple view class that prevents the Window Server from dragging the area |
| @@ -1023,6 +1025,8 @@ |
| // else. |
| [self updateFaviconForContents:contents->tab_contents() atIndex:modelIndex]; |
| + [self updateCommonTitlePrefix]; |
| + |
| // Send a broadcast that the number of tabs have changed. |
| [[NSNotificationCenter defaultCenter] |
| postNotificationName:kTabStripNumberOfTabsChanged |
| @@ -1142,6 +1146,8 @@ |
| // Once we're totally done with the tab, delete its controller |
| [tabArray_ removeObjectAtIndex:index]; |
| + |
| + [self updateCommonTitlePrefix]; |
| } |
| // Called by the CAAnimation delegate when the tab completes the closing |
| @@ -1337,6 +1343,8 @@ |
| TabContentsController* updatedController = |
| [tabContentsArray_ objectAtIndex:index]; |
| [updatedController tabDidChange:contents->tab_contents()]; |
| + |
| + [self updateCommonTitlePrefix]; |
| } |
| // Called when a tab is moved (usually by drag&drop). Keep our parallel arrays |
| @@ -1906,4 +1914,26 @@ |
| } |
| } |
| +- (void)updateCommonTitlePrefix { |
|
pink (ping after 24hrs)
2011/03/21 13:31:38
this method needs a comment
Robert Sesek
2011/03/21 19:09:14
+1. Each loop should probably have one, too.
sail
2011/03/22 00:47:00
Done.
sail
2011/03/22 00:47:00
Done.
|
| + std::vector<TitlePrefixMatcher::TitleInfo> tabTitleInfos; |
| + int tabIndex = 0; |
| + for (TabController* tabController in tabArray_.get()) { |
| + TabContentsController* tabContentsController = |
| + [tabContentsArray_ objectAtIndex:tabIndex]; |
|
pink (ping after 24hrs)
2011/03/21 13:31:38
continuations indented 4 additional spaces.
sail
2011/03/22 00:47:00
Done.
|
| + TabContents* tabContents = [tabContentsController tabContents]; |
| + if (!tabContents->GetTitle().empty() && ![tabController mini]) { |
| + tabTitleInfos.push_back(TitlePrefixMatcher::TitleInfo( |
| + &(tabContents->GetTitle()), tabIndex)); |
| + } |
| + } |
| + TitlePrefixMatcher::CalculatePrefixLengths(&tabTitleInfos); |
| + |
| + for (size_t infoIndex = 0; infoIndex < tabTitleInfos.size(); infoIndex++) { |
|
pink (ping after 24hrs)
2011/03/21 13:31:38
++infoIndex, not that it really matters.
sail
2011/03/22 00:47:00
Done.
|
| + tabIndex = tabTitleInfos[infoIndex].caller_value; |
| + TabController* tabController = [tabArray_ objectAtIndex:tabIndex]; |
|
pink (ping after 24hrs)
2011/03/21 13:31:38
you should DCHECK tabIndex < array length to ensur
sail
2011/03/22 00:47:00
Done.
|
| + [tabController setTitleCommonPrefixLength: |
| + tabTitleInfos[infoIndex].prefix_length]; |
| + } |
| +} |
| + |
| @end |