OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/tab_strip_controller.h" | 5 #import "chrome/browser/ui/cocoa/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> |
11 | 11 |
12 #include "app/l10n_util.h" | 12 #include "app/l10n_util.h" |
13 #include "app/mac/nsimage_cache.h" | |
13 #include "app/resource_bundle.h" | 14 #include "app/resource_bundle.h" |
14 #include "base/mac_util.h" | 15 #include "base/mac_util.h" |
15 #include "base/nsimage_cache_mac.h" | |
16 #include "base/sys_string_conversions.h" | 16 #include "base/sys_string_conversions.h" |
17 #include "chrome/app/chrome_command_ids.h" | 17 #include "chrome/app/chrome_command_ids.h" |
18 #include "chrome/browser/autocomplete/autocomplete.h" | 18 #include "chrome/browser/autocomplete/autocomplete.h" |
19 #include "chrome/browser/autocomplete/autocomplete_classifier.h" | 19 #include "chrome/browser/autocomplete/autocomplete_classifier.h" |
20 #include "chrome/browser/autocomplete/autocomplete_match.h" | 20 #include "chrome/browser/autocomplete/autocomplete_match.h" |
21 #include "chrome/browser/metrics/user_metrics.h" | 21 #include "chrome/browser/metrics/user_metrics.h" |
22 #include "chrome/browser/profiles/profile.h" | 22 #include "chrome/browser/profiles/profile.h" |
23 #include "chrome/browser/debugger/devtools_window.h" | 23 #include "chrome/browser/debugger/devtools_window.h" |
24 #include "chrome/browser/net/url_fixer_upper.h" | 24 #include "chrome/browser/net/url_fixer_upper.h" |
25 #include "chrome/browser/sidebar/sidebar_container.h" | 25 #include "chrome/browser/sidebar/sidebar_container.h" |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
309 // TODO(viettrungluu): WTF? "For some reason, if the view is present in the | 309 // TODO(viettrungluu): WTF? "For some reason, if the view is present in the |
310 // nib a priori, it draws correctly. If we create it in code and add it to | 310 // nib a priori, it draws correctly. If we create it in code and add it to |
311 // the tab view, it draws with all sorts of crazy artifacts." | 311 // the tab view, it draws with all sorts of crazy artifacts." |
312 newTabButton_ = [view newTabButton]; | 312 newTabButton_ = [view newTabButton]; |
313 [self addSubviewToPermanentList:newTabButton_]; | 313 [self addSubviewToPermanentList:newTabButton_]; |
314 [newTabButton_ setTarget:nil]; | 314 [newTabButton_ setTarget:nil]; |
315 [newTabButton_ setAction:@selector(commandDispatch:)]; | 315 [newTabButton_ setAction:@selector(commandDispatch:)]; |
316 [newTabButton_ setTag:IDC_NEW_TAB]; | 316 [newTabButton_ setTag:IDC_NEW_TAB]; |
317 // Set the images from code because Cocoa fails to find them in our sub | 317 // Set the images from code because Cocoa fails to find them in our sub |
318 // bundle during tests. | 318 // bundle during tests. |
319 [newTabButton_ setImage:nsimage_cache::ImageNamed(kNewTabImage)]; | 319 [newTabButton_ setImage:app::mac::GetCachedImageWithName(kNewTabImage)]; |
320 [newTabButton_ | 320 [newTabButton_ setAlternateImage:app::mac::GetCachedImageWithName( |
321 setAlternateImage:nsimage_cache::ImageNamed(kNewTabPressedImage)]; | 321 kNewTabPressedImage)]; |
Avi (use Gerrit)
2010/12/22 19:06:38
Awkward break; better is breaking after setAlterna
| |
322 newTabButtonShowingHoverImage_ = NO; | 322 newTabButtonShowingHoverImage_ = NO; |
323 newTabTrackingArea_.reset( | 323 newTabTrackingArea_.reset( |
324 [[NSTrackingArea alloc] initWithRect:[newTabButton_ bounds] | 324 [[NSTrackingArea alloc] initWithRect:[newTabButton_ bounds] |
325 options:(NSTrackingMouseEnteredAndExited | | 325 options:(NSTrackingMouseEnteredAndExited | |
326 NSTrackingActiveAlways) | 326 NSTrackingActiveAlways) |
327 owner:self | 327 owner:self |
328 userInfo:nil]); | 328 userInfo:nil]); |
329 [newTabButton_ addTrackingArea:newTabTrackingArea_.get()]; | 329 [newTabButton_ addTrackingArea:newTabTrackingArea_.get()]; |
330 targetFrames_.reset([[NSMutableDictionary alloc] init]); | 330 targetFrames_.reset([[NSMutableDictionary alloc] init]); |
331 | 331 |
(...skipping 1251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1583 } | 1583 } |
1584 [tabView setTrackingEnabled:enabled]; | 1584 [tabView setTrackingEnabled:enabled]; |
1585 } | 1585 } |
1586 } | 1586 } |
1587 | 1587 |
1588 // Sets the new tab button's image based on the current hover state. Does | 1588 // Sets the new tab button's image based on the current hover state. Does |
1589 // nothing if the hover state is already correct. | 1589 // nothing if the hover state is already correct. |
1590 - (void)setNewTabButtonHoverState:(BOOL)shouldShowHover { | 1590 - (void)setNewTabButtonHoverState:(BOOL)shouldShowHover { |
1591 if (shouldShowHover && !newTabButtonShowingHoverImage_) { | 1591 if (shouldShowHover && !newTabButtonShowingHoverImage_) { |
1592 newTabButtonShowingHoverImage_ = YES; | 1592 newTabButtonShowingHoverImage_ = YES; |
1593 [newTabButton_ setImage:nsimage_cache::ImageNamed(kNewTabHoverImage)]; | 1593 [newTabButton_ |
1594 setImage:app::mac::GetCachedImageWithName(kNewTabHoverImage)]; | |
Avi (use Gerrit)
2010/12/22 19:06:38
Ditto; a cleaner break is after setImage:
| |
1594 } else if (!shouldShowHover && newTabButtonShowingHoverImage_) { | 1595 } else if (!shouldShowHover && newTabButtonShowingHoverImage_) { |
1595 newTabButtonShowingHoverImage_ = NO; | 1596 newTabButtonShowingHoverImage_ = NO; |
1596 [newTabButton_ setImage:nsimage_cache::ImageNamed(kNewTabImage)]; | 1597 [newTabButton_ setImage:app::mac::GetCachedImageWithName(kNewTabImage)]; |
1597 } | 1598 } |
1598 } | 1599 } |
1599 | 1600 |
1600 // Adds the given subview to (the end of) the list of permanent subviews | 1601 // Adds the given subview to (the end of) the list of permanent subviews |
1601 // (specified from bottom up). These subviews will always be below the | 1602 // (specified from bottom up). These subviews will always be below the |
1602 // transitory subviews (tabs). |-regenerateSubviewList| must be called to | 1603 // transitory subviews (tabs). |-regenerateSubviewList| must be called to |
1603 // effectuate the addition. | 1604 // effectuate the addition. |
1604 - (void)addSubviewToPermanentList:(NSView*)aView { | 1605 - (void)addSubviewToPermanentList:(NSView*)aView { |
1605 if (aView) | 1606 if (aView) |
1606 [permanentSubviews_ addObject:aView]; | 1607 [permanentSubviews_ addObject:aView]; |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1895 NSInteger index = [self indexFromModelIndex:modelIndex]; | 1896 NSInteger index = [self indexFromModelIndex:modelIndex]; |
1896 BrowserWindowController* controller = | 1897 BrowserWindowController* controller = |
1897 (BrowserWindowController*)[[switchView_ window] windowController]; | 1898 (BrowserWindowController*)[[switchView_ window] windowController]; |
1898 DCHECK(index >= 0); | 1899 DCHECK(index >= 0); |
1899 if (index >= 0) { | 1900 if (index >= 0) { |
1900 [controller setTab:[self viewAtIndex:index] isDraggable:YES]; | 1901 [controller setTab:[self viewAtIndex:index] isDraggable:YES]; |
1901 } | 1902 } |
1902 } | 1903 } |
1903 | 1904 |
1904 @end | 1905 @end |
OLD | NEW |