OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <cmath> | 9 #include <cmath> |
10 #include <limits> | 10 #include <limits> |
(...skipping 1203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1214 // Handles setting the title of the tab based on the given |contents|. Uses | 1214 // Handles setting the title of the tab based on the given |contents|. Uses |
1215 // a canned string if |contents| is NULL. | 1215 // a canned string if |contents| is NULL. |
1216 - (void)setTabTitle:(TabController*)tab withContents:(WebContents*)contents { | 1216 - (void)setTabTitle:(TabController*)tab withContents:(WebContents*)contents { |
1217 base::string16 title; | 1217 base::string16 title; |
1218 if (contents) | 1218 if (contents) |
1219 title = contents->GetTitle(); | 1219 title = contents->GetTitle(); |
1220 if (title.empty()) | 1220 if (title.empty()) |
1221 title = l10n_util::GetStringUTF16(IDS_BROWSER_WINDOW_MAC_TAB_UNTITLED); | 1221 title = l10n_util::GetStringUTF16(IDS_BROWSER_WINDOW_MAC_TAB_UNTITLED); |
1222 [tab setTitle:base::SysUTF16ToNSString(title)]; | 1222 [tab setTitle:base::SysUTF16ToNSString(title)]; |
1223 | 1223 |
1224 const base::string16& toolTip = chrome::AssembleTabTooltipText( | 1224 NSString* toolTip = base::SysUTF16ToNSString(chrome::AssembleTabTooltipText( |
1225 title, [self alertStateForContents:contents]); | 1225 title, [self alertStateForContents:contents])); |
1226 [tab setToolTip:base::SysUTF16ToNSString(toolTip)]; | 1226 [tab setToolTip:toolTip]; |
| 1227 if ([tab tabView] == hoveredTab_) |
| 1228 [toolTipView_ setToolTip:toolTip]; |
1227 } | 1229 } |
1228 | 1230 |
1229 // Called when a notification is received from the model to insert a new tab | 1231 // Called when a notification is received from the model to insert a new tab |
1230 // at |modelIndex|. | 1232 // at |modelIndex|. |
1231 - (void)insertTabWithContents:(content::WebContents*)contents | 1233 - (void)insertTabWithContents:(content::WebContents*)contents |
1232 atIndex:(NSInteger)modelIndex | 1234 atIndex:(NSInteger)modelIndex |
1233 inForeground:(bool)inForeground { | 1235 inForeground:(bool)inForeground { |
1234 DCHECK(contents); | 1236 DCHECK(contents); |
1235 DCHECK(modelIndex == TabStripModel::kNoTab || | 1237 DCHECK(modelIndex == TabStripModel::kNoTab || |
1236 tabStripModel_->ContainsIndex(modelIndex)); | 1238 tabStripModel_->ContainsIndex(modelIndex)); |
(...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1881 [newHoveredTab mouseEntered:nil]; | 1883 [newHoveredTab mouseEntered:nil]; |
1882 | 1884 |
1883 // Use a transparent subview to show the hovered tab's tooltip while the | 1885 // Use a transparent subview to show the hovered tab's tooltip while the |
1884 // mouse pointer is inside the tab's custom shape. | 1886 // mouse pointer is inside the tab's custom shape. |
1885 if (!toolTipView_) | 1887 if (!toolTipView_) |
1886 toolTipView_.reset([[NSView alloc] init]); | 1888 toolTipView_.reset([[NSView alloc] init]); |
1887 [toolTipView_ setToolTip:[newHoveredTab toolTipText]]; | 1889 [toolTipView_ setToolTip:[newHoveredTab toolTipText]]; |
1888 [toolTipView_ setFrame:[newHoveredTab frame]]; | 1890 [toolTipView_ setFrame:[newHoveredTab frame]]; |
1889 if (![toolTipView_ superview]) { | 1891 if (![toolTipView_ superview]) { |
1890 [tabStripView_ addSubview:toolTipView_ | 1892 [tabStripView_ addSubview:toolTipView_ |
1891 positioned:NSWindowBelow | 1893 positioned:NSWindowAbove |
1892 relativeTo:nil]; | 1894 relativeTo:dragBlockingView_]; |
1893 } | 1895 } |
1894 } | 1896 } |
1895 } | 1897 } |
1896 | 1898 |
1897 // Enable/Disable the tracking areas for the tabs. They are only enabled | 1899 // Enable/Disable the tracking areas for the tabs. They are only enabled |
1898 // when the mouse is in the tabstrip. | 1900 // when the mouse is in the tabstrip. |
1899 - (void)setTabTrackingAreasEnabled:(BOOL)enabled { | 1901 - (void)setTabTrackingAreasEnabled:(BOOL)enabled { |
1900 NSNotificationCenter* defaultCenter = [NSNotificationCenter defaultCenter]; | 1902 NSNotificationCenter* defaultCenter = [NSNotificationCenter defaultCenter]; |
1901 for (TabController* controller in tabArray_.get()) { | 1903 for (TabController* controller in tabArray_.get()) { |
1902 TabView* tabView = [controller tabView]; | 1904 TabView* tabView = [controller tabView]; |
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2291 | 2293 |
2292 - (TabAlertState)alertStateForContents:(content::WebContents*)contents { | 2294 - (TabAlertState)alertStateForContents:(content::WebContents*)contents { |
2293 return chrome::GetTabAlertStateForContents(contents); | 2295 return chrome::GetTabAlertStateForContents(contents); |
2294 } | 2296 } |
2295 | 2297 |
2296 - (void)themeDidChangeNotification:(NSNotification*)notification { | 2298 - (void)themeDidChangeNotification:(NSNotification*)notification { |
2297 [newTabButton_ setImages]; | 2299 [newTabButton_ setImages]; |
2298 } | 2300 } |
2299 | 2301 |
2300 @end | 2302 @end |
OLD | NEW |