OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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 #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h" | 5 #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h" |
6 | 6 |
7 #import <QuartzCore/QuartzCore.h> | 7 #import <QuartzCore/QuartzCore.h> |
8 | 8 |
9 #include <limits> | 9 #include <limits> |
10 #include <string> | 10 #include <string> |
(...skipping 1086 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1097 scoped_nsobject<TabContentsController> contentsController( | 1097 scoped_nsobject<TabContentsController> contentsController( |
1098 [[TabContentsController alloc] initWithContents:contents->tab_contents() | 1098 [[TabContentsController alloc] initWithContents:contents->tab_contents() |
1099 delegate:self]); | 1099 delegate:self]); |
1100 [tabContentsArray_ insertObject:contentsController atIndex:index]; | 1100 [tabContentsArray_ insertObject:contentsController atIndex:index]; |
1101 | 1101 |
1102 // Make a new tab and add it to the strip. Keep track of its controller. | 1102 // Make a new tab and add it to the strip. Keep track of its controller. |
1103 TabController* newController = [self newTab]; | 1103 TabController* newController = [self newTab]; |
1104 [newController setMini:tabStripModel_->IsMiniTab(modelIndex)]; | 1104 [newController setMini:tabStripModel_->IsMiniTab(modelIndex)]; |
1105 [newController setPinned:tabStripModel_->IsTabPinned(modelIndex)]; | 1105 [newController setPinned:tabStripModel_->IsTabPinned(modelIndex)]; |
1106 [newController setApp:tabStripModel_->IsAppTab(modelIndex)]; | 1106 [newController setApp:tabStripModel_->IsAppTab(modelIndex)]; |
| 1107 [newController setUrl:contents->tab_contents()->GetURL()]; |
1107 [tabArray_ insertObject:newController atIndex:index]; | 1108 [tabArray_ insertObject:newController atIndex:index]; |
1108 NSView* newView = [newController view]; | 1109 NSView* newView = [newController view]; |
1109 | 1110 |
1110 // Set the originating frame to just below the strip so that it animates | 1111 // Set the originating frame to just below the strip so that it animates |
1111 // upwards as it's being initially layed out. Oddly, this works while doing | 1112 // upwards as it's being initially layed out. Oddly, this works while doing |
1112 // something similar in |-layoutTabs| confuses the window server. | 1113 // something similar in |-layoutTabs| confuses the window server. |
1113 [newView setFrame:NSOffsetRect([newView frame], | 1114 [newView setFrame:NSOffsetRect([newView frame], |
1114 0, -[[self class] defaultTabHeight])]; | 1115 0, -[[self class] defaultTabHeight])]; |
1115 | 1116 |
1116 [self setTabTitle:newController withContents:contents->tab_contents()]; | 1117 [self setTabTitle:newController withContents:contents->tab_contents()]; |
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1494 TabController* tabController = [tabArray_ objectAtIndex:index]; | 1495 TabController* tabController = [tabArray_ objectAtIndex:index]; |
1495 DCHECK([tabController isKindOfClass:[TabController class]]); | 1496 DCHECK([tabController isKindOfClass:[TabController class]]); |
1496 | 1497 |
1497 // Don't do anything if the change was already picked up by the move event. | 1498 // Don't do anything if the change was already picked up by the move event. |
1498 if (tabStripModel_->IsMiniTab(modelIndex) == [tabController mini]) | 1499 if (tabStripModel_->IsMiniTab(modelIndex) == [tabController mini]) |
1499 return; | 1500 return; |
1500 | 1501 |
1501 [tabController setMini:tabStripModel_->IsMiniTab(modelIndex)]; | 1502 [tabController setMini:tabStripModel_->IsMiniTab(modelIndex)]; |
1502 [tabController setPinned:tabStripModel_->IsTabPinned(modelIndex)]; | 1503 [tabController setPinned:tabStripModel_->IsTabPinned(modelIndex)]; |
1503 [tabController setApp:tabStripModel_->IsAppTab(modelIndex)]; | 1504 [tabController setApp:tabStripModel_->IsAppTab(modelIndex)]; |
| 1505 [tabController setUrl:contents->tab_contents()->GetURL()]; |
1504 [self updateFaviconForContents:contents->tab_contents() atIndex:modelIndex]; | 1506 [self updateFaviconForContents:contents->tab_contents() atIndex:modelIndex]; |
1505 // If the tab is being restored and it's pinned, the mini state is set after | 1507 // If the tab is being restored and it's pinned, the mini state is set after |
1506 // the tab has already been rendered, so re-layout the tabstrip. In all other | 1508 // the tab has already been rendered, so re-layout the tabstrip. In all other |
1507 // cases, the state is set before the tab is rendered so this isn't needed. | 1509 // cases, the state is set before the tab is rendered so this isn't needed. |
1508 [self layoutTabs]; | 1510 [self layoutTabs]; |
1509 | 1511 |
1510 [self updateCommonTitlePrefix]; | 1512 [self updateCommonTitlePrefix]; |
1511 } | 1513 } |
1512 | 1514 |
1513 - (void)setFrameOfSelectedTab:(NSRect)frame { | 1515 - (void)setFrameOfSelectedTab:(NSRect)frame { |
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2036 size_t tabIndex; | 2038 size_t tabIndex; |
2037 size_t tabCount = [tabArray_ count]; | 2039 size_t tabCount = [tabArray_ count]; |
2038 | 2040 |
2039 // Add all tab titles to |tabTitleInfos|. | 2041 // Add all tab titles to |tabTitleInfos|. |
2040 for (tabIndex = 0; tabIndex < tabCount; ++tabIndex) { | 2042 for (tabIndex = 0; tabIndex < tabCount; ++tabIndex) { |
2041 TabController* tabController = [tabArray_ objectAtIndex:tabIndex]; | 2043 TabController* tabController = [tabArray_ objectAtIndex:tabIndex]; |
2042 string16 title = base::SysNSStringToUTF16([tabController title]); | 2044 string16 title = base::SysNSStringToUTF16([tabController title]); |
2043 if (!title.empty() && ![tabController mini]) { | 2045 if (!title.empty() && ![tabController mini]) { |
2044 titles.push_back(new string16(title)); | 2046 titles.push_back(new string16(title)); |
2045 tabTitleInfos.push_back(TitlePrefixMatcher::TitleInfo( | 2047 tabTitleInfos.push_back(TitlePrefixMatcher::TitleInfo( |
2046 titles[titles.size() - 1], tabIndex)); | 2048 titles[titles.size() - 1], [tabController url], tabIndex)); |
2047 } | 2049 } |
2048 } | 2050 } |
2049 | 2051 |
2050 // Calculate the prefix length. | 2052 // Calculate the prefix length. |
2051 TitlePrefixMatcher::CalculatePrefixLengths(&tabTitleInfos); | 2053 TitlePrefixMatcher::CalculatePrefixLengths(&tabTitleInfos); |
2052 | 2054 |
2053 // Update the prefix length for each tab. | 2055 // Update the prefix length for each tab. |
2054 for (size_t infoIndex = 0; infoIndex < tabTitleInfos.size(); ++infoIndex) { | 2056 for (size_t infoIndex = 0; infoIndex < tabTitleInfos.size(); ++infoIndex) { |
2055 tabIndex = tabTitleInfos[infoIndex].caller_value; | 2057 tabIndex = tabTitleInfos[infoIndex].caller_value; |
2056 DCHECK(tabIndex < [tabArray_ count]); | 2058 DCHECK(tabIndex < [tabArray_ count]); |
(...skipping 30 matching lines...) Expand all Loading... |
2087 } | 2089 } |
2088 | 2090 |
2089 NSString* menuTitle = | 2091 NSString* menuTitle = |
2090 l10n_util::GetNSStringWithFixup(IDS_PROFILES_CREATE_NEW_PROFILE_OPTION); | 2092 l10n_util::GetNSStringWithFixup(IDS_PROFILES_CREATE_NEW_PROFILE_OPTION); |
2091 [menu addItemWithTitle:menuTitle | 2093 [menu addItemWithTitle:menuTitle |
2092 action:NULL | 2094 action:NULL |
2093 keyEquivalent:@""]; | 2095 keyEquivalent:@""]; |
2094 } | 2096 } |
2095 | 2097 |
2096 @end | 2098 @end |
OLD | NEW |